Skip to content

Commit

Permalink
Merge pull request moby#8999 from yoheiueda/test-unit-without-parallel
Browse files Browse the repository at this point in the history
Make test-unit runnable without parallel
  • Loading branch information
unclejack committed Nov 14, 2014
2 parents 70a3f4e + dad5873 commit 7b7af6d
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions hack/make/test-unit
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit 7b7af6d

Please sign in to comment.