mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #11235 from ethereum/cmdline-tests-for-stdin
Allow using stdin in cmdlineTests
This commit is contained in:
commit
2abd3073d4
@ -131,9 +131,11 @@ function test_solc_behaviour()
|
|||||||
|
|
||||||
if [[ "$exit_code_expected" = "" ]]; then exit_code_expected="0"; fi
|
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
|
set +e
|
||||||
"$SOLC" "${filename}" "${solc_args[@]}" <"$solc_stdin" >"$stdout_path" 2>"$stderr_path"
|
"$SOLC" "${solc_args[@]}" <"$solc_stdin" >"$stdout_path" 2>"$stderr_path"
|
||||||
exitCode=$?
|
exitCode=$?
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@ -300,20 +302,24 @@ printTask "Running general commandline tests..."
|
|||||||
# Use printf to get rid of the trailing newline
|
# Use printf to get rid of the trailing newline
|
||||||
inputFile=$(printf "%s" "${inputFiles}")
|
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" ]
|
if [ "${inputFile}" = "${tdir}/input.json" ]
|
||||||
then
|
then
|
||||||
|
! [ -e "${tdir}/stdin" ] || { printError "Found a file called 'stdin' but redirecting standard input in JSON mode is not allowed."; exit 1; }
|
||||||
|
|
||||||
stdin="${inputFile}"
|
stdin="${inputFile}"
|
||||||
inputFile=""
|
inputFile=""
|
||||||
stdout="$(cat "${tdir}/output.json" 2>/dev/null || true)"
|
stdout="$(cat "${tdir}/output.json" 2>/dev/null || true)"
|
||||||
stdoutExpectationFile="${tdir}/output.json"
|
stdoutExpectationFile="${tdir}/output.json"
|
||||||
command_args="--standard-json "$(cat "${tdir}/args" 2>/dev/null || true)
|
command_args="--standard-json "$(cat "${tdir}/args" 2>/dev/null || true)
|
||||||
else
|
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)"
|
stdout="$(cat "${tdir}/output" 2>/dev/null || true)"
|
||||||
stdoutExpectationFile="${tdir}/output"
|
stdoutExpectationFile="${tdir}/output"
|
||||||
command_args=$(cat "${tdir}/args" 2>/dev/null || true)
|
command_args=$(cat "${tdir}/args" 2>/dev/null || true)
|
||||||
|
@ -1 +1 @@
|
|||||||
--standard-json
|
--standard-json input.sol
|
||||||
|
@ -1 +1 @@
|
|||||||
File not found: standard_file_not_found/input.sol
|
File not found: input.sol
|
||||||
|
1
test/cmdlineTests/stdin/args
Normal file
1
test/cmdlineTests/stdin/args
Normal file
@ -0,0 +1 @@
|
|||||||
|
-
|
5
test/cmdlineTests/stdin/err
Normal file
5
test/cmdlineTests/stdin/err
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
|
||||||
|
--> <stdin>
|
||||||
|
|
||||||
|
Warning: Source file does not specify required compiler version!
|
||||||
|
--> <stdin>
|
1
test/cmdlineTests/stdin/stdin
Normal file
1
test/cmdlineTests/stdin/stdin
Normal file
@ -0,0 +1 @@
|
|||||||
|
contract C {}
|
Loading…
Reference in New Issue
Block a user