github.com/shiroyuki/docker@v1.9.0/hack/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 [[ "$(go version)" =~ "gccgo" ]]; then
    27  	GCCGOFLAGS="-gccgoflags= -lpthread -ldl "
    28  fi
    29  
    30  if ! (
    31  	cd "$dir"
    32  	go test "${testcover[@]}" "$GCCGOFLAGS" -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" $TESTFLAGS -c 
    33  ); then
    34  	exit 1
    35  fi
    36  
    37  mkdir -p "$(dirname "$out_file")"
    38  mv "$in_file" "$out_file"
    39  echo "Precompiled: ${DOCKER_PKG}${dir#.}"