Run tests in parallel on circle.

This commit is contained in:
chriseth 2018-02-26 20:41:18 +01:00
parent b9dccf9f20
commit 6a83beaab5
2 changed files with 58 additions and 46 deletions

View File

@ -45,11 +45,16 @@ else
fi fi
echo "Running commandline tests..." 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 function download_eth()
# 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 if [[ "$OSTYPE" == "darwin"* ]]; then
ETH_PATH="$REPO_ROOT/eth" ETH_PATH="$REPO_ROOT/eth"
elif [ -z $CI ]; then elif [ -z $CI ]; then
@ -71,28 +76,35 @@ else
ETH_PATH="/tmp/test/eth" ETH_PATH="/tmp/test/eth"
fi 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=$!
# Wait until the IPC endpoint is available. That won't be available instantly. # $1: data directory
# The node needs to get a little way into its startup sequence before the IPC # echos the PID
# is available and is ready for the unit-tests to start talking to it. function run_eth()
while [ ! -S /tmp/test/geth.ipc ]; do sleep 2; done {
echo "--> IPC available." $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 sleep 2
# And then run the Solidity unit-tests (once without optimization, once with), }
# pointing to that IPC endpoint.
download_eth
ETH_PID=$(run_eth /tmp/test)
progress="--show-progress"
if [ "$CI" ]
then
progress=""
fi
echo "--> Running tests without optimizer..." echo "--> Running tests without optimizer..."
"$REPO_ROOT"/build/test/soltest --show-progress $testargs_no_opt -- --ipcpath /tmp/test/geth.ipc && \ "$REPO_ROOT"/build/test/soltest $testargs_no_opt $progress -- --ipcpath /tmp/test/geth.ipc
echo "--> Running tests WITH optimizer..." && \ echo "--> Running tests WITH optimizer..."
"$REPO_ROOT"/build/test/soltest --show-progress $testargs_opt -- --optimize --ipcpath /tmp/test/geth.ipc "$REPO_ROOT"/build/test/soltest $testargs_opt $progress -- --optimize --ipcpath /tmp/test/geth.ipc
ERROR_CODE=$?
wait $CMDLINE_PID
pkill "$ETH_PID" || true pkill "$ETH_PID" || true
sleep 4 sleep 4
pgrep "$ETH_PID" && pkill -9 "$ETH_PID" || true pgrep "$ETH_PID" && pkill -9 "$ETH_PID" || true
exit $ERROR_CODE

View File

@ -172,4 +172,4 @@ TMPDIR=$(mktemp -d)
done done
) )
rm -rf "$TMPDIR" rm -rf "$TMPDIR"
echo "Done." echo "Commandline tests successful."