Skip to content

Commit

Permalink
fix: memory comparison script failing silently (#1333)
Browse files Browse the repository at this point in the history
* Make the memory comparison script fail correctly

* Make the script fail if no tests were run

* Make script `cd` into script's dir at startup

* Remove strange whitespace in workflow file

* Add prints

* Fix: option name is `proof_mode`, not `proof`

---------

Co-authored-by: Pedro Fontana <[email protected]>
  • Loading branch information
MegaRedHand and pefontana authored Jul 16, 2023
1 parent bdac293 commit 424b53e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ jobs:

- name: Run comparison script
run: |
if [ ${{ matrix.program-target }} = cairo_proof_programs ]; then
PROOF=proof
if [ ${{ matrix.program-target }} = cairo_proof_programs ]; then
PROOF=proof_mode
fi
./vm/src/tests/compare_vm_state.sh trace memory $PROOF
23 changes: 17 additions & 6 deletions vm/src/tests/compare_vm_state.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/usr/bin/env sh

# move to the directory where the script is located
cd $(dirname "$0")

tests_path="../../../cairo_programs"
proof_tests_path="${tests_path}/proof_programs"
exit_code=0
trace=false
memory=false
Expand All @@ -10,19 +14,23 @@ failed_tests=0
for i in $@; do
case $i in
"trace") trace=true
echo "Requested trace comparison"
;;
"memory") memory=true
echo "Requested memory comparison"
;;
"proof_mode") tests_path="../../../cairo_programs/proof_programs"
"proof_mode") tests_path=$proof_tests_path
echo "Requested proof mode usage"
;;
*)
;;
esac
done

files=$(ls $tests_path)
if [ $? != 0 ]; then
exit $?
EXIT_CODE=$?
if [ ${EXIT_CODE} != 0 ]; then
exit ${EXIT_CODE}
fi

for file in $(ls $tests_path | grep .cairo$ | sed -E 's/\.cairo$//'); do
Expand All @@ -49,10 +57,13 @@ for file in $(ls $tests_path | grep .cairo$ | sed -E 's/\.cairo$//'); do
fi
done

if test $failed_tests = 0; then
echo "All $passed_tests tests passed; no discrepancies found"
else
if test $failed_tests != 0; then
echo "Comparisons: $failed_tests failed, $passed_tests passed, $((failed_tests + passed_tests)) total"
elif test $passed_tests = 0; then
echo "No tests ran!"
exit_code=2
else
echo "All $passed_tests tests passed; no discrepancies found"
fi

exit "${exit_code}"

0 comments on commit 424b53e

Please sign in to comment.