From 4e4f46cde5a364423247f74882f7d99cea820fe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Sat, 10 Apr 2021 22:24:05 +0200 Subject: [PATCH 1/2] cmdlineTests: Allow tests with no input file --- test/cmdlineTests.sh | 11 ++++------- test/cmdlineTests/standard_file_not_found/args | 2 +- test/cmdlineTests/standard_file_not_found/err | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh index 0f45deaa4..555a74515 100755 --- a/test/cmdlineTests.sh +++ b/test/cmdlineTests.sh @@ -131,9 +131,11 @@ function test_solc_behaviour() if [[ "$exit_code_expected" = "" ]]; then exit_code_expected="0"; fi - local solc_command="$SOLC ${filename} ${solc_args[*]} <$solc_stdin" + [[ $filename == "" ]] || solc_args+=("$filename") + + local solc_command="$SOLC ${solc_args[*]} <$solc_stdin" set +e - "$SOLC" "${filename}" "${solc_args[@]}" <"$solc_stdin" >"$stdout_path" 2>"$stderr_path" + "$SOLC" "${solc_args[@]}" <"$solc_stdin" >"$stdout_path" 2>"$stderr_path" exitCode=$? set -e @@ -300,11 +302,6 @@ printTask "Running general commandline tests..." # Use printf to get rid of the trailing newline inputFile=$(printf "%s" "${inputFiles}") - # If no files specified, assume input.sol as the default - if [ -z "${inputFile}" ]; then - inputFile="${tdir}/input.sol" - fi - if [ "${inputFile}" = "${tdir}/input.json" ] then stdin="${inputFile}" diff --git a/test/cmdlineTests/standard_file_not_found/args b/test/cmdlineTests/standard_file_not_found/args index 69ea051f1..ee8e7c840 100644 --- a/test/cmdlineTests/standard_file_not_found/args +++ b/test/cmdlineTests/standard_file_not_found/args @@ -1 +1 @@ ---standard-json \ No newline at end of file +--standard-json input.sol diff --git a/test/cmdlineTests/standard_file_not_found/err b/test/cmdlineTests/standard_file_not_found/err index e2f23b9f3..a97cc5b7a 100644 --- a/test/cmdlineTests/standard_file_not_found/err +++ b/test/cmdlineTests/standard_file_not_found/err @@ -1 +1 @@ -File not found: standard_file_not_found/input.sol +File not found: input.sol From 59ef75cf5ab56a88ced41c28542209351f3caa5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Sat, 10 Apr 2021 21:56:22 +0200 Subject: [PATCH 2/2] cmdlineTests: Allow providing content of the standard input when not testing via Standard JSON --- test/cmdlineTests.sh | 11 ++++++++++- test/cmdlineTests/stdin/args | 1 + test/cmdlineTests/stdin/err | 5 +++++ test/cmdlineTests/stdin/stdin | 1 + 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 test/cmdlineTests/stdin/args create mode 100644 test/cmdlineTests/stdin/err create mode 100644 test/cmdlineTests/stdin/stdin diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh index 555a74515..6db8e60c3 100755 --- a/test/cmdlineTests.sh +++ b/test/cmdlineTests.sh @@ -304,13 +304,22 @@ printTask "Running general commandline tests..." if [ "${inputFile}" = "${tdir}/input.json" ] then + ! [ -e "${tdir}/stdin" ] || { printError "Found a file called 'stdin' but redirecting standard input in JSON mode is not allowed."; exit 1; } + stdin="${inputFile}" inputFile="" stdout="$(cat "${tdir}/output.json" 2>/dev/null || true)" stdoutExpectationFile="${tdir}/output.json" command_args="--standard-json "$(cat "${tdir}/args" 2>/dev/null || true) else - stdin="" + if [ -e "${tdir}/stdin" ] + then + stdin="${tdir}/stdin" + [ -f "${tdir}/stdin" ] || { printError "'stdin' is not a regular file."; exit 1; } + else + stdin="" + fi + stdout="$(cat "${tdir}/output" 2>/dev/null || true)" stdoutExpectationFile="${tdir}/output" command_args=$(cat "${tdir}/args" 2>/dev/null || true) diff --git a/test/cmdlineTests/stdin/args b/test/cmdlineTests/stdin/args new file mode 100644 index 000000000..39cdd0ded --- /dev/null +++ b/test/cmdlineTests/stdin/args @@ -0,0 +1 @@ +- diff --git a/test/cmdlineTests/stdin/err b/test/cmdlineTests/stdin/err new file mode 100644 index 000000000..c5254f827 --- /dev/null +++ b/test/cmdlineTests/stdin/err @@ -0,0 +1,5 @@ +Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information. +--> + +Warning: Source file does not specify required compiler version! +--> diff --git a/test/cmdlineTests/stdin/stdin b/test/cmdlineTests/stdin/stdin new file mode 100644 index 000000000..2dde0d209 --- /dev/null +++ b/test/cmdlineTests/stdin/stdin @@ -0,0 +1 @@ +contract C {}