mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #8274 from tianon/parallel-shellshock
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
This commit is contained in:
commit
27c5269b4e
3 changed files with 28 additions and 28 deletions
25
hack/make.sh
25
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
|
# This helper function walks the current directory looking for directories
|
||||||
# holding certain files ($1 parameter), and prints their paths on standard
|
# holding certain files ($1 parameter), and prints their paths on standard
|
||||||
# output, one per line.
|
# output, one per line.
|
||||||
|
|
26
hack/make/.go-compile-test-dir
Executable file
26
hack/make/.go-compile-test-dir
Executable file
|
@ -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#.}"
|
|
@ -29,7 +29,6 @@ bundle_test_unit() {
|
||||||
export HOME="$(mktemp -d)"
|
export HOME="$(mktemp -d)"
|
||||||
mkdir -p "$HOME/.parallel"
|
mkdir -p "$HOME/.parallel"
|
||||||
touch "$HOME/.parallel/ignored_vars"
|
touch "$HOME/.parallel/ignored_vars"
|
||||||
export -f go_compile_test_dir
|
|
||||||
export LDFLAGS="$LDFLAGS $LDFLAGS_STATIC_DOCKER"
|
export LDFLAGS="$LDFLAGS $LDFLAGS_STATIC_DOCKER"
|
||||||
export TESTFLAGS
|
export TESTFLAGS
|
||||||
export HAVE_GO_TEST_COVER
|
export HAVE_GO_TEST_COVER
|
||||||
|
@ -38,12 +37,12 @@ bundle_test_unit() {
|
||||||
export BUILDFLAGS_FILE="$HOME/buildflags_file"
|
export BUILDFLAGS_FILE="$HOME/buildflags_file"
|
||||||
( IFS=$'\n'; echo "${BUILDFLAGS[*]}" ) > "$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"
|
rm -rf "$HOME"
|
||||||
) else
|
) else
|
||||||
# aww, no "parallel" available - fall back to boring
|
# aww, no "parallel" available - fall back to boring
|
||||||
for test_dir in $TESTDIRS; do
|
for test_dir in $TESTDIRS; do
|
||||||
go_compile_test_dir "$test_dir"
|
"$(dirname "$BASH_SOURCE")/.go-compile-test-dir" "$test_dir"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
echo "$TESTDIRS" | go_run_test_dir
|
echo "$TESTDIRS" | go_run_test_dir
|
||||||
|
|
Loading…
Add table
Reference in a new issue