From 6533cb973f6bab672018148fd6a67644580cc61f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 14 Apr 2015 18:43:33 +0200 Subject: [PATCH] hack/make/test-integration-cli: introduce MAKEDIR variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - every execution of dirname costs time - less repeating Signed-off-by: Jörg Thalheim --- hack/make.sh | 1 + hack/make/.dockerinit | 2 +- hack/make/.dockerinit-gccgo | 2 +- hack/make/binary | 2 +- hack/make/build-deb | 4 ++-- hack/make/cross | 2 +- hack/make/dynbinary | 4 ++-- hack/make/dyngccgo | 4 ++-- hack/make/gccgo | 2 +- hack/make/test-docker-py | 4 ++-- hack/make/test-integration | 2 +- hack/make/test-integration-cli | 12 ++++++------ hack/make/test-unit | 4 ++-- hack/make/validate-dco | 2 +- hack/make/validate-gofmt | 2 +- hack/make/validate-toml | 2 +- hack/make/validate-vet | 2 +- 17 files changed, 27 insertions(+), 26 deletions(-) diff --git a/hack/make.sh b/hack/make.sh index d2547af12e..eeb26cbce0 100755 --- a/hack/make.sh +++ b/hack/make.sh @@ -25,6 +25,7 @@ set -o pipefail export DOCKER_PKG='github.com/docker/docker' export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +export MAKEDIR="$SCRIPTDIR/make" # We're a nice, sexy, little shell script, and people might try to run us; # but really, they shouldn't. We want to be in a container! diff --git a/hack/make/.dockerinit b/hack/make/.dockerinit index 36be4f822c..4a62ee1add 100644 --- a/hack/make/.dockerinit +++ b/hack/make/.dockerinit @@ -2,7 +2,7 @@ set -e IAMSTATIC="true" -source "$(dirname "$BASH_SOURCE")/.go-autogen" +source "${MAKEDIR}/.go-autogen" # dockerinit still needs to be a static binary, even if docker is dynamic go build \ diff --git a/hack/make/.dockerinit-gccgo b/hack/make/.dockerinit-gccgo index 47611d66a4..022f6db009 100644 --- a/hack/make/.dockerinit-gccgo +++ b/hack/make/.dockerinit-gccgo @@ -2,7 +2,7 @@ set -e IAMSTATIC="true" -source "$(dirname "$BASH_SOURCE")/.go-autogen" +source "${MAKEDIR}/.go-autogen" # dockerinit still needs to be a static binary, even if docker is dynamic go build --compiler=gccgo \ diff --git a/hack/make/binary b/hack/make/binary index 0f57ea0d69..d3ec2939c0 100644 --- a/hack/make/binary +++ b/hack/make/binary @@ -11,7 +11,7 @@ if [[ "$(uname -s)" == CYGWIN* ]]; then DEST=$(cygpath -mw $DEST) fi -source "$(dirname "$BASH_SOURCE")/.go-autogen" +source "${MAKEDIR}/.go-autogen" go build \ -o "$DEST/$BINARY_FULLNAME" \ diff --git a/hack/make/build-deb b/hack/make/build-deb index 657aa04ccb..90c4c16939 100644 --- a/hack/make/build-deb +++ b/hack/make/build-deb @@ -5,7 +5,7 @@ DEST=$1 # subshell so that we can export PATH without breaking other things ( - source "$(dirname "$BASH_SOURCE")/.integration-daemon-start" + source "${MAKEDIR}/.integration-daemon-start" # we need to wrap up everything in between integration-daemon-start and # integration-daemon-stop to make sure we kill the daemon and don't hang, @@ -76,7 +76,7 @@ DEST=$1 # clean up after ourselves rm -f Dockerfile.build - source "$(dirname "$BASH_SOURCE")/.integration-daemon-stop" + source "${MAKEDIR}/.integration-daemon-stop" [ -z "$didFail" ] # "set -e" ftw ) 2>&1 | tee -a $DEST/test.log diff --git a/hack/make/cross b/hack/make/cross index 3c5cb0401d..368ebc5ab9 100644 --- a/hack/make/cross +++ b/hack/make/cross @@ -28,6 +28,6 @@ for platform in $DOCKER_CROSSPLATFORMS; do export LDFLAGS_STATIC_DOCKER="" # we just need a simple client for these platforms export BUILDFLAGS=( "${ORIG_BUILDFLAGS[@]/ daemon/}" ) # remove the "daemon" build tag from platforms that aren't supported fi - source "$(dirname "$BASH_SOURCE")/binary" "$DEST/$platform" + source "${MAKEDIR}/binary" "$DEST/$platform" ) done diff --git a/hack/make/dynbinary b/hack/make/dynbinary index f9b43b0e77..e1b65b48ef 100644 --- a/hack/make/dynbinary +++ b/hack/make/dynbinary @@ -4,7 +4,7 @@ set -e DEST=$1 if [ -z "$DOCKER_CLIENTONLY" ]; then - source "$(dirname "$BASH_SOURCE")/.dockerinit" + source "${MAKEDIR}/.dockerinit" hash_files "$DEST/dockerinit-$VERSION" else @@ -18,5 +18,5 @@ fi export LDFLAGS_STATIC_DOCKER='' export BUILDFLAGS=( "${BUILDFLAGS[@]/netgo /}" ) # disable netgo, since we don't need it for a dynamic binary export BUILDFLAGS=( "${BUILDFLAGS[@]/static_build /}" ) # we're not building a "static" binary here - source "$(dirname "$BASH_SOURCE")/binary" + source "${MAKEDIR}/binary" ) diff --git a/hack/make/dyngccgo b/hack/make/dyngccgo index 738e1450ac..7bdd404f10 100644 --- a/hack/make/dyngccgo +++ b/hack/make/dyngccgo @@ -4,7 +4,7 @@ set -e DEST=$1 if [ -z "$DOCKER_CLIENTONLY" ]; then - source "$(dirname "$BASH_SOURCE")/.dockerinit-gccgo" + source "${MAKEDIR}/.dockerinit-gccgo" hash_files "$DEST/dockerinit-$VERSION" else @@ -19,5 +19,5 @@ fi export LDFLAGS_STATIC_DOCKER='' export BUILDFLAGS=( "${BUILDFLAGS[@]/netgo /}" ) # disable netgo, since we don't need it for a dynamic binary export BUILDFLAGS=( "${BUILDFLAGS[@]/static_build /}" ) # we're not building a "static" binary here - source "$(dirname "$BASH_SOURCE")/gccgo" + source "${MAKEDIR}/gccgo" ) diff --git a/hack/make/gccgo b/hack/make/gccgo index c85d2fbda5..c61c190f3a 100644 --- a/hack/make/gccgo +++ b/hack/make/gccgo @@ -6,7 +6,7 @@ BINARY_NAME="docker-$VERSION" BINARY_EXTENSION="$(binary_extension)" BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION" -source "$(dirname "$BASH_SOURCE")/.go-autogen" +source "${MAKEDIR}/.go-autogen" go build -compiler=gccgo \ -o "$DEST/$BINARY_FULLNAME" \ diff --git a/hack/make/test-docker-py b/hack/make/test-docker-py index b95cf40af5..409cee0e4e 100644 --- a/hack/make/test-docker-py +++ b/hack/make/test-docker-py @@ -5,7 +5,7 @@ DEST=$1 # subshell so that we can export PATH without breaking other things ( - source "$(dirname "$BASH_SOURCE")/.integration-daemon-start" + source "${MAKEDIR}/.integration-daemon-start" # we need to wrap up everything in between integration-daemon-start and # integration-daemon-stop to make sure we kill the daemon and don't hang, @@ -24,7 +24,7 @@ DEST=$1 didFail=1 fi - source "$(dirname "$BASH_SOURCE")/.integration-daemon-stop" + source "${MAKEDIR}/.integration-daemon-stop" [ -z "$didFail" ] # "set -e" ftw ) 2>&1 | tee -a $DEST/test.log diff --git a/hack/make/test-integration b/hack/make/test-integration index b4cb6debde..206e37abf0 100644 --- a/hack/make/test-integration +++ b/hack/make/test-integration @@ -5,7 +5,7 @@ DEST=$1 INIT=$DEST/../dynbinary/dockerinit-$VERSION [ -x "$INIT" ] || { - source "$(dirname "$BASH_SOURCE")/.dockerinit" + source "${MAKEDIR}/.dockerinit" INIT="$DEST/dockerinit" } export TEST_DOCKERINIT_PATH="$INIT" diff --git a/hack/make/test-integration-cli b/hack/make/test-integration-cli index 3ef41d919e..8e9b975704 100644 --- a/hack/make/test-integration-cli +++ b/hack/make/test-integration-cli @@ -9,23 +9,23 @@ bundle_test_integration_cli() { # subshell so that we can export PATH without breaking other things ( - source "$(dirname "$BASH_SOURCE")/.integration-daemon-start" + source "${MAKEDIR}/.integration-daemon-start" # we need to wrap up everything in between integration-daemon-start and # integration-daemon-stop to make sure we kill the daemon and don't hang, # even and especially on test failures didFail= if ! { - source "$(dirname "$BASH_SOURCE")/.ensure-frozen-images" - source "$(dirname "$BASH_SOURCE")/.ensure-httpserver" - source "$(dirname "$BASH_SOURCE")/.ensure-emptyfs" + source "${MAKEDIR}/.ensure-frozen-images" + source "${MAKEDIR}/.ensure-httpserver" + source "${MAKEDIR}/.ensure-emptyfs" bundle_test_integration_cli }; then didFail=1 fi - source "$(dirname "$BASH_SOURCE")/.integration-daemon-stop" + source "${MAKEDIR}/.integration-daemon-stop" [ -z "$didFail" ] # "set -e" ftw -) 2>&1 | tee -a $DEST/test.log +) 2>&1 | tee -a "$DEST/test.log" diff --git a/hack/make/test-unit b/hack/make/test-unit index 15595a89c3..7b6ce089e2 100644 --- a/hack/make/test-unit +++ b/hack/make/test-unit @@ -39,12 +39,12 @@ bundle_test_unit() { mkdir -p "$HOME/.parallel" touch "$HOME/.parallel/ignored_vars" - echo "$TESTDIRS" | parallel --jobs "$PARALLEL_JOBS" --env _ "$(dirname "$BASH_SOURCE")/.go-compile-test-dir" + echo "$TESTDIRS" | parallel --jobs "$PARALLEL_JOBS" --env _ "${MAKEDIR}/.go-compile-test-dir" rm -rf "$HOME" else # aww, no "parallel" available - fall back to boring for test_dir in $TESTDIRS; do - "$(dirname "$BASH_SOURCE")/.go-compile-test-dir" "$test_dir" || true + "${MAKEDIR}/.go-compile-test-dir" "$test_dir" || true # don't let one directory that fails to build tank _all_ our tests! done fi diff --git a/hack/make/validate-dco b/hack/make/validate-dco index 84c47f526d..5ac98728f3 100644 --- a/hack/make/validate-dco +++ b/hack/make/validate-dco @@ -1,6 +1,6 @@ #!/bin/bash -source "$(dirname "$BASH_SOURCE")/.validate" +source "${MAKEDIR}/.validate" adds=$(validate_diff --numstat | awk '{ s += $1 } END { print s }') dels=$(validate_diff --numstat | awk '{ s += $2 } END { print s }') diff --git a/hack/make/validate-gofmt b/hack/make/validate-gofmt index 8fc88cc559..7ad9e85576 100644 --- a/hack/make/validate-gofmt +++ b/hack/make/validate-gofmt @@ -1,6 +1,6 @@ #!/bin/bash -source "$(dirname "$BASH_SOURCE")/.validate" +source "${MAKEDIR}/.validate" IFS=$'\n' files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' || true) ) diff --git a/hack/make/validate-toml b/hack/make/validate-toml index 16c228d14e..18f26ee757 100644 --- a/hack/make/validate-toml +++ b/hack/make/validate-toml @@ -1,6 +1,6 @@ #!/bin/bash -source "$(dirname "$BASH_SOURCE")/.validate" +source "${MAKEDIR}/.validate" IFS=$'\n' files=( $(validate_diff --diff-filter=ACMR --name-only -- 'MAINTAINERS' || true) ) diff --git a/hack/make/validate-vet b/hack/make/validate-vet index e88f7549c3..febe93e5c1 100644 --- a/hack/make/validate-vet +++ b/hack/make/validate-vet @@ -1,6 +1,6 @@ #!/bin/bash -source "$(dirname "$BASH_SOURCE")/.validate" +source "${MAKEDIR}/.validate" IFS=$'\n' files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' || true) )