Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix silent errors in AST import tests #12018

Merged
merged 1 commit into from
Sep 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion scripts/ASTImportTest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,24 @@ function testImportExportEquivalence {

if $SOLC "$nth_input_file" "${all_input_files[@]}" > /dev/null 2>&1
then
! [[ -e stderr.txt ]] || { echo "stderr.txt already exists. Refusing to overwrite."; exit 1; }

# save exported json as expected result (silently)
$SOLC --combined-json ast,compact-format --pretty-json "$nth_input_file" "${all_input_files[@]}" > expected.json 2> /dev/null
# import it, and export it again as obtained result (silently)
if ! $SOLC --import-ast --combined-json ast,compact-format --pretty-json expected.json > obtained.json 2> /dev/null
if ! $SOLC --import-ast --combined-json ast,compact-format --pretty-json expected.json > obtained.json 2> stderr.txt
then
# For investigating, use exit 1 here so the script stops at the
# first failing test
# exit 1
FAILED=$((FAILED + 1))
echo -e "ERROR: AST reimport failed for input file $nth_input_file"
echo
echo "Compiler stderr:"
cat ./stderr.txt
echo
echo "Compiler stdout:"
cat ./obtained.json
return 1
fi
DIFF="$(diff expected.json obtained.json)"
Expand All @@ -72,6 +81,7 @@ function testImportExportEquivalence {
fi
TESTED=$((TESTED + 1))
rm expected.json obtained.json
rm -f stderr.txt
else
# echo "contract $solfile could not be compiled "
UNCOMPILABLE=$((UNCOMPILABLE + 1))
Expand Down