scripts/ImportExportTest.sh: adding test for --optimized

This commit is contained in:
Alexander Arlt 2022-03-14 15:51:55 -05:00
parent 43faf23ed8
commit e8f76ff661

View File

@ -99,11 +99,13 @@ function testImportExportEquivalence {
UNCOMPILABLE=$((UNCOMPILABLE + 1)) UNCOMPILABLE=$((UNCOMPILABLE + 1))
return 0 return 0
else else
$SOLC --optimize --combined-json bin,bin-runtime,opcodes,asm,srcmap,srcmap-runtime --pretty-json "$nth_input_file" "${all_input_files[@]}" > expected_optimized.json 2> expected_optimized.error
for contract in $(jq '.contracts | keys | .[]' expected.json 2> /dev/null) for contract in $(jq '.contracts | keys | .[]' expected.json 2> /dev/null)
do do
for type in "${types[@]}" for type in "${types[@]}"
do do
jq --raw-output ".contracts.${contract}.\"${type}\"" expected.json > "expected.${type}" jq --raw-output ".contracts.${contract}.\"${type}\"" expected.json > "expected.${type}"
jq --raw-output ".contracts.${contract}.\"${type}\"" expected_optimized.json > "expected_optimized.${type}"
done done
assembly=$(cat expected.asm) assembly=$(cat expected.asm)
@ -117,27 +119,47 @@ function testImportExportEquivalence {
FAILED=$((FAILED + 1)) FAILED=$((FAILED + 1))
return 0 return 0
else else
$SOLC --combined-json bin,bin-runtime,opcodes,asm,srcmap,srcmap-runtime --pretty-json --import-asm-json expected.asm > obtained_optimized.json 2> obtained_optimized.error
for type in "${types[@]}" for type in "${types[@]}"
do do
for obtained_contract in $(jq '.contracts | keys | .[]' obtained.json 2> /dev/null) for obtained_contract in $(jq '.contracts | keys | .[]' obtained.json 2> /dev/null)
do do
jq --raw-output ".contracts.${obtained_contract}.\"${type}\"" obtained.json > "obtained.${type}" jq --raw-output ".contracts.${obtained_contract}.\"${type}\"" obtained.json > "obtained.${type}"
jq --raw-output ".contracts.${obtained_contract}.\"${type}\"" obtained_optimized.json > "obtained_optimized.${type}"
set +e set +e
DIFF="$(diff "expected.${type}" "obtained.${type}")" DIFF="$(diff "expected.${type}" "obtained.${type}")"
# DIFF_OPTIMIZED="$(diff "expected_optimized.${type}" "obtained_optimized.${type}")"
set -e set -e
if [ "$DIFF" != "" ]
then
if [ "$DIFFVIEW" == "" ] if [ "$DIFFVIEW" == "" ]
then
if [ "$DIFF" != "" ]
then then
echo -e "ERROR: JSONS differ for $1: \n $DIFF \n" echo -e "ERROR: JSONS differ for $1: \n $DIFF \n"
echo "Expected:" echo "Expected:"
cat "expected.${type}" cat "expected.${type}"
echo "Obtained:" echo "Obtained:"
cat "obtained.${type}" cat "obtained.${type}"
fi
if [ "$DIFF_OPTIMIZED" != "" ]
then
echo -e "ERROR: JSONS (optimized) differ for $1: \n $DIFF \n"
echo "Expected (optimized):"
cat "expected_optimized.${type}"
echo "Obtained (optimized):"
cat "obtained_optimized.${type}"
fi
else else
# Use user supplied diff view binary # Use user supplied diff view binary
if [ "$DIFF" != "" ]
then
echo "$DIFFVIEW expected.json obtained.json"
$DIFFVIEW expected.json obtained.json $DIFFVIEW expected.json obtained.json
fi fi
if [ "$DIFF_OPTIMIZED" != "" ]
then
echo "$DIFFVIEW expected_optimized.json obtained_optimized.json"
$DIFFVIEW expected_optimized.json obtained_optimized.json
fi
_TESTED= _TESTED=
FAILED=$((FAILED + 1)) FAILED=$((FAILED + 1))
return 0 return 0