From d14c4288ec8c944953bed2590c3c3244dafc3b95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Fri, 11 Dec 2020 20:08:45 +0100 Subject: [PATCH] Make scripts fail on non-zero return codes and undefined variables where possible --- scripts/check_style.sh | 6 ++++-- scripts/chk_shellscripts/chk_shellscripts.sh | 2 +- scripts/endToEndExtraction/create_traces.sh | 15 ++++++++------- scripts/install_cmake.sh | 2 +- scripts/install_obsolete_jsoncpp_1_7_4.sh | 2 +- scripts/install_static_z3.sh | 2 ++ scripts/soltest.sh | 2 +- 7 files changed, 18 insertions(+), 13 deletions(-) diff --git a/scripts/check_style.sh b/scripts/check_style.sh index b8033ea28..5c423230c 100755 --- a/scripts/check_style.sh +++ b/scripts/check_style.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +set -eu + ERROR_LOG="$(mktemp -t check_style_XXXXXX.log)" EXCLUDE_FILES=( @@ -20,7 +22,7 @@ REPO_ROOT="$(dirname "$0")"/.. cd "$REPO_ROOT" || exit 1 WHITESPACE=$(git grep -n -I -E "^.*[[:space:]]+$" | - grep -v "test/libsolidity/ASTJSON\|test/libsolidity/ASTRecoveryTests\|test/compilationTests/zeppelin/LICENSE\|${EXCLUDE_FILES_JOINED}" + grep -v "test/libsolidity/ASTJSON\|test/libsolidity/ASTRecoveryTests\|test/compilationTests/zeppelin/LICENSE\|${EXCLUDE_FILES_JOINED}" || true ) if [[ "$WHITESPACE" != "" ]] @@ -49,7 +51,7 @@ FORMATERROR=$( preparedGrep "[a-zA-Z0-9_]\s*[&][a-zA-Z_]" | grep -E -v "return [&]" # right-aligned reference ampersand (needs to exclude return) # right-aligned reference pointer star (needs to exclude return and comments) preparedGrep "[a-zA-Z0-9_]\s*[*][a-zA-Z_]" | grep -E -v -e "return [*]" -e "^* [*]" -e "^*//.*" -) | grep -E -v -e "^[a-zA-Z\./]*:[0-9]*:\s*\/(\/|\*)" -e "^test/" +) | grep -E -v -e "^[a-zA-Z\./]*:[0-9]*:\s*\/(\/|\*)" -e "^test/" || true ) if [[ "$FORMATERROR" != "" ]] diff --git a/scripts/chk_shellscripts/chk_shellscripts.sh b/scripts/chk_shellscripts/chk_shellscripts.sh index 12ece3f4e..4f5c23743 100755 --- a/scripts/chk_shellscripts/chk_shellscripts.sh +++ b/scripts/chk_shellscripts/chk_shellscripts.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -set -e +set -eu REPO_ROOT="$(dirname "$0")"/../.. REPO_ROOT=$(realpath "${REPO_ROOT}") diff --git a/scripts/endToEndExtraction/create_traces.sh b/scripts/endToEndExtraction/create_traces.sh index 8970c5cb3..3e1de4677 100755 --- a/scripts/endToEndExtraction/create_traces.sh +++ b/scripts/endToEndExtraction/create_traces.sh @@ -1,24 +1,25 @@ #!/usr/bin/env bash +set -eu -BASE_PATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 || exit ; pwd -P )" +BASE_PATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 && pwd -P )" mkdir -p build -cd build || exit +cd build cmake ../../../ make soltest -cd test/ || exit +cd test/ echo "running soltest on 'semanticTests/extracted'..." ./soltest --color_output=false --log_level=test_suite -t semanticTests/extracted/ -- --testpath "${BASE_PATH}/../../test" --no-smt --evmonepath /Users/alex/evmone/lib/libevmone.dylib --show-messages --show-metadata > "${BASE_PATH}/extracted-tests.trace" echo "running soltest on 'semanticTests/extracted'... done" -cd "$BASE_PATH" || exit +cd "$BASE_PATH" git clone git@github.com:ethereum/solidity.git solidity-develop -cd solidity-develop || exit +cd solidity-develop mkdir -p build -cd build || exit +cd build cmake .. make soltest -cd test/ || exit +cd test/ echo "running soltest on 'SolidityEndToEndTest'..." ./soltest --color_output=false --log_level=test_suite -t SolidityEndToEndTest/ -- --testpath "${BASE_PATH}/solidity-develop/test" --no-smt --evmonepath /Users/alex/evmone/lib/libevmone.dylib --show-messages --show-metadata > "${BASE_PATH}/endToEndExtraction-tests.trace" echo "running soltest on 'SolidityEndToEndTest'... done" diff --git a/scripts/install_cmake.sh b/scripts/install_cmake.sh index d7317d1e5..0533de723 100755 --- a/scripts/install_cmake.sh +++ b/scripts/install_cmake.sh @@ -4,7 +4,7 @@ # (the cmake executable will be in ~/.local/bin). # This is mostly suitable for CIs, not end users. -set -e +set -eu VERSION_MAJOR=3 VERSION_MINOR=15 diff --git a/scripts/install_obsolete_jsoncpp_1_7_4.sh b/scripts/install_obsolete_jsoncpp_1_7_4.sh index 9dbbde491..eb617e651 100755 --- a/scripts/install_obsolete_jsoncpp_1_7_4.sh +++ b/scripts/install_obsolete_jsoncpp_1_7_4.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -e +set -eu TEMPDIR=$(mktemp -d) ( diff --git a/scripts/install_static_z3.sh b/scripts/install_static_z3.sh index 6fba203d8..304ef410c 100644 --- a/scripts/install_static_z3.sh +++ b/scripts/install_static_z3.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +set -eu + git clone --depth 1 --branch z3-4.8.7 https://github.com/Z3Prover/z3.git cd z3 mkdir build diff --git a/scripts/soltest.sh b/scripts/soltest.sh index db802aa47..e9b6de979 100755 --- a/scripts/soltest.sh +++ b/scripts/soltest.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -e +set -eu REPO_ROOT="$(dirname "$0")"/.. USE_DEBUGGER=0