11#! /usr/bin/env bash
22
3- set -e
3+ set -euo pipefail
44IMPORT_TEST_TYPE=" ${1} "
55
66# Bash script to test the import/exports.
@@ -60,7 +60,7 @@ function Ast_ImportExportEquivalence
6060 set +e
6161 diff_files expected.json obtained.json
6262 DIFF=$?
63- set -e
63+ set -euo pipefail
6464 if [[ ${DIFF} != 0 ]]
6565 then
6666 FAILED=$(( FAILED + 1 ))
@@ -112,7 +112,7 @@ function JsonEvmAsm_ImportExportEquivalence
112112 set +e
113113 diff_files " expected.${output} " " obtained.${output} "
114114 DIFF=$?
115- set -e
115+ set -euo pipefail
116116 if [[ ${DIFF} != 0 ]]
117117 then
118118 _TESTED=
@@ -137,7 +137,7 @@ function JsonEvmAsm_ImportExportEquivalence
137137 set +e
138138 diff_files " expected.asm" " obtained_direct_import_export.asm"
139139 DIFF=$?
140- set -e
140+ set -euo pipefail
141141 if [[ ${DIFF} != 0 ]]
142142 then
143143 _TESTED=
@@ -166,6 +166,11 @@ function testImportExportEquivalence {
166166 local nth_input_file=" $1 "
167167 IFS=" " read -r -a all_input_files <<< " $2"
168168
169+ if [ -z ${all_input_files+x} ]
170+ then
171+ all_input_files=
172+ fi
173+
169174 if $SOLC --bin " $nth_input_file " " ${all_input_files[@]} " > /dev/null 2>&1
170175 then
171176 ! [[ -e stderr.txt ]] || { printError " stderr.txt already exists. Refusing to overwrite." ; exit 1; }
219224 set +e
220225 OUTPUT=$( " $SPLITSOURCES " " $solfile " )
221226 SPLITSOURCES_RC=$?
222- set -e
227+ set -euo pipefail
223228 if [ ${SPLITSOURCES_RC} == 0 ]
224229 then
225230 NSOURCES=$(( NSOURCES - 1 ))
230235 done
231236 elif [ ${SPLITSOURCES_RC} == 1 ]
232237 then
233- testImportExportEquivalence " $solfile "
238+ testImportExportEquivalence " $solfile " " "
234239 elif [ ${SPLITSOURCES_RC} == 2 ]
235240 then
236241 # The script will exit with return code 2, if an UnicodeDecodeError occurred.
237242 # This is the case if e.g. some tests are using invalid utf-8 sequences. We will ignore
238243 # these errors, but print the actual output of the script.
239244 printError " \n${OUTPUT} \n"
240- testImportExportEquivalence " $solfile "
245+ testImportExportEquivalence " $solfile " " "
241246 else
242247 # All other return codes will be treated as critical errors. The script will exit.
243248 printError " \nGot unexpected return code ${SPLITSOURCES_RC} from ${SPLITSOURCES} . Aborting."
0 commit comments