.go-compile-test-dir 972 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/bash
  2. set -e
  3. # Compile phase run by parallel in test-unit. No support for coverpkg
  4. dir=$1
  5. in_file="$dir/$(basename "$dir").test"
  6. out_file="$DEST/precompiled/$dir.test"
  7. # we want to use binary_extension() here, but we can't because it's in main.sh and this file gets re-execed
  8. if [ "$(go env GOOS)" = 'windows' ]; then
  9. in_file+='.exe'
  10. out_file+='.exe'
  11. fi
  12. testcover=()
  13. if [ "$HAVE_GO_TEST_COVER" ]; then
  14. # if our current go install has -cover, we want to use it :)
  15. mkdir -p "$DEST/coverprofiles"
  16. coverprofile="docker${dir#.}"
  17. coverprofile="$DEST/coverprofiles/${coverprofile//\//-}"
  18. testcover=( -cover -coverprofile "$coverprofile" ) # missing $coverpkg
  19. fi
  20. if [ "$BUILDFLAGS_FILE" ]; then
  21. readarray -t BUILDFLAGS < "$BUILDFLAGS_FILE"
  22. fi
  23. if ! (
  24. cd "$dir"
  25. go test "${testcover[@]}" -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" $TESTFLAGS -c
  26. ); then
  27. exit 1
  28. fi
  29. mkdir -p "$(dirname "$out_file")"
  30. mv "$in_file" "$out_file"
  31. echo "Precompiled: ${DOCKER_PKG}${dir#.}"