Merge pull request #10464 from ethereum/enable-shellcheck-for-external-test-scripts

Enable shellcheck for external test scripts
This commit is contained in:
Kamil Śliwak 2020-12-04 18:56:09 +01:00 committed by GitHub
commit 3619a0a0f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 46 additions and 48 deletions

View File

@ -1,12 +1,5 @@
./test/docsCodeStyle.sh ./test/docsCodeStyle.sh
./test/cmdlineTests.sh ./test/cmdlineTests.sh
./test/externalTests.sh
./test/externalTests/common.sh
./test/externalTests/gnosis.sh
./test/externalTests/zeppelin.sh
./test/externalTests/colony.sh
./test/externalTests/solc-js/solc-js.sh
./scripts/common.sh
./scripts/isoltest.sh ./scripts/isoltest.sh
./scripts/get_version.sh ./scripts/get_version.sh
./scripts/soltest.sh ./scripts/soltest.sh

View File

@ -1,3 +1,4 @@
#!/usr/bin/env bash
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# vim:ts=4:et # vim:ts=4:et
# This file is part of solidity. # This file is part of solidity.
@ -37,21 +38,21 @@ safe_kill()
local n=1 local n=1
# only proceed if $PID does exist # only proceed if $PID does exist
kill -0 $PID 2>/dev/null || return kill -0 "$PID" 2>/dev/null || return
echo "Sending SIGTERM to ${NAME} (${PID}) ..." echo "Sending SIGTERM to ${NAME} (${PID}) ..."
kill $PID kill "$PID"
# wait until process terminated gracefully # wait until process terminated gracefully
while kill -0 $PID 2>/dev/null && [[ $n -le 4 ]]; do while kill -0 "$PID" 2>/dev/null && [[ $n -le 4 ]]; do
echo "Waiting ($n) ..." echo "Waiting ($n) ..."
sleep 1 sleep 1
n=$[n + 1] n=$((n + 1))
done done
# process still alive? then hard-kill # process still alive? then hard-kill
if kill -0 $PID 2>/dev/null; then if kill -0 "$PID" 2>/dev/null; then
echo "Sending SIGKILL to ${NAME} (${PID}) ..." echo "Sending SIGKILL to ${NAME} (${PID}) ..."
kill -9 $PID kill -9 "$PID"
fi fi
} }

View File

@ -42,10 +42,10 @@ source test/externalTests/common.sh
printTask "Running external tests..." printTask "Running external tests..."
$REPO_ROOT/externalTests/zeppelin.sh "$SOLJSON" "$REPO_ROOT/externalTests/zeppelin.sh" "$SOLJSON"
$REPO_ROOT/externalTests/gnosis.sh "$SOLJSON" "$REPO_ROOT/externalTests/gnosis.sh" "$SOLJSON"
$REPO_ROOT/externalTests/colony.sh "$SOLJSON" "$REPO_ROOT/externalTests/colony.sh" "$SOLJSON"
$REPO_ROOT/externalTests/ens.sh "$SOLJSON" "$REPO_ROOT/externalTests/ens.sh" "$SOLJSON"
# Disabled temporarily as it needs to be updated to latest Truffle first. # Disabled temporarily as it needs to be updated to latest Truffle first.
#test_truffle Gnosis https://github.com/axic/pm-contracts.git solidity-050 #test_truffle Gnosis https://github.com/axic/pm-contracts.git solidity-050

View File

@ -31,18 +31,17 @@ function test_fn { yarn run test:contracts; }
function colony_test function colony_test
{ {
OPTIMIZER_LEVEL=3 OPTIMIZER_LEVEL=3
FORCE_ABIv2=false
CONFIG="truffle.js" CONFIG="truffle.js"
truffle_setup https://github.com/solidity-external-tests/colonyNetwork.git develop_070 truffle_setup "$SOLJSON" https://github.com/solidity-external-tests/colonyNetwork.git develop_070
run_install install_fn run_install "$SOLJSON" install_fn
cd lib cd lib
rm -Rf dappsys rm -Rf dappsys
git clone https://github.com/solidity-external-tests/dappsys-monolithic.git -b master_060 dappsys git clone https://github.com/solidity-external-tests/dappsys-monolithic.git -b master_060 dappsys
cd .. cd ..
truffle_run_test compile_fn test_fn truffle_run_test "$SOLJSON" compile_fn test_fn "NO-FORCE-ABI-V2"
} }
external_test ColonyNetworks colony_test external_test ColonyNetworks colony_test

