mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
cmdlineTests.sh: Add fail helper to make exiting on an error more convenient
This commit is contained in:
parent
ce61a2bf28
commit
26f9a554fb
@ -33,6 +33,12 @@ else
|
|||||||
function printLog() { echo "$(tput setaf 3)$1$(tput sgr0)"; }
|
function printLog() { echo "$(tput setaf 3)$1$(tput sgr0)"; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
function fail()
|
||||||
|
{
|
||||||
|
printError "$@"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
safe_kill()
|
safe_kill()
|
||||||
{
|
{
|
||||||
local PID=${1}
|
local PID=${1}
|
||||||
|
@ -323,8 +323,7 @@ printTask "Testing unknown options..."
|
|||||||
then
|
then
|
||||||
echo "Passed"
|
echo "Passed"
|
||||||
else
|
else
|
||||||
printError "Incorrect response to unknown options: $output"
|
fail "Incorrect response to unknown options: $output"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -346,8 +345,7 @@ printTask "Running general commandline tests..."
|
|||||||
do
|
do
|
||||||
if ! [[ -d $tdir ]]
|
if ! [[ -d $tdir ]]
|
||||||
then
|
then
|
||||||
printError "Test directory not found: $tdir"
|
fail "Test directory not found: $tdir"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printTask " - ${tdir}"
|
printTask " - ${tdir}"
|
||||||
@ -383,7 +381,7 @@ printTask "Running general commandline tests..."
|
|||||||
|
|
||||||
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; }
|
! [ -e "${tdir}/stdin" ] || fail "Found a file called 'stdin' but redirecting standard input in JSON mode is not allowed."
|
||||||
|
|
||||||
stdin="${inputFile}"
|
stdin="${inputFile}"
|
||||||
inputFile=""
|
inputFile=""
|
||||||
@ -394,7 +392,7 @@ printTask "Running general commandline tests..."
|
|||||||
if [ -e "${tdir}/stdin" ]
|
if [ -e "${tdir}/stdin" ]
|
||||||
then
|
then
|
||||||
stdin="${tdir}/stdin"
|
stdin="${tdir}/stdin"
|
||||||
[ -f "${tdir}/stdin" ] || { printError "'stdin' is not a regular file."; exit 1; }
|
[ -f "${tdir}/stdin" ] || fail "'stdin' is not a regular file."
|
||||||
else
|
else
|
||||||
stdin=""
|
stdin=""
|
||||||
fi
|
fi
|
||||||
@ -543,22 +541,19 @@ SOLTMPDIR=$(mktemp -d)
|
|||||||
# This should fail
|
# This should fail
|
||||||
if [[ ! ("$output" =~ "No input files given") || ($result == 0) ]]
|
if [[ ! ("$output" =~ "No input files given") || ($result == 0) ]]
|
||||||
then
|
then
|
||||||
printError "Incorrect response to empty input arg list: $output"
|
fail "Incorrect response to empty input arg list: $output"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# The contract should be compiled
|
# The contract should be compiled
|
||||||
if ! output=$(echo 'contract C {} ' | "$SOLC" - --bin 2>/dev/null | grep -q "<stdin>:C")
|
if ! output=$(echo 'contract C {} ' | "$SOLC" - --bin 2>/dev/null | grep -q "<stdin>:C")
|
||||||
then
|
then
|
||||||
printError "Failed to compile a simple contract from standard input"
|
fail "Failed to compile a simple contract from standard input"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# This should not fail
|
# This should not fail
|
||||||
if ! output=$(echo '' | "$SOLC" --ast-compact-json - 2>/dev/null)
|
if ! output=$(echo '' | "$SOLC" --ast-compact-json - 2>/dev/null)
|
||||||
then
|
then
|
||||||
printError "Incorrect response to --ast-compact-json option with empty stdin"
|
fail "Incorrect response to --ast-compact-json option with empty stdin"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
rm -r "$SOLTMPDIR"
|
rm -r "$SOLTMPDIR"
|
||||||
|
Loading…
Reference in New Issue
Block a user