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:
|
|
|
|
#
|
2020-11-18 14:20:34 +00:00
|
|
|
# https://docs.soliditylang.org
|
2016-08-01 05:25:37 +00:00
|
|
|
#
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# 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
|
|
|
|
|
2019-04-26 09:57:49 +00:00
|
|
|
REPO_ROOT="$(dirname "$0")/.."
|
2020-04-17 13:02:40 +00:00
|
|
|
SOLIDITY_BUILD_DIR="${SOLIDITY_BUILD_DIR:-${REPO_ROOT}/build}"
|
2020-12-11 20:34:55 +00:00
|
|
|
IFS=" " read -r -a SMT_FLAGS <<< "$SMT_FLAGS"
|
2019-04-26 09:57:49 +00:00
|
|
|
|
2020-12-12 00:46:21 +00:00
|
|
|
# shellcheck source=scripts/common.sh
|
2019-04-26 09:57:49 +00:00
|
|
|
source "${REPO_ROOT}/scripts/common.sh"
|
2016-11-02 11:32:55 +00:00
|
|
|
|
2020-12-11 17:47:51 +00:00
|
|
|
WORKDIR=$(mktemp -d)
|
2018-07-27 08:32:04 +00:00
|
|
|
CMDLINE_PID=
|
|
|
|
|
2021-10-28 09:58:47 +00:00
|
|
|
function cleanup
|
|
|
|
{
|
2019-04-03 08:59:22 +00:00
|
|
|
# ensure failing commands don't cause termination during cleanup (especially within safe_kill)
|
|
|
|
set +e
|
2018-07-27 08:32:04 +00:00
|
|
|
|
|
|
|
if [[ -n "$CMDLINE_PID" ]]
|
|
|
|
then
|
2020-12-11 17:19:53 +00:00
|
|
|
safe_kill "$CMDLINE_PID" "Commandline tests"
|
2018-07-27 08:32:04 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Cleaning up working directory ${WORKDIR} ..."
|
|
|
|
rm -rf "$WORKDIR" || true
|
|
|
|
}
|
|
|
|
trap cleanup INT TERM
|
|
|
|
|
2021-09-10 19:05:17 +00:00
|
|
|
log_directory=""
|
|
|
|
no_smt=""
|
|
|
|
while [[ $# -gt 0 ]]
|
|
|
|
do
|
|
|
|
case "$1" in
|
|
|
|
--junit_report)
|
|
|
|
if [ -z "$2" ]
|
|
|
|
then
|
|
|
|
echo "Usage: $0 [--junit_report <report_directory>] [--no-smt]"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
log_directory="$2"
|
|
|
|
fi
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--no-smt)
|
|
|
|
no_smt="--no-smt"
|
|
|
|
SMT_FLAGS+=(--no-smt)
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: $0 [--junit_report <report_directory>] [--no-smt]"
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
done
|
2018-02-13 10:54:22 +00:00
|
|
|
|
2021-01-21 10:29:15 +00:00
|
|
|
printTask "Testing Python scripts..."
|
|
|
|
"$REPO_ROOT/test/pyscriptTests.py"
|
|
|
|
|
2021-12-13 13:53:40 +00:00
|
|
|
printTask "Testing LSP..."
|
2022-03-15 17:52:59 +00:00
|
|
|
"$REPO_ROOT/test/lsp.py" "${SOLIDITY_BUILD_DIR}/solc/solc"
|
2021-12-13 13:53:40 +00:00
|
|
|
|
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
|
2018-07-27 08:32:04 +00:00
|
|
|
if [[ -n "$CI" ]]
|
2018-02-26 19:41:18 +00:00
|
|
|
then
|
2018-07-27 08:32:04 +00:00
|
|
|
"$REPO_ROOT/test/cmdlineTests.sh" &
|
|
|
|
CMDLINE_PID=$!
|
|
|
|
else
|
2021-09-10 19:05:17 +00:00
|
|
|
if ! "$REPO_ROOT/test/cmdlineTests.sh" "$no_smt"
|
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"
|
|
|
|
|
2019-04-26 09:57:49 +00:00
|
|
|
if [ -z "$CI" ]
|
2018-04-06 10:20:01 +00:00
|
|
|
then
|
2022-11-09 11:12:18 +00:00
|
|
|
EVM_VERSIONS+=" constantinople petersburg istanbul berlin london paris"
|
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
|
2020-04-17 12:32:38 +00:00
|
|
|
for vm in $EVM_VERSIONS
|
2018-09-26 17:09:10 +00:00
|
|
|
do
|
2020-11-19 15:58:41 +00:00
|
|
|
FORCE_ABIV1_RUNS="no"
|
2023-01-18 16:34:48 +00:00
|
|
|
if [[ "$vm" == "paris" ]]
|
2018-09-26 17:09:10 +00:00
|
|
|
then
|
2023-01-18 16:34:48 +00:00
|
|
|
FORCE_ABIV1_RUNS="no yes" # run both in paris
|
2018-09-26 17:09:10 +00:00
|
|
|
fi
|
2020-11-19 15:58:41 +00:00
|
|
|
for abiv1 in $FORCE_ABIV1_RUNS
|
2020-04-17 12:32:38 +00:00
|
|
|
do
|
2020-12-11 20:34:55 +00:00
|
|
|
force_abiv1_flag=()
|
2020-11-19 15:58:41 +00:00
|
|
|
if [[ "$abiv1" == "yes" ]]
|
2020-04-17 12:32:38 +00:00
|
|
|
then
|
2020-12-11 20:34:55 +00:00
|
|
|
force_abiv1_flag=(--abiencoderv1)
|
2020-04-17 12:32:38 +00:00
|
|
|
fi
|
2020-12-11 20:34:55 +00:00
|
|
|
printTask "--> Running tests using $optimize --evm-version $vm ${force_abiv1_flag[*]}..."
|
2020-04-17 12:32:38 +00:00
|
|
|
|
2020-12-11 20:34:55 +00:00
|
|
|
log=()
|
2020-04-17 12:32:38 +00:00
|
|
|
if [ -n "$log_directory" ]
|
|
|
|
then
|
|
|
|
if [ -n "$optimize" ]
|
|
|
|
then
|
2020-12-11 20:34:55 +00:00
|
|
|
log+=("--logger=JUNIT,error,$log_directory/opt_$vm.xml")
|
2020-04-17 12:32:38 +00:00
|
|
|
else
|
2020-12-11 20:34:55 +00:00
|
|
|
log+=("--logger=JUNIT,error,$log_directory/noopt_$vm.xml")
|
2020-04-17 12:32:38 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
set +e
|
2023-01-12 08:08:39 +00:00
|
|
|
"${SOLIDITY_BUILD_DIR}"/test/soltest --show-progress "${log[@]}" -- --testpath "$REPO_ROOT"/test "$optimize" --evm-version "$vm" "${SMT_FLAGS[@]}" "${force_abiv1_flag[@]}"
|
2020-04-17 12:32:38 +00:00
|
|
|
|
|
|
|
if test "0" -ne "$?"; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
set -e
|
|
|
|
|
|
|
|
done
|
2018-09-26 17:09:10 +00:00
|
|
|
done
|
2018-02-22 16:21:26 +00:00
|
|
|
done
|
2018-02-26 19:41:18 +00:00
|
|
|
|
2018-07-27 08:32:04 +00:00
|
|
|
if [[ -n $CMDLINE_PID ]] && ! wait $CMDLINE_PID
|
2018-04-17 06:53:21 +00:00
|
|
|
then
|
|
|
|
printError "Commandline tests FAILED"
|
2018-07-27 08:32:04 +00:00
|
|
|
CMDLINE_PID=
|
2018-04-17 06:53:21 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2018-02-26 19:41:18 +00:00
|
|
|
|
2018-07-27 08:32:04 +00:00
|
|
|
cleanup
|