View File

@ -40,9 +40,10 @@ function verify_version_input
function setup function setup
{ {
local branch="$1" local soljson="$1"
local branch="$2"
setup_solcjs "$DIR" "$SOLJSON" "$branch" "solc" setup_solcjs "$DIR" "$soljson" "$branch" "solc"
cd solc cd solc
} }
@ -80,7 +81,7 @@ function download_project
printLog "Cloning $branch of $repo..." printLog "Cloning $branch of $repo..."
git clone --depth 1 "$repo" -b "$branch" "$dir/ext" git clone --depth 1 "$repo" -b "$branch" "$dir/ext"
cd ext cd ext
echo "Current commit hash: `git rev-parse HEAD`" echo "Current commit hash: $(git rev-parse HEAD)"
} }
function force_truffle_version function force_truffle_version
@ -92,10 +93,11 @@ function force_truffle_version
function truffle_setup function truffle_setup
{ {
local repo="$1" local soljson="$1"
local branch="$2" local repo="$2"
local branch="$3"
setup_solcjs "$DIR" "$SOLJSON" "master" "solc" setup_solcjs "$DIR" "$soljson" "master" "solc"
download_project "$repo" "$branch" "$DIR" download_project "$repo" "$branch" "$DIR"
} }
@ -207,11 +209,12 @@ function clean
function run_install function run_install
{ {
local init_fn="$1" local soljson="$1"
local init_fn="$2"
printLog "Running install function..." printLog "Running install function..."
replace_version_pragmas replace_version_pragmas
force_solc "$CONFIG" "$DIR" "$SOLJSON" force_solc "$CONFIG" "$DIR" "$soljson"
$init_fn $init_fn
} }
@ -232,11 +235,15 @@ function run_test
function truffle_run_test function truffle_run_test
{ {
local compile_fn="$1" local soljson="$1"
local test_fn="$2" local compile_fn="$2"
local test_fn="$3"
local force_abi_v2_flag="$4"
test "$force_abi_v2_flag" = "FORCE-ABI-V2" || test "$force_abi_v2_flag" = "NO-FORCE-ABI-V2"
replace_version_pragmas replace_version_pragmas
force_solc "$CONFIG" "$DIR" "$SOLJSON" force_solc "$CONFIG" "$DIR" "$soljson"
printLog "Checking optimizer level..." printLog "Checking optimizer level..."
if [ -z "$OPTIMIZER_LEVEL" ]; then if [ -z "$OPTIMIZER_LEVEL" ]; then
@ -258,7 +265,7 @@ function truffle_run_test
clean clean
force_solc_settings "$CONFIG" "$optimize" "istanbul" force_solc_settings "$CONFIG" "$optimize" "istanbul"
# Force abi coder v2 in the last step. Has to be the last because code is modified. # Force abi coder v2 in the last step. Has to be the last because code is modified.
if [ "$FORCE_ABIv2" = true ]; then if [ "$force_abi_v2_flag" = "FORCE-ABI-V2" ]; then
[[ "$optimize" =~ yul ]] && force_abi_v2 [[ "$optimize" =~ yul ]] && force_abi_v2
fi fi

View File

@ -18,9 +18,7 @@
# #
# (c) 2019 solidity contributors. # (c) 2019 solidity contributors.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# shellcheck disable=SC1091
source scripts/common.sh source scripts/common.sh
# shellcheck disable=SC1091
source test/externalTests/common.sh source test/externalTests/common.sh
verify_input "$1" verify_input "$1"
@ -35,14 +33,14 @@ function ens_test
export OPTIMIZER_LEVEL=1 export OPTIMIZER_LEVEL=1
export CONFIG="truffle-config.js" export CONFIG="truffle-config.js"
truffle_setup https://github.com/solidity-external-tests/ens.git upgrade-0.8.0 truffle_setup "$SOLJSON" https://github.com/solidity-external-tests/ens.git upgrade-0.8.0
# Use latest Truffle. Older versions crash on the output from 0.8.0. # Use latest Truffle. Older versions crash on the output from 0.8.0.
force_truffle_version ^5.1.55 force_truffle_version ^5.1.55
run_install install_fn run_install "$SOLJSON" install_fn
truffle_run_test compile_fn test_fn truffle_run_test "$SOLJSON" compile_fn test_fn "NO-FORCE-ABI-V2"
} }
external_test Ens ens_test external_test Ens ens_test

