Merge pull request #6524 from ethereum/cmdlineUpdateInteractive

Only ask for cmdline test updates in interactive runs.
This commit is contained in:
chriseth 2019-04-30 17:05:53 +02:00 committed by GitHub
commit 3b3d9db7af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -32,6 +32,11 @@ set -e
REPO_ROOT=$(cd $(dirname "$0")/.. && pwd)
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"
@ -95,23 +100,19 @@ function compileFull()
function ask_expectation_update()
{
local newExpectation="${1}"
local expectationFile="${2}"
while true;
do
set +e
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
u* ) echo "$newExpectation" > $expectationFile ; break;;
q* ) exit 1;;
esac
done
if [ $INTERACTIVE ]
then
local newExpectation="${1}"
local expectationFile="${2}"
while true;
do
read -p "(u)pdate expectation/(q)uit? "
case $REPLY in
u* ) echo "$newExpectation" > $expectationFile ; break;;
q* ) exit 1;;
esac
done
fi
}
# 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 solc_args="${2}"
local solc_stdin="${3}"
[ -z "$solc_stdin" ] && solc_stdin="/dev/stdin"
local stdout_expected="${4}"
local exit_code_expected="${5}"
local stderr_expected="${6}"
@ -133,13 +135,9 @@ function test_solc_behaviour()
if [[ "$exit_code_expected" = "" ]]; then exit_code_expected="0"; fi
local solc_command="$SOLC ${filename} ${solc_args}"
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
local solc_command="$SOLC ${filename} ${solc_args} <$solc_stdin"
set +e
eval "$solc_command"
"$SOLC" "${filename}" ${solc_args} <"$solc_stdin" >"$stdout_path" 2>"$stderr_path"
exitCode=$?
set -e
@ -165,10 +163,10 @@ function test_solc_behaviour()
if [[ "$(cat $stdout_path)" != "${stdout_expected}" ]]
then
printError "Incorrect output on stdout received. Expected:"
echo "${stdout_expected}"
echo -e "${stdout_expected}"
printError "But got:"
cat $stdout_path
echo -e "$(cat $stdout_path)"
printError "When running $solc_command"
@ -183,10 +181,10 @@ function test_solc_behaviour()
if [[ "$(cat $stderr_path)" != "${stderr_expected}" ]]
then
printError "Incorrect output on stderr received. Expected:"
echo "${stderr_expected}"
echo -e "${stderr_expected}"
printError "But got:"
cat $stderr_path
echo -e "$(cat $stderr_path)"
printError "When running $solc_command"
@ -262,13 +260,13 @@ printTask "Running general commandline tests..."
inputFile=""
stdin="${tdir}/input.json"
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)
else
inputFile="${tdir}input.sol"
stdin=""
stdout="$(cat ${tdir}/output 2>/dev/null || true)"
stdoutExpectationFile="$(pwd)/${tdir}/output"
stdoutExpectationFile="${tdir}/output"
args=$(cat ${tdir}/args 2>/dev/null || true)
fi
exitCode=$(cat ${tdir}/exit 2>/dev/null || true)
@ -302,8 +300,6 @@ printTask "Compiling all examples from the documentation..."
SOLTMPDIR=$(mktemp -d)
(
set -e
cd "$REPO_ROOT"
REPO_ROOT=$(pwd) # make it absolute
cd "$SOLTMPDIR"
"$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/docs/ docs
for f in *.sol
@ -430,8 +426,6 @@ printTask "Testing soljson via the fuzzer..."
SOLTMPDIR=$(mktemp -d)
(
set -e
cd "$REPO_ROOT"
REPO_ROOT=$(pwd) # make it absolute
cd "$SOLTMPDIR"
"$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/test/
"$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/docs/ docs