Skip to content

Commit

Permalink
tools/ci.sh: Add test for mpy-tool's merging feature.
Browse files Browse the repository at this point in the history
Signed-off-by: Damien George <[email protected]>
  • Loading branch information
dpgeorge committed Jun 7, 2022
1 parent 599a22e commit bf92b0c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ports_unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ jobs:
run: source tools/ci.sh && ci_unix_coverage_build
- name: Run main test suite
run: source tools/ci.sh && ci_unix_coverage_run_tests
- name: Test merging .mpy files
run: source tools/ci.sh && ci_unix_coverage_run_mpy_merge_tests
- name: Build native mpy modules
run: source tools/ci.sh && ci_native_mpy_modules_build
- name: Test importing .mpy generated by mpy_ld.py
Expand Down
24 changes: 24 additions & 0 deletions tools/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,30 @@ function ci_unix_coverage_run_tests {
ci_unix_run_tests_full_helper coverage
}

function ci_unix_coverage_run_mpy_merge_tests {
mptop=$(pwd)
outdir=$(mktemp -d)
allmpy=()

# Compile a selection of tests to .mpy and execute them, collecting the output.
# None of the tests should SKIP.
for inpy in $mptop/tests/basics/[acdel]*.py; do
test=$(basename $inpy .py)
echo $test
outmpy=$outdir/$test.mpy
$mptop/mpy-cross/mpy-cross -o $outmpy $inpy
(cd $outdir && $mptop/ports/unix/micropython-coverage -m $test >> out-individual)
allmpy+=($outmpy)
done

# Merge all the tests into one .mpy file, and then execute it.
python3 $mptop/tools/mpy-tool.py --merge -o $outdir/merged.mpy ${allmpy[@]}
(cd $outdir && $mptop/ports/unix/micropython-coverage -m merged > out-merged)

# Make sure the outputs match.
diff $outdir/out-individual $outdir/out-merged && /bin/rm -rf $outdir
}

function ci_unix_coverage_run_native_mpy_tests {
MICROPYPATH=examples/natmod/features2 ./ports/unix/micropython-coverage -m features2
(cd tests && ./run-natmodtests.py "$@" extmod/{btree*,framebuf*,uheapq*,urandom*,ure*,uzlib*}.py)
Expand Down

0 comments on commit bf92b0c

Please sign in to comment.