View File

@ -33,17 +33,17 @@ function gnosis_safe_test
OPTIMIZER_LEVEL=1 OPTIMIZER_LEVEL=1
CONFIG="truffle.js" CONFIG="truffle.js"
truffle_setup https://github.com/solidity-external-tests/safe-contracts.git development_070 truffle_setup "$SOLJSON" https://github.com/solidity-external-tests/safe-contracts.git development_070
force_truffle_version ^5.0.42 force_truffle_version ^5.0.42
sed -i 's|github:gnosis/mock-contract#sol_0_5_0|github:solidity-external-tests/mock-contract#master_070|g' package.json sed -i 's|github:gnosis/mock-contract#sol_0_5_0|github:solidity-external-tests/mock-contract#master_070|g' package.json
rm -f package-lock.json rm -f package-lock.json
rm -rf node_modules/ rm -rf node_modules/
run_install install_fn run_install "$SOLJSON" install_fn
replace_libsolc_call replace_libsolc_call
truffle_run_test compile_fn test_fn truffle_run_test "$SOLJSON" compile_fn test_fn "NO-FORCE-ABI-V2"
} }
external_test Gnosis-Safe gnosis_safe_test external_test Gnosis-Safe gnosis_safe_test

View File

@ -35,16 +35,16 @@ function solcjs_test
SOLCJS_INPUT_DIR="$TEST_DIR"/test/externalTests/solc-js SOLCJS_INPUT_DIR="$TEST_DIR"/test/externalTests/solc-js
# set up solc-js on the branch specified # set up solc-js on the branch specified
setup master setup "$SOLJSON" master
printLog "Updating index.js file..." printLog "Updating index.js file..."
echo "require('./determinism.js');" >> test/index.js echo "require('./determinism.js');" >> test/index.js
printLog "Copying determinism.js..." printLog "Copying determinism.js..."
cp -f $SOLCJS_INPUT_DIR/determinism.js test/ cp -f "$SOLCJS_INPUT_DIR/determinism.js" test/
printLog "Copying contracts..." printLog "Copying contracts..."
cp -Rf $SOLCJS_INPUT_DIR/DAO test/ cp -Rf "$SOLCJS_INPUT_DIR/DAO" test/
printLog "Copying SMTChecker tests..." printLog "Copying SMTChecker tests..."
cp -Rf "$TEST_DIR"/test/libsolidity/smtCheckerTests test/ cp -Rf "$TEST_DIR"/test/libsolidity/smtCheckerTests test/
@ -52,7 +52,7 @@ function solcjs_test
# Update version (needed for some tests) # Update version (needed for some tests)
echo "Updating package.json to version $VERSION" echo "Updating package.json to version $VERSION"
npm version --allow-same-version --no-git-tag-version $VERSION npm version --allow-same-version --no-git-tag-version "$VERSION"
run_test compile_fn test_fn run_test compile_fn test_fn
} }

View File

@ -33,10 +33,10 @@ function zeppelin_test
OPTIMIZER_LEVEL=1 OPTIMIZER_LEVEL=1
CONFIG="truffle-config.js" CONFIG="truffle-config.js"
truffle_setup https://github.com/solidity-external-tests/openzeppelin-contracts.git upgrade-0.7.0 truffle_setup "$SOLJSON" https://github.com/solidity-external-tests/openzeppelin-contracts.git upgrade-0.7.0
run_install install_fn run_install "$SOLJSON" install_fn
truffle_run_test compile_fn test_fn truffle_run_test "$SOLJSON" compile_fn test_fn "NO-FORCE-ABI-V2"
} }
external_test Zeppelin zeppelin_test external_test Zeppelin zeppelin_test