Skip to content

Commit d08f5dc

Browse files
committed
gopls/internal/regtest: unskip all of TestModFileModification
I believe the races described in the issue have been fixed: we should invalidate mod tidy results on any metadata change. If this invalidation doesn't work due to a race, we want to know about it. Update the test to wait for file-related events to complete before removing files, in an attempt to avoid windows file-locking issues. For golang/go#40269 For golang/go#53878 Change-Id: I91f0cb4969851010b34904a0b78ab9bd2808f92e Reviewed-on: https://go-review.googlesource.com/c/tools/+/420718 Run-TryBot: Robert Findley <[email protected]> gopls-CI: kokoro <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Suzy Mueller <[email protected]>
1 parent ddb90ec commit d08f5dc

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

gopls/internal/regtest/modfile/modfile_test.go

+26-6
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ func main() {
9595
goModContent := env.ReadWorkspaceFile("a/go.mod")
9696
env.OpenFile("a/main.go")
9797
env.Await(
98-
env.DiagnosticAtRegexp("a/main.go", "\"example.com/blah\""),
98+
OnceMet(
99+
env.DoneWithOpen(),
100+
env.DiagnosticAtRegexp("a/main.go", "\"example.com/blah\""),
101+
),
99102
)
100103
if got := env.ReadWorkspaceFile("a/go.mod"); got != goModContent {
101104
t.Fatalf("go.mod changed on disk:\n%s", tests.Diff(t, goModContent, got))
@@ -114,26 +117,43 @@ func main() {
114117

115118
// Reproduce golang/go#40269 by deleting and recreating main.go.
116119
t.Run("delete main.go", func(t *testing.T) {
117-
t.Skip("This test will be flaky until golang/go#40269 is resolved.")
118-
119120
runner.Run(t, untidyModule, func(t *testing.T, env *Env) {
120121
goModContent := env.ReadWorkspaceFile("a/go.mod")
121122
mainContent := env.ReadWorkspaceFile("a/main.go")
122123
env.OpenFile("a/main.go")
123124
env.SaveBuffer("a/main.go")
124125

126+
// Ensure that we're done processing all the changes caused by opening
127+
// and saving above. If not, we may run into a file locking issue on
128+
// windows.
129+
//
130+
// If this proves insufficient, env.RemoveWorkspaceFile can be updated to
131+
// retry file lock errors on windows.
132+
env.Await(
133+
env.DoneWithOpen(),
134+
env.DoneWithSave(),
135+
env.DoneWithChangeWatchedFiles(),
136+
)
125137
env.RemoveWorkspaceFile("a/main.go")
138+
139+
// TODO(rfindley): awaiting here shouldn't really be necessary. We should
140+
// be consistent eventually.
141+
//
142+
// Probably this was meant to exercise a race with the change below.
126143
env.Await(
127144
env.DoneWithOpen(),
128145
env.DoneWithSave(),
129146
env.DoneWithChangeWatchedFiles(),
130147
)
131148

132-
env.WriteWorkspaceFile("main.go", mainContent)
149+
env.WriteWorkspaceFile("a/main.go", mainContent)
133150
env.Await(
134-
env.DiagnosticAtRegexp("main.go", "\"example.com/blah\""),
151+
OnceMet(
152+
env.DoneWithChangeWatchedFiles(),
153+
env.DiagnosticAtRegexp("a/main.go", "\"example.com/blah\""),
154+
),
135155
)
136-
if got := env.ReadWorkspaceFile("go.mod"); got != goModContent {
156+
if got := env.ReadWorkspaceFile("a/go.mod"); got != goModContent {
137157
t.Fatalf("go.mod changed on disk:\n%s", tests.Diff(t, goModContent, got))
138158
}
139159
})

0 commit comments

Comments
 (0)