Skip to content

Commit

Permalink
gopls/coverage: repair coverage.go
Browse files Browse the repository at this point in the history
Coverage.go computes the test coverage from running all the gopls tests.

This CL accounts for the changed source tree (internal/lsp is gone)
and new actions returned by go test -json ('pause' and 'cont').

Change-Id: I970b3ec107746ce02e3dcdcad9f8c19cffad8d11
Reviewed-on: https://go-review.googlesource.com/c/tools/+/448295
Run-TryBot: Peter Weinberger <pjw@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
  • Loading branch information
pjweinbgo committed Nov 7, 2022
1 parent 8e0240a commit 88a3548
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions gopls/internal/coverage/coverage.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,12 @@ func maybePrint(m result) {
if *verbose > 3 {
fmt.Printf("%s %s %q %.3f\n", m.Action, m.Test, m.Output, m.Elapsed)
}
case "pause", "cont":
if *verbose > 2 {
fmt.Printf("%s %s %.3f\n", m.Action, m.Test, m.Elapsed)
}
default:
fmt.Printf("%#v\n", m)
log.Fatalf("unknown action %s\n", m.Action)
}
}
Expand Down Expand Up @@ -228,7 +233,7 @@ func checkCwd() {
if err != nil {
log.Fatal(err)
}
// we expect to be a the root of golang.org/x/tools
// we expect to be at the root of golang.org/x/tools
cmd := exec.Command("go", "list", "-m", "-f", "{{.Dir}}", "golang.org/x/tools")
buf, err := cmd.Output()
buf = bytes.Trim(buf, "\n \t") // remove \n at end
Expand All @@ -243,10 +248,6 @@ func checkCwd() {
if err != nil {
log.Fatalf("expected a gopls directory, %v", err)
}
_, err = os.Stat("internal/lsp")
if err != nil {
log.Fatalf("expected to see internal/lsp, %v", err)
}
}

func listDirs(dir string) []string {
Expand Down

0 comments on commit 88a3548

Please sign in to comment.