Skip to content

Commit 02d2c9a

Browse files
committed
change into test dir for cmdline tests
1 parent 8cf3305 commit 02d2c9a

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

test/cmdlineTests.sh

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ EOF
225225
if jq 'has("ethdebug")' "$stdout_path" --exit-status > /dev/null; then
226226
local temporary_file
227227
temporary_file=$(mktemp -t cmdline-ethdebug-XXXXXX.tmp)
228-
if [[ -e ${tdir}/strip-ethdebug ]]; then
228+
if [[ -e strip-ethdebug ]]; then
229229
jq --indent 4 '
230230
(. | .. | objects | select(has("ethdebug"))) |= (.ethdebug = "<ETHDEBUG DEBUG DATA REMOVED>")
231231
' "$stdout_path" > "$temporary_file"
@@ -350,9 +350,11 @@ test_solc_behaviour "${0}" "ctx:=/some/remapping/target" "" "" 1 "" "Error: Inva
350350

351351
printTask "Running general commandline tests..."
352352
(
353-
cd "$REPO_ROOT"/test/cmdlineTests/
354353
for tdir in "${selected_tests[@]}"
355354
do
355+
# go back to the test root dir
356+
cd "$REPO_ROOT"/test/cmdlineTests/
357+
356358
if ! [[ -d $tdir ]]
357359
then
358360
fail "Test directory not found: $tdir"
@@ -377,18 +379,21 @@ printTask "Running general commandline tests..."
377379
fi
378380
fi
379381

380-
scriptFiles="$(ls -1 "${tdir}/test."* 2> /dev/null || true)"
382+
# jump into test dir
383+
cd "${tdir}"
384+
385+
scriptFiles="$(ls -1 "test."* 2> /dev/null || true)"
381386
scriptCount="$(echo "${scriptFiles}" | wc -w)"
382387

383-
inputFiles="$(ls -1 "${tdir}/input."* 2> /dev/null || true)"
388+
inputFiles="$(ls -1 "input."* 2> /dev/null || true)"
384389
inputCount="$(echo "${inputFiles}" | wc -w)"
385390
(( inputCount <= 1 )) || fail "Ambiguous input. Found input files in multiple formats:"$'\n'"${inputFiles}"
386391
(( scriptCount <= 1 )) || fail "Ambiguous input. Found script files in multiple formats:"$'\n'"${scriptFiles}"
387392
(( inputCount == 0 || scriptCount == 0 )) || fail "Ambiguous input. Found both input and script files:"$'\n'"${inputFiles}"$'\n'"${scriptFiles}"
388393

389394
if (( scriptCount == 1 ))
390395
then
391-
if ! "$scriptFiles"
396+
if ! "./$scriptFiles"
392397
then
393398
fail "Test script ${scriptFiles} failed."
394399
fi
@@ -399,38 +404,38 @@ printTask "Running general commandline tests..."
399404
# Use printf to get rid of the trailing newline
400405
inputFile=$(printf "%s" "${inputFiles}")
401406

402-
if [ "${inputFile}" = "${tdir}/input.json" ]
407+
if [ "${inputFile}" = "input.json" ]
403408
then
404-
! [ -e "${tdir}/stdin" ] || fail "Found a file called 'stdin' but redirecting standard input in JSON mode is not allowed."
409+
! [ -e "stdin" ] || fail "Found a file called 'stdin' but redirecting standard input in JSON mode is not allowed."
405410

406411
stdin="${inputFile}"
407412
inputFile=""
408-
stdout="$(cat "${tdir}/output.json" 2>/dev/null || true)"
409-
stdoutExpectationFile="${tdir}/output.json"
413+
stdout="$(cat "output.json" 2>/dev/null || true)"
414+
stdoutExpectationFile="output.json"
410415
prettyPrintFlags=""
411-
if [[ ! -f "${tdir}/no-pretty-print" ]]
416+
if [[ ! -f "no-pretty-print" ]]
412417
then
413418
prettyPrintFlags="--pretty-json --json-indent 4"
414419
fi
415420

416-
command_args="--standard-json ${prettyPrintFlags} "$(cat "${tdir}/args" 2>/dev/null || true)
421+
command_args="--standard-json ${prettyPrintFlags} "$(cat "args" 2>/dev/null || true)
417422
else
418-
if [ -e "${tdir}/stdin" ]
423+
if [ -e "stdin" ]
419424
then
420-
stdin="${tdir}/stdin"
421-
[ -f "${tdir}/stdin" ] || fail "'stdin' is not a regular file."
425+
stdin="stdin"
426+
[ -f "stdin" ] || fail "'stdin' is not a regular file."
422427
else
423428
stdin=""
424429
fi
425430

426-
stdout="$(cat "${tdir}/output" 2>/dev/null || true)"
427-
stdoutExpectationFile="${tdir}/output"
428-
command_args=$(cat "${tdir}/args" 2>/dev/null || true)
431+
stdout="$(cat "output" 2>/dev/null || true)"
432+
stdoutExpectationFile="output"
433+
command_args=$(cat "args" 2>/dev/null || true)
429434
fi
430-
exitCodeExpectationFile="${tdir}/exit"
435+
exitCodeExpectationFile="exit"
431436
exitCode=$(cat "$exitCodeExpectationFile" 2>/dev/null || true)
432-
err="$(cat "${tdir}/err" 2>/dev/null || true)"
433-
stderrExpectationFile="${tdir}/err"
437+
err="$(cat "err" 2>/dev/null || true)"
438+
stderrExpectationFile="err"
434439
test_solc_behaviour "$inputFile" \
435440
"$command_args" \
436441
"$stdin" \

0 commit comments

Comments
 (0)