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  [short] skip
     9  
    10  # Kick off test.
    11  go test -vet=off -count=1 -coverprofile=cov.p ./...
    12  
    13  # Generate a function profile.
    14  go tool cover -func=cov.p
    15  
    16  stdout 'cov/pkg1/file.go:3:\s+DoSomething\s+0.0%'
    17  
    18  -- go.mod --
    19  module cov
    20  
    21  -- pkg1/file.go --
    22  package pkg1
    23  
    24  func DoSomething() bool {
    25  	return true
    26  }
    27  -- pkg2/file.go --
    28  package pkg2
    29  
    30  func DoSomething() bool {
    31  	return true
    32  }
    33  -- pkg2/file_test.go --
    34  package pkg2
    35  
    36  import (
    37  	"cov/pkg1"
    38  	"testing"
    39  )
    40  
    41  func TestSmth(t *testing.T) {
    42  	pkg1.DoSomething()
    43  	DoSomething()
    44  }
    45  

View as plain text