Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7b7af6d

Browse files
committed
Merge pull request moby#8999 from yoheiueda/test-unit-without-parallel
Make test-unit runnable without parallel
2 parents 70a3f4e + dad5873 commit 7b7af6d

1 file changed

Lines changed: 20 additions & 18 deletions

File tree

hack/make/test-unit

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,31 @@ bundle_test_unit() {
2222
if [ -z "$TESTDIRS" ]; then
2323
TESTDIRS=$(find_dirs '*_test.go')
2424
fi
25-
26-
if command -v parallel &> /dev/null; then (
27-
# accomodate parallel to be able to access variables
28-
export SHELL="$BASH"
29-
export HOME="$(mktemp -d)"
30-
mkdir -p "$HOME/.parallel"
31-
touch "$HOME/.parallel/ignored_vars"
25+
(
3226
export LDFLAGS="$LDFLAGS $LDFLAGS_STATIC_DOCKER"
3327
export TESTFLAGS
3428
export HAVE_GO_TEST_COVER
3529
export DEST
36-
# some hack to export array variables
37-
export BUILDFLAGS_FILE="$HOME/buildflags_file"
38-
( IFS=$'\n'; echo "${BUILDFLAGS[*]}" ) > "$BUILDFLAGS_FILE"
30+
if command -v parallel &> /dev/null; then
31+
# accomodate parallel to be able to access variables
32+
export SHELL="$BASH"
33+
export HOME="$(mktemp -d)"
34+
mkdir -p "$HOME/.parallel"
35+
touch "$HOME/.parallel/ignored_vars"
3936

40-
echo "$TESTDIRS" | parallel --jobs "$PARALLEL_JOBS" --halt 2 --env _ "$(dirname "$BASH_SOURCE")/.go-compile-test-dir"
41-
rm -rf "$HOME"
42-
) else
43-
# aww, no "parallel" available - fall back to boring
44-
for test_dir in $TESTDIRS; do
45-
"$(dirname "$BASH_SOURCE")/.go-compile-test-dir" "$test_dir"
46-
done
47-
fi
37+
# some hack to export array variables
38+
export BUILDFLAGS_FILE="$HOME/buildflags_file"
39+
( IFS=$'\n'; echo "${BUILDFLAGS[*]}" ) > "$BUILDFLAGS_FILE"
40+
41+
echo "$TESTDIRS" | parallel --jobs "$PARALLEL_JOBS" --halt 2 --env _ "$(dirname "$BASH_SOURCE")/.go-compile-test-dir"
42+
rm -rf "$HOME"
43+
else
44+
# aww, no "parallel" available - fall back to boring
45+
for test_dir in $TESTDIRS; do
46+
"$(dirname "$BASH_SOURCE")/.go-compile-test-dir" "$test_dir"
47+
done
48+
fi
49+
)
4850
echo "$TESTDIRS" | go_run_test_dir
4951
}
5052
}

0 commit comments

Comments
 (0)