Skip to content

Commit

Permalink
internal/cpu: revise test to make it work properly with -cover
Browse files Browse the repository at this point in the history
Fix up a test to insure that it does the right thing when
"go test -cover" is in effect.

Fixes #52761.

Change-Id: I0c141181e2dcaefd592fb04813f812f2800511da
Reviewed-on: https://go-review.googlesource.com/c/go/+/404715
Run-TryBot: Than McIntosh <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Keith Randall <[email protected]>
Reviewed-by: Keith Randall <[email protected]>
  • Loading branch information
thanm committed May 9, 2022
1 parent 7ca1e2a commit c4311a4
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/internal/cpu/cpu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"internal/testenv"
"os"
"os/exec"
"strings"
"testing"
)

Expand All @@ -35,13 +34,9 @@ func runDebugOptionsTest(t *testing.T, test string, options string) {
cmd.Env = append(cmd.Env, env)

output, err := cmd.CombinedOutput()
lines := strings.Fields(string(output))
lastline := lines[len(lines)-1]

got := strings.TrimSpace(lastline)
want := "PASS"
if err != nil || got != want {
t.Fatalf("%s with %s: want %s, got %v", test, env, want, got)
if err != nil {
t.Fatalf("%s with %s: run failed: %v output:\n%s\n",
test, env, err, string(output))
}
}

Expand Down

0 comments on commit c4311a4

Please sign in to comment.