Refactorings.

This commit is contained in:
Alexander Arlt 2022-04-27 13:47:13 +02:00
parent d4c8c9947d
commit 8e55cacd7c

View File

@ -75,11 +75,7 @@ function Ast_ImportExportEquivalence
cat ./obtained.json >&2
return 1
fi
set +e
diff_files expected.json obtained.json
DIFF=$?
set -e
if [[ ${DIFF} != 0 ]]
if ! diff_files expected.json obtained.json
then
FAILED=$((FAILED + 1))
fi
@ -101,7 +97,12 @@ function JsonEvmAsm_ImportExportEquivalence
cat expected.error >&2
UNCOMPILABLE=$((UNCOMPILABLE + 1))
return 0
else
fi
# Note that we have some test files, that only consists of free functions.
# Those files doesn't define any contracts, so the resulting json does not define any
# keys. In this case `jq` returns an error like `jq: error: null (null) has no keys`
# to not get spammed by these errors, errors are redirected to /dev/null.
for contract in $(jq '.contracts | keys | .[]' expected.json 2> /dev/null)
do
for output in "${outputs[@]}"
@ -119,7 +120,8 @@ function JsonEvmAsm_ImportExportEquivalence
cat obtained.error >&2
FAILED=$((FAILED + 1))
return 0
else
fi
for output in "${outputs[@]}"
do
for obtained_contract in $(jq '.contracts | keys | .[]' obtained.json 2> /dev/null)
@ -142,7 +144,8 @@ function JsonEvmAsm_ImportExportEquivalence
cat obtained_direct_import_export.error >&2
FAILED=$((FAILED + 1))
return 0
else
fi
# reformat jsons using jq.
jq . expected.asm.json > expected.asm.json.pretty
jq . obtained_direct_import_export.json > obtained_direct_import_export.json.pretty
@ -153,11 +156,8 @@ function JsonEvmAsm_ImportExportEquivalence
return 0
fi
fi
fi
fi
done
fi
if [ -n "${_TESTED}" ]
then
TESTED=$((TESTED + 1))