Signed-off-by: Andrew Page <admwiggin@gmail.com>
| ... | ... |
@@ -169,31 +169,6 @@ go_test_dir() {
|
| 169 | 169 |
) |
| 170 | 170 |
} |
| 171 | 171 |
|
| 172 |
-# Compile phase run by parallel in test-unit. No support for coverpkg |
|
| 173 |
-go_compile_test_dir() {
|
|
| 174 |
- dir=$1 |
|
| 175 |
- out_file="$DEST/precompiled/$dir.test" |
|
| 176 |
- testcover=() |
|
| 177 |
- if [ "$HAVE_GO_TEST_COVER" ]; then |
|
| 178 |
- # if our current go install has -cover, we want to use it :) |
|
| 179 |
- mkdir -p "$DEST/coverprofiles" |
|
| 180 |
- coverprofile="docker${dir#.}"
|
|
| 181 |
- coverprofile="$DEST/coverprofiles/${coverprofile//\//-}"
|
|
| 182 |
- testcover=( -cover -coverprofile "$coverprofile" ) # missing $coverpkg |
|
| 183 |
- fi |
|
| 184 |
- if [ "$BUILDFLAGS_FILE" ]; then |
|
| 185 |
- readarray -t BUILDFLAGS < "$BUILDFLAGS_FILE" |
|
| 186 |
- fi |
|
| 187 |
- ( |
|
| 188 |
- cd "$dir" |
|
| 189 |
- go test "${testcover[@]}" -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" $TESTFLAGS -c
|
|
| 190 |
- ) |
|
| 191 |
- [ $? -ne 0 ] && return 1 |
|
| 192 |
- mkdir -p "$(dirname "$out_file")" |
|
| 193 |
- mv "$dir/$(basename "$dir").test" "$out_file" |
|
| 194 |
- echo "Precompiled: ${DOCKER_PKG}${dir#.}"
|
|
| 195 |
-} |
|
| 196 |
- |
|
| 197 | 172 |
# This helper function walks the current directory looking for directories |
| 198 | 173 |
# holding certain files ($1 parameter), and prints their paths on standard |
| 199 | 174 |
# output, one per line. |
| 200 | 175 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,26 @@ |
| 0 |
+#!/bin/bash |
|
| 1 |
+set -e |
|
| 2 |
+ |
|
| 3 |
+# Compile phase run by parallel in test-unit. No support for coverpkg |
|
| 4 |
+ |
|
| 5 |
+dir=$1 |
|
| 6 |
+out_file="$DEST/precompiled/$dir.test" |
|
| 7 |
+testcover=() |
|
| 8 |
+if [ "$HAVE_GO_TEST_COVER" ]; then |
|
| 9 |
+ # if our current go install has -cover, we want to use it :) |
|
| 10 |
+ mkdir -p "$DEST/coverprofiles" |
|
| 11 |
+ coverprofile="docker${dir#.}"
|
|
| 12 |
+ coverprofile="$DEST/coverprofiles/${coverprofile//\//-}"
|
|
| 13 |
+ testcover=( -cover -coverprofile "$coverprofile" ) # missing $coverpkg |
|
| 14 |
+fi |
|
| 15 |
+if [ "$BUILDFLAGS_FILE" ]; then |
|
| 16 |
+ readarray -t BUILDFLAGS < "$BUILDFLAGS_FILE" |
|
| 17 |
+fi |
|
| 18 |
+( |
|
| 19 |
+ cd "$dir" |
|
| 20 |
+ go test "${testcover[@]}" -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" $TESTFLAGS -c
|
|
| 21 |
+) |
|
| 22 |
+[ $? -ne 0 ] && return 1 |
|
| 23 |
+mkdir -p "$(dirname "$out_file")" |
|
| 24 |
+mv "$dir/$(basename "$dir").test" "$out_file" |
|
| 25 |
+echo "Precompiled: ${DOCKER_PKG}${dir#.}"
|
| ... | ... |
@@ -29,7 +29,6 @@ bundle_test_unit() {
|
| 29 | 29 |
export HOME="$(mktemp -d)" |
| 30 | 30 |
mkdir -p "$HOME/.parallel" |
| 31 | 31 |
touch "$HOME/.parallel/ignored_vars" |
| 32 |
- export -f go_compile_test_dir |
|
| 33 | 32 |
export LDFLAGS="$LDFLAGS $LDFLAGS_STATIC_DOCKER" |
| 34 | 33 |
export TESTFLAGS |
| 35 | 34 |
export HAVE_GO_TEST_COVER |
| ... | ... |
@@ -38,12 +37,12 @@ bundle_test_unit() {
|
| 38 | 38 |
export BUILDFLAGS_FILE="$HOME/buildflags_file" |
| 39 | 39 |
( IFS=$'\n'; echo "${BUILDFLAGS[*]}" ) > "$BUILDFLAGS_FILE"
|
| 40 | 40 |
|
| 41 |
- echo "$TESTDIRS" | parallel --jobs "$PARALLEL_JOBS" --halt 2 --env _ go_compile_test_dir |
|
| 41 |
+ echo "$TESTDIRS" | parallel --jobs "$PARALLEL_JOBS" --halt 2 --env _ "$(dirname "$BASH_SOURCE")/.go-compile-test-dir" |
|
| 42 | 42 |
rm -rf "$HOME" |
| 43 | 43 |
) else |
| 44 | 44 |
# aww, no "parallel" available - fall back to boring |
| 45 | 45 |
for test_dir in $TESTDIRS; do |
| 46 |
- go_compile_test_dir "$test_dir" |
|
| 46 |
+ "$(dirname "$BASH_SOURCE")/.go-compile-test-dir" "$test_dir" |
|
| 47 | 47 |
done |
| 48 | 48 |
fi |
| 49 | 49 |
echo "$TESTDIRS" | go_run_test_dir |