solidity/scripts/tests.sh

142 lines
3.4 KiB
Bash
Raw Normal View History

Make the Solidity repository standalone. This commit is the culmination of several months of work to decouple Solidity from the webthree-umbrella so that it can be developed in parallel with cpp-ethereum (the Ethereum C++ runtime) and so that even for the Solidity unit-tests there is no hard-dependency onto the C++ runtime. The Tests-over-IPC refactoring was a major step in the same process which was already committed. This commit contains the following changes: - A subset of the CMake functionality in webthree-helpers was extracted and tailored for Solidity into ./cmake. Further cleanup is certainly possible. - A subset of the libdevcore functionality in libweb3core was extracted and tailored for Solidity into ./libdevcore. Further cleanup is certainly possible - The gas price constants in EVMSchedule were orphaned into libevmasm. - Some other refactorings and cleanups were made to sever unnecessary EVM dependencies in the Solidity unit-tests. - TravisCI and Appveyor support was added, covering builds and running of the unit-tests (Linux and macOS only for now) - A bug-fix was made to get the Tests-over-IPC running on macOS. - There are still reliability issues in the unit-tests, which need immediate attention. The Travis build has been flipped to run the unit-tests 5 times, to try to flush these out. - The Emscripten automation which was previously in webthree-umbrella was merged into the TravisCI automation here. - The development ZIP deployment step has been commented out, but we will want to read that ONLY for release branch. Further iteration on these changes will definitely be needed, but I feel these have got to sufficient maturity than holding them back further isn't winning us anything. It is go time :-)
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
REPO_ROOT="$(dirname "$0")/.."
source "${REPO_ROOT}/scripts/common.sh"
2016-11-02 11:32:55 +00:00
WORKDIR=`mktemp -d`
CMDLINE_PID=
if [[ "$OSTYPE" == "darwin"* ]]
then
SMT_FLAGS="--no-smt"
fi
cleanup() {
2019-04-03 08:59:22 +00:00
# ensure failing commands don't cause termination during cleanup (especially within safe_kill)
set +e
if [[ -n "$CMDLINE_PID" ]]
then
safe_kill $CMDLINE_PID "Commandline tests"
fi
echo "Cleaning up working directory ${WORKDIR} ..."
rm -rf "$WORKDIR" || true
}
trap cleanup INT TERM
2018-02-13 10:54:22 +00:00
if [ "$1" = --junit_report ]
then
if [ -z "$2" ]
then
echo "Usage: $0 [--junit_report <report_directory>]"
exit 1
fi
2018-02-22 16:21:26 +00:00
log_directory="$2"
2018-02-13 10:54:22 +00:00
else
2018-02-22 16:21:26 +00:00
log_directory=""
2018-02-13 10:54:22 +00:00
fi
2018-04-17 06:53:21 +00:00
printTask "Running commandline tests..."
2018-02-26 19:41:18 +00:00
# Only run in parallel if this is run on CI infrastructure
if [[ -n "$CI" ]]
2018-02-26 19:41:18 +00:00
then
"$REPO_ROOT/test/cmdlineTests.sh" &
CMDLINE_PID=$!
else
if ! $REPO_ROOT/test/cmdlineTests.sh
2018-04-17 06:53:21 +00:00
then
printError "Commandline tests FAILED"
exit 1
fi
2018-02-26 19:41:18 +00:00
fi
2017-07-05 10:28:15 +00:00
2018-02-26 19:41:18 +00:00
2018-04-06 10:20:01 +00:00
EVM_VERSIONS="homestead byzantium"
if [ -z "$CI" ]
2018-04-06 10:20:01 +00:00
then
EVM_VERSIONS+=" constantinople petersburg"
2018-04-06 10:20:01 +00:00
fi
2018-02-22 16:21:26 +00:00
# And then run the Solidity unit-tests in the matrix combination of optimizer / no optimizer
2019-07-17 09:05:44 +00:00
# and homestead / byzantium VM
2018-02-22 16:21:26 +00:00
for optimize in "" "--optimize"
do
2018-04-06 10:20:01 +00:00
for vm in $EVM_VERSIONS
2018-02-22 16:21:26 +00:00
do
FORCE_ABIV2_RUNS="no"
if [[ "$vm" == "constantinople" ]]
2018-02-22 16:21:26 +00:00
then
FORCE_ABIV2_RUNS="no yes" # run both in constantinople
2018-02-22 16:21:26 +00:00
fi
for abiv2 in $FORCE_ABIV2_RUNS
do
force_abiv2_flag=""
if [[ "$abiv2" == "yes" ]]
then
force_abiv2_flag="--abiencoderv2 --optimize-yul"
fi
printTask "--> Running tests using "$optimize" --evm-version "$vm" $force_abiv2_flag..."
log=""
if [ -n "$log_directory" ]
then
if [ -n "$optimize" ]
then
log=--logger=JUNIT,error,$log_directory/opt_$vm.xml $testargs
else
log=--logger=JUNIT,error,$log_directory/noopt_$vm.xml $testargs_no_opt
fi
fi
2019-04-02 09:07:00 +00:00
set +e
2019-07-17 09:05:44 +00:00
"$REPO_ROOT"/build/test/soltest --show-progress $log -- --testpath "$REPO_ROOT"/test "$optimize" --evm-version "$vm" $SMT_FLAGS $force_abiv2_flag
2019-04-02 09:07:00 +00:00
if test "0" -ne "$?"; then
exit 1
fi
set -e
done
2018-02-22 16:21:26 +00:00
done
done
2018-02-26 19:41:18 +00:00
if [[ -n $CMDLINE_PID ]] && ! wait $CMDLINE_PID
2018-04-17 06:53:21 +00:00
then
printError "Commandline tests FAILED"
CMDLINE_PID=
2018-04-17 06:53:21 +00:00
exit 1
fi
2018-02-26 19:41:18 +00:00
cleanup