diff --git a/scripts/chk_shellscripts/ignore.txt b/scripts/chk_shellscripts/ignore.txt index 220ed9f57..188efb0ab 100644 --- a/scripts/chk_shellscripts/ignore.txt +++ b/scripts/chk_shellscripts/ignore.txt @@ -1,12 +1,5 @@ ./test/docsCodeStyle.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/get_version.sh ./scripts/soltest.sh diff --git a/scripts/common.sh b/scripts/common.sh index fbb730241..3518a21aa 100644 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -1,3 +1,4 @@ +#!/usr/bin/env bash # ------------------------------------------------------------------------------ # vim:ts=4:et # This file is part of solidity. @@ -37,21 +38,21 @@ safe_kill() local n=1 # 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}) ..." - kill $PID + kill "$PID" # 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) ..." sleep 1 - n=$[n + 1] + n=$((n + 1)) done # 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}) ..." - kill -9 $PID + kill -9 "$PID" fi } diff --git a/test/externalTests.sh b/test/externalTests.sh index 7bf3eb76b..e53f9925a 100755 --- a/test/externalTests.sh +++ b/test/externalTests.sh @@ -42,10 +42,10 @@ source test/externalTests/common.sh printTask "Running external tests..." -$REPO_ROOT/externalTests/zeppelin.sh "$SOLJSON" -$REPO_ROOT/externalTests/gnosis.sh "$SOLJSON" -$REPO_ROOT/externalTests/colony.sh "$SOLJSON" -$REPO_ROOT/externalTests/ens.sh "$SOLJSON" +"$REPO_ROOT/externalTests/zeppelin.sh" "$SOLJSON" +"$REPO_ROOT/externalTests/gnosis.sh" "$SOLJSON" +"$REPO_ROOT/externalTests/colony.sh" "$SOLJSON" +"$REPO_ROOT/externalTests/ens.sh" "$SOLJSON" # Disabled temporarily as it needs to be updated to latest Truffle first. #test_truffle Gnosis https://github.com/axic/pm-contracts.git solidity-050 diff --git a/test/externalTests/colony.sh b/test/externalTests/colony.sh index 6a246b2b9..349cabf2a 100755 --- a/test/externalTests/colony.sh +++ b/test/externalTests/colony.sh @@ -31,18 +31,17 @@ function test_fn { yarn run test:contracts; } function colony_test { OPTIMIZER_LEVEL=3 - FORCE_ABIv2=false CONFIG="truffle.js" - truffle_setup https://github.com/solidity-external-tests/colonyNetwork.git develop_070 - run_install install_fn + truffle_setup "$SOLJSON" https://github.com/solidity-external-tests/colonyNetwork.git develop_070 + run_install "$SOLJSON" install_fn cd lib rm -Rf dappsys git clone https://github.com/solidity-external-tests/dappsys-monolithic.git -b master_060 dappsys 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 diff --git a/test/externalTests/common.sh b/test/externalTests/common.sh index d56912a85..ad36a5ff4 100644 --- a/test/externalTests/common.sh +++ b/test/externalTests/common.sh @@ -40,9 +40,10 @@ function verify_version_input 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 } @@ -80,7 +81,7 @@ function download_project printLog "Cloning $branch of $repo..." git clone --depth 1 "$repo" -b "$branch" "$dir/ext" cd ext - echo "Current commit hash: `git rev-parse HEAD`" + echo "Current commit hash: $(git rev-parse HEAD)" } function force_truffle_version @@ -92,10 +93,11 @@ function force_truffle_version function truffle_setup { - local repo="$1" - local branch="$2" + local soljson="$1" + local repo="$2" + local branch="$3" - setup_solcjs "$DIR" "$SOLJSON" "master" "solc" + setup_solcjs "$DIR" "$soljson" "master" "solc" download_project "$repo" "$branch" "$DIR" } @@ -207,11 +209,12 @@ function clean function run_install { - local init_fn="$1" + local soljson="$1" + local init_fn="$2" printLog "Running install function..." replace_version_pragmas - force_solc "$CONFIG" "$DIR" "$SOLJSON" + force_solc "$CONFIG" "$DIR" "$soljson" $init_fn } @@ -232,11 +235,15 @@ function run_test function truffle_run_test { - local compile_fn="$1" - local test_fn="$2" + local soljson="$1" + 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 - force_solc "$CONFIG" "$DIR" "$SOLJSON" + force_solc "$CONFIG" "$DIR" "$soljson" printLog "Checking optimizer level..." if [ -z "$OPTIMIZER_LEVEL" ]; then @@ -258,7 +265,7 @@ function truffle_run_test clean force_solc_settings "$CONFIG" "$optimize" "istanbul" # 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 fi diff --git a/test/externalTests/ens.sh b/test/externalTests/ens.sh index 52cccdb56..99f4b8971 100755 --- a/test/externalTests/ens.sh +++ b/test/externalTests/ens.sh @@ -18,9 +18,7 @@ # # (c) 2019 solidity contributors. #------------------------------------------------------------------------------ -# shellcheck disable=SC1091 source scripts/common.sh -# shellcheck disable=SC1091 source test/externalTests/common.sh verify_input "$1" @@ -35,14 +33,14 @@ function ens_test export OPTIMIZER_LEVEL=1 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. 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 diff --git a/test/externalTests/gnosis.sh b/test/externalTests/gnosis.sh index 8a5ccd0c7..73870f8db 100755 --- a/test/externalTests/gnosis.sh +++ b/test/externalTests/gnosis.sh @@ -33,17 +33,17 @@ function gnosis_safe_test OPTIMIZER_LEVEL=1 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 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 -rf node_modules/ - run_install install_fn + run_install "$SOLJSON" install_fn 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 diff --git a/test/externalTests/solc-js/solc-js.sh b/test/externalTests/solc-js/solc-js.sh index db01a2ae7..9cc753959 100755 --- a/test/externalTests/solc-js/solc-js.sh +++ b/test/externalTests/solc-js/solc-js.sh @@ -35,16 +35,16 @@ function solcjs_test SOLCJS_INPUT_DIR="$TEST_DIR"/test/externalTests/solc-js # set up solc-js on the branch specified - setup master + setup "$SOLJSON" master printLog "Updating index.js file..." echo "require('./determinism.js');" >> test/index.js printLog "Copying determinism.js..." - cp -f $SOLCJS_INPUT_DIR/determinism.js test/ + cp -f "$SOLCJS_INPUT_DIR/determinism.js" test/ printLog "Copying contracts..." - cp -Rf $SOLCJS_INPUT_DIR/DAO test/ + cp -Rf "$SOLCJS_INPUT_DIR/DAO" test/ printLog "Copying SMTChecker tests..." cp -Rf "$TEST_DIR"/test/libsolidity/smtCheckerTests test/ @@ -52,7 +52,7 @@ function solcjs_test # Update version (needed for some tests) 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 } diff --git a/test/externalTests/zeppelin.sh b/test/externalTests/zeppelin.sh index 51051f334..e71e974d6 100755 --- a/test/externalTests/zeppelin.sh +++ b/test/externalTests/zeppelin.sh @@ -33,10 +33,10 @@ function zeppelin_test OPTIMIZER_LEVEL=1 CONFIG="truffle-config.js" - truffle_setup https://github.com/solidity-external-tests/openzeppelin-contracts.git upgrade-0.7.0 - run_install install_fn + truffle_setup "$SOLJSON" https://github.com/solidity-external-tests/openzeppelin-contracts.git upgrade-0.7.0 + 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