2016-08-01 05:25:37 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Bash script to execute the Solidity tests.
|
|
|
|
#
|
|
|
|
# The documentation for solidity is hosted at:
|
|
|
|
#
|
|
|
|
# https://solidity.readthedocs.org
|
|
|
|
#
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# This file is part of solidity.
|
|
|
|
#
|
|
|
|
# solidity is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# solidity is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with solidity. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
#
|
|
|
|
# (c) 2016 solidity contributors.
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
2016-08-01 13:33:01 +00:00
|
|
|
set -e
|
|
|
|
|
2016-11-02 11:32:55 +00:00
|
|
|
REPO_ROOT="$(dirname "$0")"/..
|
|
|
|
|
2017-01-24 22:36:35 +00:00
|
|
|
echo "Running commandline tests..."
|
|
|
|
"$REPO_ROOT/test/cmdlineTests.sh"
|
2016-08-01 05:25:37 +00:00
|
|
|
|
2017-01-20 18:48:53 +00:00
|
|
|
echo "Checking that StandardToken.sol, owned.sol and mortal.sol produce bytecode..."
|
|
|
|
output=$("$REPO_ROOT"/build/solc/solc --bin "$REPO_ROOT"/std/*.sol 2>/dev/null | grep "ffff" | wc -l)
|
2017-02-07 17:40:26 +00:00
|
|
|
test "${output//[[:blank:]]/}" = "3"
|
2017-01-20 18:48:53 +00:00
|
|
|
|
2016-08-01 05:25:37 +00:00
|
|
|
# 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"
|
|
|
|
else
|
|
|
|
ETH_PATH="eth"
|
|
|
|
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 &
|
|
|
|
|
|
|
|
# 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
|
2016-11-23 14:14:25 +00:00
|
|
|
echo "--> IPC available."
|
2017-02-03 00:53:42 +00:00
|
|
|
sleep 2
|
2016-11-23 14:14:25 +00:00
|
|
|
# And then run the Solidity unit-tests (once without optimization, once with),
|
|
|
|
# pointing to that IPC endpoint.
|
|
|
|
echo "--> Running tests without optimizer..."
|
2017-02-08 21:19:05 +00:00
|
|
|
"$REPO_ROOT"/build/test/soltest --show-progress -- --ipcpath /tmp/test/geth.ipc && \
|
2016-11-23 14:14:25 +00:00
|
|
|
echo "--> Running tests WITH optimizer..." && \
|
2017-02-08 21:19:05 +00:00
|
|
|
"$REPO_ROOT"/build/test/soltest --show-progress -- --optimize --ipcpath /tmp/test/geth.ipc
|
2016-08-01 05:25:37 +00:00
|
|
|
ERROR_CODE=$?
|
2016-08-01 13:33:01 +00:00
|
|
|
pkill eth || true
|
|
|
|
sleep 4
|
|
|
|
pgrep eth && pkill -9 eth || true
|
2017-02-03 00:53:42 +00:00
|
|
|
exit $ERROR_CODE
|