2014-09-28 23:48:57 -04:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Compile phase run by parallel in test-unit. No support for coverpkg
|
|
|
|
|
|
|
|
dir=$1
|
2015-01-09 19:28:40 -05:00
|
|
|
in_file="$dir/$(basename "$dir").test"
|
2014-09-28 23:48:57 -04:00
|
|
|
out_file="$DEST/precompiled/$dir.test"
|
2015-01-09 19:28:40 -05:00
|
|
|
# we want to use binary_extension() here, but we can't because it's in main.sh and this file gets re-execed
|
|
|
|
if [ "$(go env GOOS)" = 'windows' ]; then
|
|
|
|
in_file+='.exe'
|
|
|
|
out_file+='.exe'
|
|
|
|
fi
|
2014-09-28 23:48:57 -04:00
|
|
|
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
|
2015-01-09 19:28:40 -05:00
|
|
|
|
|
|
|
if ! (
|
2014-09-28 23:48:57 -04:00
|
|
|
cd "$dir"
|
|
|
|
go test "${testcover[@]}" -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" $TESTFLAGS -c
|
2015-01-09 19:28:40 -05:00
|
|
|
); then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2014-09-28 23:48:57 -04:00
|
|
|
mkdir -p "$(dirname "$out_file")"
|
2015-01-09 19:28:40 -05:00
|
|
|
mv "$in_file" "$out_file"
|
2014-09-28 23:48:57 -04:00
|
|
|
echo "Precompiled: ${DOCKER_PKG}${dir#.}"
|