diff options
author | androlo <androlo1980@gmail.com> | 2018-12-20 19:17:33 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-12-21 07:46:31 +0800 |
commit | 88c7975ca5fc46fd6c0ea5cc0267d55f2fe97ff8 (patch) | |
tree | 6d5b7d0d67ac5e8a896f92bf187b3068a4efc1e9 /test | |
parent | 8a9e01275707a95aa731e8d9735dc2957f34a8e7 (diff) | |
download | dexon-solidity-88c7975ca5fc46fd6c0ea5cc0267d55f2fe97ff8.tar dexon-solidity-88c7975ca5fc46fd6c0ea5cc0267d55f2fe97ff8.tar.gz dexon-solidity-88c7975ca5fc46fd6c0ea5cc0267d55f2fe97ff8.tar.bz2 dexon-solidity-88c7975ca5fc46fd6c0ea5cc0267d55f2fe97ff8.tar.lz dexon-solidity-88c7975ca5fc46fd6c0ea5cc0267d55f2fe97ff8.tar.xz dexon-solidity-88c7975ca5fc46fd6c0ea5cc0267d55f2fe97ff8.tar.zst dexon-solidity-88c7975ca5fc46fd6c0ea5cc0267d55f2fe97ff8.zip |
Move functions to the top.
Diffstat (limited to 'test')
-rwxr-xr-x | test/cmdlineTests.sh | 86 |
1 files changed, 47 insertions, 39 deletions
diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh index fc84d8a0..40b49daf 100755 --- a/test/cmdlineTests.sh +++ b/test/cmdlineTests.sh @@ -28,14 +28,14 @@ set -e +## GLOBAL VARIABLES + REPO_ROOT=$(cd $(dirname "$0")/.. && pwd) -echo $REPO_ROOT SOLC="$REPO_ROOT/build/solc/solc" FULLARGS="--optimize --ignore-missing --combined-json abi,asm,ast,bin,bin-runtime,compact-format,devdoc,hashes,interface,metadata,opcodes,srcmap,srcmap-runtime,userdoc" -echo "Checking that the bug list is up to date..." -"$REPO_ROOT"/scripts/update_bugs_by_version.py +## FUNCTIONS if [ "$CIRCLECI" ] then @@ -93,22 +93,6 @@ function compileFull() fi } -printTask "Testing unknown options..." -( - set +e - output=$("$SOLC" --allow=test 2>&1) - failed=$? - set -e - - if [ "$output" == "unrecognised option '--allow=test'" ] && [ $failed -ne 0 ] - then - echo "Passed" - else - printError "Incorrect response to unknown options: $STDERR" - exit 1 - fi -) - # General helper function for testing SOLC behaviour, based on file name, compile opts, exit code, stdout and stderr. # An failure is expected. function test_solc_behaviour() @@ -174,6 +158,49 @@ function test_solc_behaviour() rm -f $stdout_path $stderr_path } + +function test_solc_assembly_output() +{ + local input="${1}" + local expected="${2}" + local solc_args="${3}" + + local expected_object="object \"object\" { code "${expected}" }" + + output=$(echo "${input}" | "$SOLC" - ${solc_args} 2>/dev/null) + empty=$(echo $output | sed -ne '/'"${expected_object}"'/p') + if [ -z "$empty" ] + then + printError "Incorrect assembly output. Expected: " + echo -e ${expected} + printError "with arguments ${solc_args}, but got:" + echo "${output}" + exit 1 + fi +} + +## RUN + +echo "Checking that the bug list is up to date..." +"$REPO_ROOT"/scripts/update_bugs_by_version.py + +printTask "Testing unknown options..." +( + set +e + output=$("$SOLC" --allow=test 2>&1) + failed=$? + set -e + + if [ "$output" == "unrecognised option '--allow=test'" ] && [ $failed -ne 0 ] + then + echo "Passed" + else + printError "Incorrect response to unknown options: $STDERR" + exit 1 + fi +) + + printTask "Testing passing files that are not found..." test_solc_behaviour "file_not_found.sol" "" "" "" 1 "\"file_not_found.sol\" is not found." @@ -297,26 +324,6 @@ SOLTMPDIR=$(mktemp -d) ) rm -rf "$SOLTMPDIR" -function test_solc_assembly_output() -{ - local input="${1}" - local expected="${2}" - local solc_args="${3}" - - local expected_object="object \"object\" { code "${expected}" }" - - output=$(echo "${input}" | "$SOLC" - ${solc_args} 2>/dev/null) - empty=$(echo $output | sed -ne '/'"${expected_object}"'/p') - if [ -z "$empty" ] - then - printError "Incorrect assembly output. Expected: " - echo -e ${expected} - printError "with arguments ${solc_args}, but got:" - echo "${output}" - exit 1 - fi -} - printTask "Testing assemble, yul, strict-assembly and optimize..." ( echo '{}' | "$SOLC" - --assemble &>/dev/null @@ -405,4 +412,5 @@ SOLTMPDIR=$(mktemp -d) done ) rm -rf "$SOLTMPDIR" + echo "Commandline tests successful." |