diff options
author | chriseth <chris@ethereum.org> | 2018-03-08 03:20:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-08 03:20:57 +0800 |
commit | dfe3193c7382c80f1814247a162663a97c3f5e67 (patch) | |
tree | d0540c2dfc43a76f0add46840f60ff2e28604a19 /scripts/tests.sh | |
parent | 3155dd8058672ce8f04bc2c0f2536cb549067d0a (diff) | |
parent | 15920dc75dd5a46a036d5ff16fb8eee0534be6e1 (diff) | |
download | dexon-solidity-dfe3193c7382c80f1814247a162663a97c3f5e67.tar dexon-solidity-dfe3193c7382c80f1814247a162663a97c3f5e67.tar.gz dexon-solidity-dfe3193c7382c80f1814247a162663a97c3f5e67.tar.bz2 dexon-solidity-dfe3193c7382c80f1814247a162663a97c3f5e67.tar.lz dexon-solidity-dfe3193c7382c80f1814247a162663a97c3f5e67.tar.xz dexon-solidity-dfe3193c7382c80f1814247a162663a97c3f5e67.tar.zst dexon-solidity-dfe3193c7382c80f1814247a162663a97c3f5e67.zip |
Merge pull request #3678 from ethereum/develop
Merge develop into release.
Diffstat (limited to 'scripts/tests.sh')
-rwxr-xr-x | scripts/tests.sh | 125 |
1 files changed, 87 insertions, 38 deletions
diff --git a/scripts/tests.sh b/scripts/tests.sh index 2b47c254..bf4ee3d9 100755 --- a/scripts/tests.sh +++ b/scripts/tests.sh @@ -30,49 +30,98 @@ set -e REPO_ROOT="$(dirname "$0")"/.. +if [ "$1" = --junit_report ] +then + if [ -z "$2" ] + then + echo "Usage: $0 [--junit_report <report_directory>]" + exit 1 + fi + log_directory="$2" +else + log_directory="" +fi + echo "Running commandline tests..." -"$REPO_ROOT/test/cmdlineTests.sh" +"$REPO_ROOT/test/cmdlineTests.sh" & +CMDLINE_PID=$! +# Only run in parallel if this is run on CI infrastructure +if [ -z "$CI" ] +then + wait $CMDLINE_PID +fi -# This conditional is only needed because we don't have a working Homebrew -# install for `eth` at the time of writing, so we unzip the ZIP file locally -# instead. This will go away soon. -if [[ "$OSTYPE" == "darwin"* ]]; then - ETH_PATH="$REPO_ROOT/eth" -elif [ -z $CI ]; then - ETH_PATH="eth" -else - mkdir -p /tmp/test - # Update hash below if binary is changed. - wget -q -O /tmp/test/eth https://github.com/ethereum/cpp-ethereum/releases/download/solidityTester/eth_byzantium2 - test "$(shasum /tmp/test/eth)" = "4dc3f208475f622be7c8e53bee720e14cd254c6f /tmp/test/eth" - sync - chmod +x /tmp/test/eth - sync # Otherwise we might get a "text file busy" error - ETH_PATH="/tmp/test/eth" +function download_eth() +{ + if [[ "$OSTYPE" == "darwin"* ]]; then + ETH_PATH="$REPO_ROOT/eth" + elif [ -z $CI ]; then + ETH_PATH="eth" + else + mkdir -p /tmp/test + if grep -i trusty /etc/lsb-release >/dev/null 2>&1 + then + # built from 1ecff3cac12f0fbbeea3e645f331d5ac026b24d3 at 2018-03-06 + ETH_BINARY=eth_byzantium_trusty + ETH_HASH="5432ea81c150e8a3547615bf597cd6dce9e1e27b" + else + # built from ?? at 2018-02-13 ? + ETH_BINARY=eth_byzantium_artful + ETH_HASH="e527dd3e3dc17b983529dd7dcfb74a0d3a5aed4e" + fi + wget -q -O /tmp/test/eth https://github.com/ethereum/cpp-ethereum/releases/download/solidityTester/$ETH_BINARY + test "$(shasum /tmp/test/eth)" = "$ETH_HASH /tmp/test/eth" + sync + chmod +x /tmp/test/eth + sync # Otherwise we might get a "text file busy" error + ETH_PATH="/tmp/test/eth" + fi + +} + +# $1: data directory +# echos the PID +function run_eth() +{ + $ETH_PATH --test -d "$1" >/dev/null 2>&1 & + echo $! + # Wait until the IPC endpoint is available. + while [ ! -S "$1"/geth.ipc ] ; do sleep 1; done + sleep 2 +} + +download_eth +ETH_PID=$(run_eth /tmp/test) + +progress="--show-progress" +if [ "$CI" ] +then + progress="" fi -# This trailing ampersand directs the shell to run the command in the background, -# that is, it is forked and run in a separate sub-shell, as a job, -# asynchronously. The shell will immediately return the return status of 0 for -# true and continue as normal, either processing further commands in a script -# or returning the cursor focus back to the user in a Linux terminal. -$ETH_PATH --test -d /tmp/test & -ETH_PID=$! +# And then run the Solidity unit-tests in the matrix combination of optimizer / no optimizer +# and homestead / byzantium VM, # pointing to that IPC endpoint. +for optimize in "" "--optimize" +do + for vm in homestead byzantium + do + echo "--> Running tests using "$optimize" --evm-version "$vm"..." + log="" + if [ -n "$log_directory" ] + then + if [ -n "$optimize" ] + then + log=--logger=JUNIT,test_suite,$log_directory/opt_$vm.xml $testargs + else + log=--logger=JUNIT,test_suite,$log_directory/noopt_$vm.xml $testargs_no_opt + fi + fi + "$REPO_ROOT"/build/test/soltest $progress $log -- "$optimize" --evm-version "$vm" --ipcpath /tmp/test/geth.ipc + done +done + +wait $CMDLINE_PID -# Wait until the IPC endpoint is available. That won't be available instantly. -# The node needs to get a little way into its startup sequence before the IPC -# is available and is ready for the unit-tests to start talking to it. -while [ ! -S /tmp/test/geth.ipc ]; do sleep 2; done -echo "--> IPC available." -sleep 2 -# And then run the Solidity unit-tests (once without optimization, once with), -# pointing to that IPC endpoint. -echo "--> Running tests without optimizer..." - "$REPO_ROOT"/build/test/soltest --show-progress -- --ipcpath /tmp/test/geth.ipc && \ - echo "--> Running tests WITH optimizer..." && \ - "$REPO_ROOT"/build/test/soltest --show-progress -- --optimize --ipcpath /tmp/test/geth.ipc -ERROR_CODE=$? pkill "$ETH_PID" || true sleep 4 pgrep "$ETH_PID" && pkill -9 "$ETH_PID" || true -exit $ERROR_CODE |