github.com/vieux/docker@v0.6.3-0.20161004191708-e097c2a938c7/hack/make/test-unit (about)

     1  #!/bin/bash
     2  set -e
     3  
     4  # Run Docker's test suite, including sub-packages, and store their output as a bundle
     5  # If $TESTFLAGS is set in the environment, it is passed as extra arguments to 'go test'.
     6  # You can use this to select certain tests to run, e.g.
     7  #
     8  #   TESTFLAGS='-test.run ^TestBuild$' ./hack/make.sh test-unit
     9  #
    10  bundle_test_unit() {
    11  	TESTFLAGS+=" -test.timeout=${TIMEOUT}"
    12  	INCBUILD="-i"
    13  	count=0
    14  	for flag in "${BUILDFLAGS[@]}"; do
    15  		if [ "${flag}" == ${INCBUILD} ]; then
    16  			unset BUILDFLAGS[${count}]
    17  			break
    18  		fi
    19  		count=$[ ${count} + 1 ]
    20  	done
    21  
    22  	date
    23  	if [ -z "$TESTDIRS" ]; then
    24  		TEST_PATH=./...
    25  	else
    26  		TEST_PATH=./${TESTDIRS}
    27  	fi
    28  	pkg_list=$(go list -e \
    29  		-f '{{if ne .Name "github.com/docker/docker"}}
    30  			{{.ImportPath}}
    31  		    {{end}}' \
    32  		"${BUILDFLAGS[@]}" $TEST_PATH \
    33  		| grep github.com/docker/docker \
    34  		| grep -v github.com/docker/docker/vendor \
    35  		| grep -v github.com/docker/docker/man \
    36  		| grep -v github.com/docker/docker/integration-cli)
    37  	go test -cover -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" $TESTFLAGS $pkg_list
    38  }
    39  
    40  bundle_test_unit 2>&1 | tee -a "$DEST/test.log"