Browse code

hack/make/test-integration-cli: introduce MAKEDIR variable

- every execution of dirname costs time
- less repeating

Signed-off-by: Jörg Thalheim <joerg@higgsboson.tk>

Jörg Thalheim authored on 2015/04/15 01:43:33
Showing 17 changed files
... ...
@@ -25,6 +25,7 @@ set -o pipefail
25 25
 
26 26
 export DOCKER_PKG='github.com/docker/docker'
27 27
 export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
28
+export MAKEDIR="$SCRIPTDIR/make"
28 29
 
29 30
 # We're a nice, sexy, little shell script, and people might try to run us;
30 31
 # but really, they shouldn't. We want to be in a container!
... ...
@@ -2,7 +2,7 @@
2 2
 set -e
3 3
 
4 4
 IAMSTATIC="true"
5
-source "$(dirname "$BASH_SOURCE")/.go-autogen"
5
+source "${MAKEDIR}/.go-autogen"
6 6
 
7 7
 # dockerinit still needs to be a static binary, even if docker is dynamic
8 8
 go build \
... ...
@@ -2,7 +2,7 @@
2 2
 set -e
3 3
 
4 4
 IAMSTATIC="true"
5
-source "$(dirname "$BASH_SOURCE")/.go-autogen"
5
+source "${MAKEDIR}/.go-autogen"
6 6
 
7 7
 # dockerinit still needs to be a static binary, even if docker is dynamic
8 8
 go build --compiler=gccgo \
... ...
@@ -11,7 +11,7 @@ if [[ "$(uname -s)" == CYGWIN* ]]; then
11 11
 	DEST=$(cygpath -mw $DEST)
12 12
 fi
13 13
 
14
-source "$(dirname "$BASH_SOURCE")/.go-autogen"
14
+source "${MAKEDIR}/.go-autogen"
15 15
 
16 16
 go build \
17 17
 	-o "$DEST/$BINARY_FULLNAME" \
... ...
@@ -5,7 +5,7 @@ DEST=$1
5 5
 
6 6
 # subshell so that we can export PATH without breaking other things
7 7
 (
8
-	source "$(dirname "$BASH_SOURCE")/.integration-daemon-start"
8
+	source "${MAKEDIR}/.integration-daemon-start"
9 9
 
10 10
 	# we need to wrap up everything in between integration-daemon-start and
11 11
 	# integration-daemon-stop to make sure we kill the daemon and don't hang,
... ...
@@ -76,7 +76,7 @@ DEST=$1
76 76
 	# clean up after ourselves
77 77
 	rm -f Dockerfile.build
78 78
 
79
-	source "$(dirname "$BASH_SOURCE")/.integration-daemon-stop"
79
+	source "${MAKEDIR}/.integration-daemon-stop"
80 80
 
81 81
 	[ -z "$didFail" ] # "set -e" ftw
82 82
 ) 2>&1 | tee -a $DEST/test.log
... ...
@@ -28,6 +28,6 @@ for platform in $DOCKER_CROSSPLATFORMS; do
28 28
 			export LDFLAGS_STATIC_DOCKER="" # we just need a simple client for these platforms
29 29
 			export BUILDFLAGS=( "${ORIG_BUILDFLAGS[@]/ daemon/}" ) # remove the "daemon" build tag from platforms that aren't supported
30 30
 		fi
31
-		source "$(dirname "$BASH_SOURCE")/binary" "$DEST/$platform"
31
+		source "${MAKEDIR}/binary" "$DEST/$platform"
32 32
 	)
33 33
 done
... ...
@@ -4,7 +4,7 @@ set -e
4 4
 DEST=$1
5 5
 
6 6
 if [ -z "$DOCKER_CLIENTONLY" ]; then
7
-	source "$(dirname "$BASH_SOURCE")/.dockerinit"
7
+	source "${MAKEDIR}/.dockerinit"
8 8
 
9 9
 	hash_files "$DEST/dockerinit-$VERSION"
10 10
 else
... ...
@@ -18,5 +18,5 @@ fi
18 18
 	export LDFLAGS_STATIC_DOCKER=''
19 19
 	export BUILDFLAGS=( "${BUILDFLAGS[@]/netgo /}" ) # disable netgo, since we don't need it for a dynamic binary
20 20
 	export BUILDFLAGS=( "${BUILDFLAGS[@]/static_build /}" ) # we're not building a "static" binary here
21
-	source "$(dirname "$BASH_SOURCE")/binary"
21
+	source "${MAKEDIR}/binary"
22 22
 )
... ...
@@ -4,7 +4,7 @@ set -e
4 4
 DEST=$1
5 5
 
6 6
 if [ -z "$DOCKER_CLIENTONLY" ]; then
7
-	source "$(dirname "$BASH_SOURCE")/.dockerinit-gccgo"
7
+	source "${MAKEDIR}/.dockerinit-gccgo"
8 8
 
9 9
 	hash_files "$DEST/dockerinit-$VERSION"
10 10
 else
... ...
@@ -19,5 +19,5 @@ fi
19 19
 	export LDFLAGS_STATIC_DOCKER=''
20 20
 	export BUILDFLAGS=( "${BUILDFLAGS[@]/netgo /}" ) # disable netgo, since we don't need it for a dynamic binary
21 21
 	export BUILDFLAGS=( "${BUILDFLAGS[@]/static_build /}" ) # we're not building a "static" binary here
22
-	source "$(dirname "$BASH_SOURCE")/gccgo"
22
+	source "${MAKEDIR}/gccgo"
23 23
 )
... ...
@@ -6,7 +6,7 @@ BINARY_NAME="docker-$VERSION"
6 6
 BINARY_EXTENSION="$(binary_extension)"
7 7
 BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION"
8 8
 
