github.com/raychaser/docker@v1.5.0/project/make/.go-compile-test-dir (about)

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