|
@@ -2,11 +2,11 @@
|
|
|
set -e
|
|
|
|
|
|
DEST=$1
|
|
|
+: ${PARALLEL_JOBS:=$(nproc)}
|
|
|
|
|
|
RED=$'\033[31m'
|
|
|
GREEN=$'\033[32m'
|
|
|
TEXTRESET=$'\033[0m' # reset the foreground colour
|
|
|
-: ${PARALLEL_JOBS:=0}
|
|
|
|
|
|
# Run Docker's test suite, including sub-packages, and store their output as a bundle
|
|
|
# If $TESTFLAGS is set in the environment, it is passed as extra arguments to 'go test'.
|
|
@@ -23,10 +23,10 @@ bundle_test_unit() {
|
|
|
TESTDIRS=$(find_dirs '*_test.go')
|
|
|
fi
|
|
|
|
|
|
- (
|
|
|
+ if command -v parallel &> /dev/null; then (
|
|
|
# accomodate parallel to be able to access variables
|
|
|
- export SHELL=/bin/bash
|
|
|
- export HOME=/tmp
|
|
|
+ export SHELL="$BASH"
|
|
|
+ export HOME="$(mktemp -d)"
|
|
|
mkdir -p "$HOME/.parallel"
|
|
|
touch "$HOME/.parallel/ignored_vars"
|
|
|
export -f go_compile_test_dir
|
|
@@ -38,8 +38,15 @@ bundle_test_unit() {
|
|
|
export BUILDFLAGS_FILE="$HOME/buildflags_file"
|
|
|
( IFS=$'\n'; echo "${BUILDFLAGS[*]}" ) > "$BUILDFLAGS_FILE"
|
|
|
|
|
|
- echo "$TESTDIRS" | parallel --jobs "$PARALLEL_JOBS" --env _ go_compile_test_dir | go_run_test_dir
|
|
|
- )
|
|
|
+ echo "$TESTDIRS" | parallel --jobs "$PARALLEL_JOBS" --env _ 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"
|
|
|
+ done
|
|
|
+ fi
|
|
|
+ echo "$TESTDIRS" | go_run_test_dir
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -48,16 +55,13 @@ go_run_test_dir() {
|
|
|
while read dir; do
|
|
|
echo
|
|
|
echo '+ go test' $TESTFLAGS "github.com/dotcloud/docker${dir#.}"
|
|
|
- pushd "$dir" > /dev/null
|
|
|
- t=$(basename "$dir").test
|
|
|
- if ! ./$t; then
|
|
|
+ precompiled="$DEST/precompiled/$dir.test"
|
|
|
+ if ! "$precompiled"; then
|
|
|
TESTS_FAILED+=("$dir")
|
|
|
echo
|
|
|
echo "${RED}Tests failed: $dir${TEXTRESET}"
|
|
|
sleep 1 # give it a second, so observers watching can take note
|
|
|
fi
|
|
|
- rm ./$t || true
|
|
|
- popd > /dev/null
|
|
|
done
|
|
|
|
|
|
echo
|