9
-source "$(dirname "$BASH_SOURCE")/.go-autogen"
9
+source "${MAKEDIR}/.go-autogen"
10 10
 
11 11
 go build -compiler=gccgo \
12 12
 	-o "$DEST/$BINARY_FULLNAME" \
... ...
@@ -5,7 +5,7 @@ DEST=$1
5 5
 
6 6
 # subshell so that we can export PATH without breaking other things
7 7
 (
8
-	source "$(dirname "$BASH_SOURCE")/.integration-daemon-start"
8
+	source "${MAKEDIR}/.integration-daemon-start"
9 9
 
10 10
 	# we need to wrap up everything in between integration-daemon-start and
11 11
 	# integration-daemon-stop to make sure we kill the daemon and don't hang,
... ...
@@ -24,7 +24,7 @@ DEST=$1
24 24
 		didFail=1
25 25
 	fi
26 26
 
27
-	source "$(dirname "$BASH_SOURCE")/.integration-daemon-stop"
27
+	source "${MAKEDIR}/.integration-daemon-stop"
28 28
 
29 29
 	[ -z "$didFail" ] # "set -e" ftw
30 30
 ) 2>&1 | tee -a $DEST/test.log
... ...
@@ -5,7 +5,7 @@ DEST=$1
5 5
 
6 6
 INIT=$DEST/../dynbinary/dockerinit-$VERSION
7 7
 [ -x "$INIT" ] || {
8
-	source "$(dirname "$BASH_SOURCE")/.dockerinit"
8
+	source "${MAKEDIR}/.dockerinit"
9 9
 	INIT="$DEST/dockerinit"
10 10
 }
11 11
 export TEST_DOCKERINIT_PATH="$INIT"
... ...
@@ -9,23 +9,23 @@ bundle_test_integration_cli() {
9 9
 
10 10
 # subshell so that we can export PATH without breaking other things
11 11
 (
12
-	source "$(dirname "$BASH_SOURCE")/.integration-daemon-start"
12
+	source "${MAKEDIR}/.integration-daemon-start"
13 13
 
14 14
 	# we need to wrap up everything in between integration-daemon-start and
15 15
 	# integration-daemon-stop to make sure we kill the daemon and don't hang,
16 16
 	# even and especially on test failures
17 17
 	didFail=
18 18
 	if ! {
19
-		source "$(dirname "$BASH_SOURCE")/.ensure-frozen-images"
20
-		source "$(dirname "$BASH_SOURCE")/.ensure-httpserver"
21
-		source "$(dirname "$BASH_SOURCE")/.ensure-emptyfs"
19
+		source "${MAKEDIR}/.ensure-frozen-images"
20
+		source "${MAKEDIR}/.ensure-httpserver"
21
+		source "${MAKEDIR}/.ensure-emptyfs"
22 22
 
23 23
 		bundle_test_integration_cli
24 24
 	}; then
25 25
 		didFail=1
26 26
 	fi
27 27
 
28
-	source "$(dirname "$BASH_SOURCE")/.integration-daemon-stop"
28
+	source "${MAKEDIR}/.integration-daemon-stop"
29 29
 
30 30
 	[ -z "$didFail" ] # "set -e" ftw
31
-) 2>&1 | tee -a $DEST/test.log
31
+) 2>&1 | tee -a "$DEST/test.log"
... ...
@@ -39,12 +39,12 @@ bundle_test_unit() {
39 39
 				mkdir -p "$HOME/.parallel"
40 40
 				touch "$HOME/.parallel/ignored_vars"
41 41
 
42
-				echo "$TESTDIRS" | parallel --jobs "$PARALLEL_JOBS" --env _ "$(dirname "$BASH_SOURCE")/.go-compile-test-dir"
42
+				echo "$TESTDIRS" | parallel --jobs "$PARALLEL_JOBS" --env _ "${MAKEDIR}/.go-compile-test-dir"
43 43
 				rm -rf "$HOME"
44 44
 			else
45 45
 				# aww, no "parallel" available - fall back to boring
46 46
 				for test_dir in $TESTDIRS; do
47
-					"$(dirname "$BASH_SOURCE")/.go-compile-test-dir" "$test_dir" || true
47
+					"${MAKEDIR}/.go-compile-test-dir" "$test_dir" || true
48 48
 					# don't let one directory that fails to build tank _all_ our tests!
49 49
 				done
50 50
 			fi
... ...
@@ -1,6 +1,6 @@
1 1
 #!/bin/bash
2 2
 
3
-source "$(dirname "$BASH_SOURCE")/.validate"
3
+source "${MAKEDIR}/.validate"
4 4
 
5 5
 adds=$(validate_diff --numstat | awk '{ s += $1 } END { print s }')
6 6
 dels=$(validate_diff --numstat | awk '{ s += $2 } END { print s }')
... ...
@@ -1,6 +1,6 @@
1 1
 #!/bin/bash
2 2
 
3
-source "$(dirname "$BASH_SOURCE")/.validate"
3
+source "${MAKEDIR}/.validate"
4 4
 
5 5
 IFS=$'\n'
6 6
 files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' || true) )
... ...
@@ -1,6 +1,6 @@
1 1
 #!/bin/bash
2 2
 
3
-source "$(dirname "$BASH_SOURCE")/.validate"
3
+source "${MAKEDIR}/.validate"
4 4
 
5 5
 IFS=$'\n'
6 6
 files=( $(validate_diff --diff-filter=ACMR --name-only -- 'MAINTAINERS' || true) )
... ...
@@ -1,6 +1,6 @@
1 1
 #!/bin/bash
2 2
 
3
-source "$(dirname "$BASH_SOURCE")/.validate"
3
+source "${MAKEDIR}/.validate"
4 4
 
5 5
 IFS=$'\n'
6 6
 files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' || true) )