Skip to content

Commit

Permalink
internal/regtest/misc: fail eagerly in TestRenameFileFromEditor
Browse files Browse the repository at this point in the history
Updates golang/go#55324

Change-Id: I07cb5465afc7f9e76cad96cb5fbe55e6e16a73b7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/461416
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
  • Loading branch information
findleyr committed Jan 11, 2023
1 parent 43158af commit 227ee72
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions gopls/internal/regtest/misc/rename_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,30 +413,24 @@ package b

// Moving x.go should make the diagnostic go away.
env.RenameFile("a/x.go", "b/x.go")
env.Await(
OnceMet(
env.DoneWithChangeWatchedFiles(),
EmptyDiagnostics("a/a.go"), // no more duplicate declarations
env.DiagnosticAtRegexp("b/b.go", "package"), // as package names mismatch
),
env.AfterChange(
EmptyDiagnostics("a/a.go"), // no more duplicate declarations
env.DiagnosticAtRegexp("b/b.go", "package"), // as package names mismatch
)

// Renaming should also work on open buffers.
env.OpenFile("b/x.go")

// Moving x.go back to a/ should cause the diagnostics to reappear.
env.RenameFile("b/x.go", "a/x.go")
// TODO(rfindley): enable using a OnceMet precondition here. We can't
// currently do this because DidClose, DidOpen and DidChangeWatchedFiles
// are sent, and it is not easy to use all as a precondition.
env.Await(
env.AfterChange(
env.DiagnosticAtRegexp("a/a.go", "X"),
env.DiagnosticAtRegexp("a/x.go", "X"),
)

// Renaming the entire directory should move both the open and closed file.
env.RenameFile("a", "x")
env.Await(
env.AfterChange(
env.DiagnosticAtRegexp("x/a.go", "X"),
env.DiagnosticAtRegexp("x/x.go", "X"),
)
Expand Down

0 comments on commit 227ee72

Please sign in to comment.