From 1d994da12b875436491a54252e50bb976fbb3893 Mon Sep 17 00:00:00 2001 From: "Daniel J. Hofmann" Date: Tue, 18 Oct 2016 14:05:20 -0700 Subject: [PATCH] Makes Scripts Fail Fast and Loud --- scripts/analyze.sh | 5 +++++ scripts/bisect_cucumber.sh | 7 ++++--- scripts/format.sh | 6 ++++-- scripts/install_node.sh | 2 ++ scripts/modernize.sh | 4 ++++ scripts/tidy.sh | 4 ++++ scripts/timer.sh | 6 +++++- scripts/update_dependencies.sh | 4 ++++ 8 files changed, 32 insertions(+), 6 deletions(-) diff --git a/scripts/analyze.sh b/scripts/analyze.sh index 872d49526..41ef60e13 100755 --- a/scripts/analyze.sh +++ b/scripts/analyze.sh @@ -1,10 +1,15 @@ #!/usr/bin/env bash +set -o errexit +set -o pipefail +set -o nounset + # Runs the Static Analyzer on the code base. # This is a wrapper intended to be used with like this: # 1/ analyze cmake .. # 2/ analyze cmake --build . + exec scan-build -analyze-headers -no-failure-reports --keep-going --status-bugs \ -enable-checker alpha.core.BoolAssignment \ -enable-checker alpha.core.IdenticalExpr \ diff --git a/scripts/bisect_cucumber.sh b/scripts/bisect_cucumber.sh index 38c2b8c5e..b58d61843 100755 --- a/scripts/bisect_cucumber.sh +++ b/scripts/bisect_cucumber.sh @@ -1,5 +1,9 @@ #!/usr/bin/env bash +set -o errexit +set -o pipefail +set -o nounset + # Automates bisecting cucumber tests in a portable way; usage: # # git bisect start GOODGITSHA BADGITSHA @@ -9,9 +13,6 @@ # to /tmp, otherwise jumping through commits will change this script, too. -# e: exit on first error, x: print commands -set -ex - BUILD_DIR=build cmake -E remove_directory $BUILD_DIR diff --git a/scripts/format.sh b/scripts/format.sh index f95f8735a..df5c49fa4 100755 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -1,12 +1,14 @@ #!/usr/bin/env bash +set -o errexit +set -o pipefail +set -o nounset + # Runs the Clang Formatter in parallel on the code base. # Return codes: # - 1 there are files to be formatted # - 0 everything looks fine -set -eu -o pipefail - # Get CPU count OS=$(uname) NPROC=1 diff --git a/scripts/install_node.sh b/scripts/install_node.sh index a22bfd2ef..a77b48406 100644 --- a/scripts/install_node.sh +++ b/scripts/install_node.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + # here we set up the node version on the fly. currently only node 4, but can be used for more values if need be # This is done manually so that the build works the same on OS X rm -rf ~/.nvm/ && git clone --depth 1 --branch v0.30.1 https://github.com/creationix/nvm.git ~/.nvm diff --git a/scripts/modernize.sh b/scripts/modernize.sh index 48d90ba36..fb5a666cd 100755 --- a/scripts/modernize.sh +++ b/scripts/modernize.sh @@ -1,5 +1,9 @@ #!/usr/bin/env bash +set -o errexit +set -o pipefail +set -o nounset + # Runs the Clang Modernizer in parallel on the code base. # Requires a compilation database in the build directory. diff --git a/scripts/tidy.sh b/scripts/tidy.sh index 7f4ba1486..a9d1a1a0e 100755 --- a/scripts/tidy.sh +++ b/scripts/tidy.sh @@ -1,5 +1,9 @@ #!/usr/bin/env bash +set -o errexit +set -o pipefail +set -o nounset + # Runs the Clang Tidy Tool in parallel on the code base. # Requires a compilation database in the build directory. diff --git a/scripts/timer.sh b/scripts/timer.sh index 926900fcb..0ff9c82c5 100755 --- a/scripts/timer.sh +++ b/scripts/timer.sh @@ -1,4 +1,8 @@ -#!/bin/bash +#!/usr/bin/env bash + +set -o errexit +set -o pipefail +set -o nounset TIMINGS_FILE=/tmp/osrm.timings NAME=$1 diff --git a/scripts/update_dependencies.sh b/scripts/update_dependencies.sh index 7b2398af3..b0d417ac6 100755 --- a/scripts/update_dependencies.sh +++ b/scripts/update_dependencies.sh @@ -1,5 +1,9 @@ #!/usr/bin/env bash +set -o errexit +set -o pipefail +set -o nounset + # Note: once the subtree merge from this script has been committed and pushed to # a branch do not attempt to rebase the branch back onto master or the subdirectory # structure will be lost.