Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal/cpu: test is unfriendly to code coverage ("-cover") #52761

Closed
thanm opened this issue May 7, 2022 · 1 comment
Closed

internal/cpu: test is unfriendly to code coverage ("-cover") #52761

thanm opened this issue May 7, 2022 · 1 comment
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@thanm
Copy link
Contributor

thanm commented May 7, 2022

What version of Go are you using (go version)?

$ go version
go version devel go1.19-4e79f06dac Fri May 6 22:04:35 2022 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes. It's been around for a couple of releases.

What operating system and processor architecture are you using (go env)?

linux/amd64

What did you do?

$ cd `go env GOROOT`/src/internal/cpu
$ go test -cover

What did you expect to see?

Passing test with coverage:

PASS
coverage: 41.7% of statements
ok  	internal/cpu	0.034s
thanm@cetina:/ssd2/go/src/internal/cpu$ 

What did you see instead?

$ go test -cover
--- FAIL: TestDisableAllCapabilities (0.01s)
    cpu_test.go:44: TestAllCapabilitiesDisabled with GODEBUG=cpu.all=off: want PASS, got statements
--- FAIL: TestDisableSSE3 (0.01s)
    cpu_test.go:44: TestSSE3DebugOption with GODEBUG=cpu.sse3=off: want PASS, got statements
FAIL
coverage: 41.7% of statements
exit status 1
FAIL	internal/cpu	0.036s
$

What's happening here is that the test is invoking itself (cmd.Exec on os.Argv[0]) and then expecting to see a single "PASS" result instead of PASS + code coverage.

@thanm thanm self-assigned this May 7, 2022
@thanm thanm added the NeedsFix The path to resolution is known, but the work has not been done. label May 7, 2022
@thanm thanm added this to the Go1.19 milestone May 7, 2022
@gopherbot
Copy link

Change https://go.dev/cl/404715 mentions this issue: internal/cpu: revise test to make it work properly with -cover

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

2 participants