From 8ffdf6022e88e19c6d1f434a69ff5cbd3dc7db6b Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Sun, 28 Sep 2014 21:48:57 -0600 Subject: [PATCH] Move the body of go_compile_test_dir into a file since GNU Parallel breaks on sourcing exported Bash functions thanks to the shellshock fixes Signed-off-by: Andrew Page --- hack/make.sh | 25 ------------------------- hack/make/.go-compile-test-dir | 26 ++++++++++++++++++++++++++ hack/make/test-unit | 5 ++--- 3 files changed, 28 insertions(+), 28 deletions(-) create mode 100755 hack/make/.go-compile-test-dir diff --git a/hack/make.sh b/hack/make.sh index 0cfdda1cb5..d6da3057fa 100755 --- a/hack/make.sh +++ b/hack/make.sh @@ -169,31 +169,6 @@ go_test_dir() { ) } -# Compile phase run by parallel in test-unit. No support for coverpkg -go_compile_test_dir() { - dir=$1 - out_file="$DEST/precompiled/$dir.test" - testcover=() - if [ "$HAVE_GO_TEST_COVER" ]; then - # if our current go install has -cover, we want to use it :) - mkdir -p "$DEST/coverprofiles" - coverprofile="docker${dir#.}" - coverprofile="$DEST/coverprofiles/${coverprofile//\//-}" - testcover=( -cover -coverprofile "$coverprofile" ) # missing $coverpkg - fi - if [ "$BUILDFLAGS_FILE" ]; then - readarray -t BUILDFLAGS < "$BUILDFLAGS_FILE" - fi - ( - cd "$dir" - go test "${testcover[@]}" -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" $TESTFLAGS -c - ) - [ $? -ne 0 ] && return 1 - mkdir -p "$(dirname "$out_file")" - mv "$dir/$(basename "$dir").test" "$out_file" - echo "Precompiled: ${DOCKER_PKG}${dir#.}" -} - # This helper function walks the current directory looking for directories # holding certain files ($1 parameter), and prints their paths on standard # output, one per line. diff --git a/hack/make/.go-compile-test-dir b/hack/make/.go-compile-test-dir new file mode 100755 index 0000000000..0905f7d468 --- /dev/null +++ b/hack/make/.go-compile-test-dir @@ -0,0 +1,26 @@ +#!/bin/bash +set -e + +# Compile phase run by parallel in test-unit. No support for coverpkg + +dir=$1 +out_file="$DEST/precompiled/$dir.test" +testcover=() +if [ "$HAVE_GO_TEST_COVER" ]; then + # if our current go install has -cover, we want to use it :) + mkdir -p "$DEST/coverprofiles" + coverprofile="docker${dir#.}" + coverprofile="$DEST/coverprofiles/${coverprofile//\//-}" + testcover=( -cover -coverprofile "$coverprofile" ) # missing $coverpkg +fi +if [ "$BUILDFLAGS_FILE" ]; then + readarray -t BUILDFLAGS < "$BUILDFLAGS_FILE" +fi +( + cd "$dir" + go test "${testcover[@]}" -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" $TESTFLAGS -c +) +[ $? -ne 0 ] && return 1 +mkdir -p "$(dirname "$out_file")" +mv "$dir/$(basename "$dir").test" "$out_file" +echo "Precompiled: ${DOCKER_PKG}${dir#.}" diff --git a/hack/make/test-unit b/hack/make/test-unit index 3bac5920d1..5040e37d6b 100644 --- a/hack/make/test-unit +++ b/hack/make/test-unit @@ -29,7 +29,6 @@ bundle_test_unit() { export HOME="$(mktemp -d)" mkdir -p "$HOME/.parallel" touch "$HOME/.parallel/ignored_vars" - export -f go_compile_test_dir export LDFLAGS="$LDFLAGS $LDFLAGS_STATIC_DOCKER" export TESTFLAGS export HAVE_GO_TEST_COVER @@ -38,12 +37,12 @@ bundle_test_unit() { export BUILDFLAGS_FILE="$HOME/buildflags_file" ( IFS=$'\n'; echo "${BUILDFLAGS[*]}" ) > "$BUILDFLAGS_FILE" - echo "$TESTDIRS" | parallel --jobs "$PARALLEL_JOBS" --halt 2 --env _ go_compile_test_dir + echo "$TESTDIRS" | parallel --jobs "$PARALLEL_JOBS" --halt 2 --env _ "$(dirname "$BASH_SOURCE")/.go-compile-test-dir" rm -rf "$HOME" ) else # aww, no "parallel" available - fall back to boring for test_dir in $TESTDIRS; do - go_compile_test_dir "$test_dir" + "$(dirname "$BASH_SOURCE")/.go-compile-test-dir" "$test_dir" done fi echo "$TESTDIRS" | go_run_test_dir