1
1
#! /usr/bin/env bash
2
2
3
- set -e
3
+ set -euo pipefail
4
4
IMPORT_TEST_TYPE=" ${1} "
5
5
6
6
# Bash script to test the import/exports.
@@ -60,7 +60,7 @@ function Ast_ImportExportEquivalence
60
60
set +e
61
61
diff_files expected.json obtained.json
62
62
DIFF=$?
63
- set -e
63
+ set -euo pipefail
64
64
if [[ ${DIFF} != 0 ]]
65
65
then
66
66
FAILED=$(( FAILED + 1 ))
@@ -112,7 +112,7 @@ function JsonEvmAsm_ImportExportEquivalence
112
112
set +e
113
113
diff_files " expected.${output} " " obtained.${output} "
114
114
DIFF=$?
115
- set -e
115
+ set -euo pipefail
116
116
if [[ ${DIFF} != 0 ]]
117
117
then
118
118
_TESTED=
@@ -137,7 +137,7 @@ function JsonEvmAsm_ImportExportEquivalence
137
137
set +e
138
138
diff_files " expected.asm" " obtained_direct_import_export.asm"
139
139
DIFF=$?
140
- set -e
140
+ set -euo pipefail
141
141
if [[ ${DIFF} != 0 ]]
142
142
then
143
143
_TESTED=
@@ -166,6 +166,11 @@ function testImportExportEquivalence {
166
166
local nth_input_file=" $1 "
167
167
IFS=" " read -r -a all_input_files <<< " $2"
168
168
169
+ if [ -z ${all_input_files+x} ]
170
+ then
171
+ all_input_files=
172
+ fi
173
+
169
174
if $SOLC --bin " $nth_input_file " " ${all_input_files[@]} " > /dev/null 2>&1
170
175
then
171
176
! [[ -e stderr.txt ]] || { printError " stderr.txt already exists. Refusing to overwrite." ; exit 1; }
219
224
set +e
220
225
OUTPUT=$( " $SPLITSOURCES " " $solfile " )
221
226
SPLITSOURCES_RC=$?
222
- set -e
227
+ set -euo pipefail
223
228
if [ ${SPLITSOURCES_RC} == 0 ]
224
229
then
225
230
NSOURCES=$(( NSOURCES - 1 ))
230
235
done
231
236
elif [ ${SPLITSOURCES_RC} == 1 ]
232
237
then
233
- testImportExportEquivalence " $solfile "
238
+ testImportExportEquivalence " $solfile " " "
234
239
elif [ ${SPLITSOURCES_RC} == 2 ]
235
240
then
236
241
# The script will exit with return code 2, if an UnicodeDecodeError occurred.
237
242
# This is the case if e.g. some tests are using invalid utf-8 sequences. We will ignore
238
243
# these errors, but print the actual output of the script.
239
244
printError " \n${OUTPUT} \n"
240
- testImportExportEquivalence " $solfile "
245
+ testImportExportEquivalence " $solfile " " "
241
246
else
242
247
# All other return codes will be treated as critical errors. The script will exit.
243
248
printError " \nGot unexpected return code ${SPLITSOURCES_RC} from ${SPLITSOURCES} . Aborting."
0 commit comments