mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #6524 from ethereum/cmdlineUpdateInteractive
Only ask for cmdline test updates in interactive runs.
This commit is contained in:
commit
3b3d9db7af
@ -32,6 +32,11 @@ set -e
|
|||||||
|
|
||||||
REPO_ROOT=$(cd $(dirname "$0")/.. && pwd)
|
REPO_ROOT=$(cd $(dirname "$0")/.. && pwd)
|
||||||
SOLC="$REPO_ROOT/build/solc/solc"
|
SOLC="$REPO_ROOT/build/solc/solc"
|
||||||
|
INTERACTIVE=true
|
||||||
|
if ! tty -s || [ "$CI" ]
|
||||||
|
then
|
||||||
|
INTERACTIVE=""
|
||||||
|
fi
|
||||||
|
|
||||||
FULLARGS="--optimize --ignore-missing --combined-json abi,asm,ast,bin,bin-runtime,compact-format,devdoc,hashes,interface,metadata,opcodes,srcmap,srcmap-runtime,userdoc"
|
FULLARGS="--optimize --ignore-missing --combined-json abi,asm,ast,bin,bin-runtime,compact-format,devdoc,hashes,interface,metadata,opcodes,srcmap,srcmap-runtime,userdoc"
|
||||||
|
|
||||||
@ -95,23 +100,19 @@ function compileFull()
|
|||||||
|
|
||||||
function ask_expectation_update()
|
function ask_expectation_update()
|
||||||
{
|
{
|
||||||
|
if [ $INTERACTIVE ]
|
||||||
|
then
|
||||||
local newExpectation="${1}"
|
local newExpectation="${1}"
|
||||||
local expectationFile="${2}"
|
local expectationFile="${2}"
|
||||||
while true;
|
while true;
|
||||||
do
|
do
|
||||||
set +e
|
read -p "(u)pdate expectation/(q)uit? "
|
||||||
read -t10 -p "(u)pdate expectation/(q)uit? "
|
|
||||||
if [ $? -gt 128 ];
|
|
||||||
then
|
|
||||||
echo -e "\nUser input timed out."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
set -e
|
|
||||||
case $REPLY in
|
case $REPLY in
|
||||||
u* ) echo "$newExpectation" > $expectationFile ; break;;
|
u* ) echo "$newExpectation" > $expectationFile ; break;;
|
||||||
q* ) exit 1;;
|
q* ) exit 1;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# General helper function for testing SOLC behaviour, based on file name, compile opts, exit code, stdout and stderr.
|
# General helper function for testing SOLC behaviour, based on file name, compile opts, exit code, stdout and stderr.
|
||||||
@ -121,6 +122,7 @@ function test_solc_behaviour()
|
|||||||
local filename="${1}"
|
local filename="${1}"
|
||||||
local solc_args="${2}"
|
local solc_args="${2}"
|
||||||
local solc_stdin="${3}"
|
local solc_stdin="${3}"
|
||||||
|
[ -z "$solc_stdin" ] && solc_stdin="/dev/stdin"
|
||||||
local stdout_expected="${4}"
|
local stdout_expected="${4}"
|
||||||
local exit_code_expected="${5}"
|
local exit_code_expected="${5}"
|
||||||
local stderr_expected="${6}"
|
local stderr_expected="${6}"
|
||||||
@ -133,13 +135,9 @@ 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}"
|
local solc_command="$SOLC ${filename} ${solc_args} <$solc_stdin"
|
||||||
if [[ -n "$solc_stdin" ]]; then solc_command+=" <$solc_stdin" ; fi
|
|
||||||
if [[ -n "$stdout_path" ]]; then solc_command+=" 1>$stdout_path"; fi
|
|
||||||
if [[ -n "$stderr_path" ]]; then solc_command+=" 2>$stderr_path"; fi
|
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
eval "$solc_command"
|
"$SOLC" "${filename}" ${solc_args} <"$solc_stdin" >"$stdout_path" 2>"$stderr_path"
|
||||||
exitCode=$?
|
exitCode=$?
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@ -165,10 +163,10 @@ function test_solc_behaviour()
|
|||||||
if [[ "$(cat $stdout_path)" != "${stdout_expected}" ]]
|
if [[ "$(cat $stdout_path)" != "${stdout_expected}" ]]
|
||||||
then
|
then
|
||||||
printError "Incorrect output on stdout received. Expected:"
|
printError "Incorrect output on stdout received. Expected:"
|
||||||
echo "${stdout_expected}"
|
echo -e "${stdout_expected}"
|
||||||
|
|
||||||
printError "But got:"
|
printError "But got:"
|
||||||
cat $stdout_path
|
echo -e "$(cat $stdout_path)"
|
||||||
|
|
||||||
printError "When running $solc_command"
|
printError "When running $solc_command"
|
||||||
|
|
||||||
@ -183,10 +181,10 @@ function test_solc_behaviour()
|
|||||||
if [[ "$(cat $stderr_path)" != "${stderr_expected}" ]]
|
if [[ "$(cat $stderr_path)" != "${stderr_expected}" ]]
|
||||||
then
|
then
|
||||||
printError "Incorrect output on stderr received. Expected:"
|
printError "Incorrect output on stderr received. Expected:"
|
||||||
echo "${stderr_expected}"
|
echo -e "${stderr_expected}"
|
||||||
|
|
||||||
printError "But got:"
|
printError "But got:"
|
||||||
cat $stderr_path
|
echo -e "$(cat $stderr_path)"
|
||||||
|
|
||||||
printError "When running $solc_command"
|
printError "When running $solc_command"
|
||||||
|
|
||||||
@ -262,13 +260,13 @@ printTask "Running general commandline tests..."
|
|||||||
inputFile=""
|
inputFile=""
|
||||||
stdin="${tdir}/input.json"
|
stdin="${tdir}/input.json"
|
||||||
stdout="$(cat ${tdir}/output.json 2>/dev/null || true)"
|
stdout="$(cat ${tdir}/output.json 2>/dev/null || true)"
|
||||||
stdoutExpectationFile="$(pwd)/${tdir}/output.json"
|
stdoutExpectationFile="${tdir}/output.json"
|
||||||
args="--standard-json "$(cat ${tdir}/args 2>/dev/null || true)
|
args="--standard-json "$(cat ${tdir}/args 2>/dev/null || true)
|
||||||
else
|
else
|
||||||
inputFile="${tdir}input.sol"
|
inputFile="${tdir}input.sol"
|
||||||
stdin=""
|
stdin=""
|
||||||
stdout="$(cat ${tdir}/output 2>/dev/null || true)"
|
stdout="$(cat ${tdir}/output 2>/dev/null || true)"
|
||||||
stdoutExpectationFile="$(pwd)/${tdir}/output"
|
stdoutExpectationFile="${tdir}/output"
|
||||||
args=$(cat ${tdir}/args 2>/dev/null || true)
|
args=$(cat ${tdir}/args 2>/dev/null || true)
|
||||||
fi
|
fi
|
||||||
exitCode=$(cat ${tdir}/exit 2>/dev/null || true)
|
exitCode=$(cat ${tdir}/exit 2>/dev/null || true)
|
||||||
@ -302,8 +300,6 @@ printTask "Compiling all examples from the documentation..."
|
|||||||
SOLTMPDIR=$(mktemp -d)
|
SOLTMPDIR=$(mktemp -d)
|
||||||
(
|
(
|
||||||
set -e
|
set -e
|
||||||
cd "$REPO_ROOT"
|
|
||||||
REPO_ROOT=$(pwd) # make it absolute
|
|
||||||
cd "$SOLTMPDIR"
|
cd "$SOLTMPDIR"
|
||||||
"$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/docs/ docs
|
"$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/docs/ docs
|
||||||
for f in *.sol
|
for f in *.sol
|
||||||
@ -430,8 +426,6 @@ printTask "Testing soljson via the fuzzer..."
|
|||||||
SOLTMPDIR=$(mktemp -d)
|
SOLTMPDIR=$(mktemp -d)
|
||||||
(
|
(
|
||||||
set -e
|
set -e
|
||||||
cd "$REPO_ROOT"
|
|
||||||
REPO_ROOT=$(pwd) # make it absolute
|
|
||||||
cd "$SOLTMPDIR"
|
cd "$SOLTMPDIR"
|
||||||
"$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/test/
|
"$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/test/
|
||||||
"$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/docs/ docs
|
"$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/docs/ docs
|
||||||
|
Loading…
Reference in New Issue
Block a user