Skip to content

Commit 063c264

Browse files
committed
gopls/test/integration/misc: add diagnostics to flaky test
watchflakes reports that TestGOMODCACHE is flaky, presumably because somehow the module cache index does not get written in time. This CL adds logging information to help diagnose the failure. Fixes: golang/go#77894 Change-Id: I03e6d9c9187c93ecb3c152d843649b1a789877a4 Reviewed-on: https://go-review.googlesource.com/c/tools/+/753120 TryBot-Bypass: Peter Weinberger <pjw@google.com> Reviewed-by: Madeline Kalil <mkalil@google.com>
1 parent deb6130 commit 063c264

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

gopls/internal/test/integration/misc/imports_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,24 @@ var _, _ = x.X, y.Y
255255

256256
// Apply suggested fix via OrganizeImports.
257257
env.SaveBuffer("main.go") // => OrganizeImports
258+
if true {
259+
// according to https://github.com/golang/go/issues/77894
260+
// this test is flaky. Print some possibly helpful diagnostic
261+
// information.
262+
ix, err := modindex.Read(modcache)
263+
if err != nil {
264+
t.Logf("could not read modcache index: %v", err)
265+
} else if len(ix.Entries) != 2 {
266+
t.Logf("%d modcache entries", len(ix.Entries))
267+
if len(ix.Entries) == 0 {
268+
fis, err := os.ReadDir(modcache)
269+
if err != nil {
270+
t.Logf("could not read modcache dir: %v", err)
271+
}
272+
t.Logf("%d modcache files", len(fis))
273+
}
274+
}
275+
}
258276
env.AfterChange(NoDiagnostics(ForFile("main.go")))
259277

260278
// Verify that y.Y is defined within the module cache.

0 commit comments

Comments
 (0)