...

Text file src/cmd/go/testdata/script/cover_coverprofile_nocoverpkg.txt

Documentation: cmd/go/testdata/script

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

View as plain text