From dad58737aea8ef4c6389cb118566fc06402fd635 Mon Sep 17 00:00:00 2001 From: Yohei Ueda Date: Fri, 7 Nov 2014 16:54:25 +0900 Subject: [PATCH] Export envvars necessary for unit-test Signed-off-by: Yohei Ueda --- hack/make/test-unit | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/hack/make/test-unit b/hack/make/test-unit index 0f19c54f62..910b887a8e 100644 --- a/hack/make/test-unit +++ b/hack/make/test-unit @@ -22,29 +22,31 @@ bundle_test_unit() { if [ -z "$TESTDIRS" ]; then TESTDIRS=$(find_dirs '*_test.go') fi - - if command -v parallel &> /dev/null; then ( - # accomodate parallel to be able to access variables - export SHELL="$BASH" - export HOME="$(mktemp -d)" - mkdir -p "$HOME/.parallel" - touch "$HOME/.parallel/ignored_vars" + ( export LDFLAGS="$LDFLAGS $LDFLAGS_STATIC_DOCKER" export TESTFLAGS export HAVE_GO_TEST_COVER export DEST - # some hack to export array variables - export BUILDFLAGS_FILE="$HOME/buildflags_file" - ( IFS=$'\n'; echo "${BUILDFLAGS[*]}" ) > "$BUILDFLAGS_FILE" + if command -v parallel &> /dev/null; then + # accomodate parallel to be able to access variables + export SHELL="$BASH" + export HOME="$(mktemp -d)" + mkdir -p "$HOME/.parallel" + touch "$HOME/.parallel/ignored_vars" - 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 - . "$(dirname "$BASH_SOURCE")/.go-compile-test-dir" "$test_dir" - done - fi + # some hack to export array variables + export BUILDFLAGS_FILE="$HOME/buildflags_file" + ( IFS=$'\n'; echo "${BUILDFLAGS[*]}" ) > "$BUILDFLAGS_FILE" + + 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 + "$(dirname "$BASH_SOURCE")/.go-compile-test-dir" "$test_dir" + done + fi + ) echo "$TESTDIRS" | go_run_test_dir } }