Text file
src/cmd/go/testdata/script/cover_coverprofile_nocoverpkg.txt
1 # Testcase for #70244. In this bug we're doing a "go test -coverprofile"
2 # run for a pair of packages, the first one without tests and the second
3 # one with tests. When writing the profile for the second test, profile
4 # data from the first package was leaking into the output (we should
5 # only see lines in the output profile for the package whose test is
6 # being run).
7
8 # Kick off test.
9 go test -vet=off -count=1 -coverprofile=cov.p ./...
10
11 # Generate a function profile.
12 go tool cover -func=cov.p
13
14 stdout 'cov/pkg1/file.go:3:\s+DoSomething\s+0.0%'
15
16 -- go.mod --
17 module cov
18
19 -- pkg1/file.go --
20 package pkg1
21
22 func DoSomething() bool {
23 return true
24 }
25 -- pkg2/file.go --
26 package pkg2
27
28 func DoSomething() bool {
29 return true
30 }
31 -- pkg2/file_test.go --
32 package pkg2
33
34 import (
35 "cov/pkg1"
36 "testing"
37 )
38
39 func TestSmth(t *testing.T) {
40 pkg1.DoSomething()
41 DoSomething()
42 }
43
View as plain text