File tree 2 files changed +40
-0
lines changed 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,21 @@ SCRATCH_FILE=${COVERFILE}.tmp
13
13
14
14
echo " mode: ${COVERMODE} " > $SCRATCH_FILE
15
15
16
+ # go1.10 has an open bug for coverage reports that requires a *terrible* hack
17
+ # to workaround. See https://github.com/golang/go/issues/23883 for more details
18
+ GO_MINOR_VERSION=$( go version | awk ' {print $3}' | cut -d ' .' -f 2)
19
+ if [ ${GO_MINOR_VERSION} -ge 10 ]; # i.e. we're on go1.10 and up
20
+ then
21
+ echo " Generating dummy integration file with all the packages listed for coverage"
22
+ DUMMY_FILE_PATH=./integration/coverage_imports.go
23
+ if [ -f ${DUMMY_FILE_PATH} ]; then
24
+ rm -f ${DUMMY_FILE_PATH} # delete file if it exists (only happens when running on a laptop)
25
+ fi
26
+ # NB: need to do this in two steps or the go compiler compiles the partial file and is :(
27
+ generate_dummy_coverage_file integration integration > coverage_imports_file.out
28
+ mv coverage_imports_file.out ${DUMMY_FILE_PATH}
29
+ fi
30
+
16
31
# compile the integration test binary
17
32
go test -test.c -test.tags=${TAGS} -test.covermode ${COVERMODE} \
18
33
-test.coverpkg $( go list ./... | grep -v /vendor/ | paste -sd, -) ./${DIR}
Original file line number Diff line number Diff line change @@ -26,3 +26,28 @@ filter_cover_profile() {
26
26
}
27
27
28
28
export -f filter_cover_profile
29
+
30
+ # go1.10 has an open bug for coverage reports that requires a *terrible* hack
31
+ # to workaround. See https://github.com/golang/go/issues/23883 for more details
32
+ function generate_dummy_coverage_file() {
33
+ local package_name=$1
34
+ local build_tag=$2
35
+ go list ./... | grep -v vendor | grep -v " \/${package_name} " > repo_packages.out
36
+ INPUT_FILE=./repo_packages.out python << END
37
+ import os
38
+ input_file_path = os.environ['INPUT_FILE']
39
+ input_file = open(input_file_path)
40
+ print '// +build ${build_tag} '
41
+ print
42
+ print 'package ${package_name} '
43
+ print
44
+ print 'import ('
45
+ for line in input_file.readlines():
46
+ line = line.strip()
47
+ print '\t _ "%s"' % line
48
+ print ')'
49
+ print
50
+ END
51
+ }
52
+
53
+ export -f generate_dummy_coverage_file
You can’t perform that action at this time.
0 commit comments