Skip to content

Commit

Permalink
internal/lsp/tests: remove ellipses from test names
Browse files Browse the repository at this point in the history
This change makes working with tests easier by trimming the folder name
up to "testdata". This will remove any ellipses from the test folder name.

Fixes golang/go#38103

Change-Id: I33b931e527de63713b8fc370c50b1c382796b2b8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/226377
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rohan Challa <rohan@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
  • Loading branch information
ridersofrohan committed Mar 30, 2020
1 parent 9c79f68 commit 31583a0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/lsp/cmd/cmd_test.go
Expand Up @@ -39,7 +39,7 @@ func testCommandLine(t *testing.T, exporter packagestest.Exporter) {
data := tests.Load(t, exporter, "../testdata")
for _, datum := range data {
defer datum.Exported.Cleanup()
t.Run(datum.Folder, func(t *testing.T) {
t.Run(tests.FormatFolderName(datum.Folder), func(t *testing.T) {
t.Helper()
tests.Run(t, cmdtest.NewRunner(exporter, datum, ctx, ts.Addr, nil), datum)
})
Expand Down
2 changes: 1 addition & 1 deletion internal/lsp/lsp_test.go
Expand Up @@ -89,7 +89,7 @@ func testLSP(t *testing.T, exporter packagestest.Exporter) {
data: datum,
ctx: ctx,
}
t.Run(datum.Folder, func(t *testing.T) {
t.Run(tests.FormatFolderName(datum.Folder), func(t *testing.T) {
t.Helper()
tests.Run(t, r, datum)
})
Expand Down
2 changes: 1 addition & 1 deletion internal/lsp/source/source_test.go
Expand Up @@ -77,7 +77,7 @@ func testSource(t *testing.T, exporter packagestest.Exporter) {
if _, err := session.DidModifyFiles(ctx, modifications); err != nil {
t.Fatal(err)
}
t.Run(datum.Folder, func(t *testing.T) {
t.Run(tests.FormatFolderName(datum.Folder), func(t *testing.T) {
t.Helper()
tests.Run(t, r, datum)
})
Expand Down
7 changes: 7 additions & 0 deletions internal/lsp/tests/util.go
Expand Up @@ -496,3 +496,10 @@ func summarizeCompletionItems(i int, want, got []protocol.CompletionItem, reason
}
return msg.String()
}

func FormatFolderName(folder string) string {
if index := strings.Index(folder, "testdata"); index != -1 {
return folder[index:]
}
return folder
}

0 comments on commit 31583a0

Please sign in to comment.