From 3e2b62ab89b258e8d68a5d816478e892971deff4 Mon Sep 17 00:00:00 2001 From: Alexander Arlt Date: Tue, 29 Mar 2022 15:09:47 -0500 Subject: [PATCH] scripts/ImportExportTest.sh: add support for 'set -euo pipefail'. --- scripts/ImportExportTest.sh | 19 ++++++++++++------- scripts/common.sh | 5 +++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/scripts/ImportExportTest.sh b/scripts/ImportExportTest.sh index ea0fd7a84..08dc27868 100755 --- a/scripts/ImportExportTest.sh +++ b/scripts/ImportExportTest.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -set -e +set -euo pipefail IMPORT_TEST_TYPE="${1}" # Bash script to test the import/exports. @@ -60,7 +60,7 @@ function Ast_ImportExportEquivalence set +e diff_files expected.json obtained.json DIFF=$? - set -e + set -euo pipefail if [[ ${DIFF} != 0 ]] then FAILED=$((FAILED + 1)) @@ -112,7 +112,7 @@ function JsonEvmAsm_ImportExportEquivalence set +e diff_files "expected.${output}" "obtained.${output}" DIFF=$? - set -e + set -euo pipefail if [[ ${DIFF} != 0 ]] then _TESTED= @@ -137,7 +137,7 @@ function JsonEvmAsm_ImportExportEquivalence set +e diff_files "expected.asm" "obtained_direct_import_export.asm" DIFF=$? - set -e + set -euo pipefail if [[ ${DIFF} != 0 ]] then _TESTED= @@ -166,6 +166,11 @@ function testImportExportEquivalence { local nth_input_file="$1" IFS=" " read -r -a all_input_files <<< "$2" + if [ -z ${all_input_files+x} ] + then + all_input_files=( "" ) + fi + if $SOLC --bin "$nth_input_file" "${all_input_files[@]}" > /dev/null 2>&1 then ! [[ -e stderr.txt ]] || { printError "stderr.txt already exists. Refusing to overwrite."; exit 1; } @@ -219,7 +224,7 @@ do set +e OUTPUT=$("$SPLITSOURCES" "$solfile") SPLITSOURCES_RC=$? - set -e + set -euo pipefail if [ ${SPLITSOURCES_RC} == 0 ] then NSOURCES=$((NSOURCES - 1)) @@ -230,14 +235,14 @@ do done elif [ ${SPLITSOURCES_RC} == 1 ] then - testImportExportEquivalence "$solfile" + testImportExportEquivalence "$solfile" "" elif [ ${SPLITSOURCES_RC} == 2 ] then # The script will exit with return code 2, if an UnicodeDecodeError occurred. # This is the case if e.g. some tests are using invalid utf-8 sequences. We will ignore # these errors, but print the actual output of the script. printError "\n${OUTPUT}\n" - testImportExportEquivalence "$solfile" + testImportExportEquivalence "$solfile" "" else # All other return codes will be treated as critical errors. The script will exit. printError "\nGot unexpected return code ${SPLITSOURCES_RC} from ${SPLITSOURCES}. Aborting." diff --git a/scripts/common.sh b/scripts/common.sh index 756fbe9ce..dfedac503 100644 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -26,6 +26,11 @@ set -e # changes directory. The paths returned by `caller` are relative to it. _initial_work_dir=$(pwd) +if [ -z ${CIRCLECI+x} ] +then + CIRCLECI=0 +fi + if [ "$CIRCLECI" ] then export TERM="${TERM:-xterm}"