aboutsummaryrefslogtreecommitdiffstats
path: root/test/cmdlineTests.sh
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2019-01-07 21:47:53 +0800
committerGitHub <noreply@github.com>2019-01-07 21:47:53 +0800
commit633228f1a74f9509af17ead951b0841fbffa12d3 (patch)
tree9e7a1c60710e0ed101b904dd93b2999fd3aefcad /test/cmdlineTests.sh
parentb06e84501b63cbc0e78fb7565b1029fcae1e4474 (diff)
parent88c7975ca5fc46fd6c0ea5cc0267d55f2fe97ff8 (diff)
downloaddexon-solidity-633228f1a74f9509af17ead951b0841fbffa12d3.tar.gz
dexon-solidity-633228f1a74f9509af17ead951b0841fbffa12d3.tar.zst
dexon-solidity-633228f1a74f9509af17ead951b0841fbffa12d3.zip
Merge pull request #5710 from ethereum/moveTests
[REF][cmdlinetests] Move functions to the top
Diffstat (limited to 'test/cmdlineTests.sh')
-rwxr-xr-xtest/cmdlineTests.sh86
1 files changed, 47 insertions, 39 deletions
diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh
index 00cc3633..3beee552 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()
@@ -178,6 +162,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."
@@ -301,26 +328,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
@@ -409,4 +416,5 @@ SOLTMPDIR=$(mktemp -d)
done
)
rm -rf "$SOLTMPDIR"
+
echo "Commandline tests successful."