Skip to content

Commit 79cde82

Browse files
findleyrgopherbot
authored andcommitted
gopls/internal/protocol/command: remove the redundant gopls.test command
As discussed in golang/go#67920, this command is no longer necessary. Remove it, since it does not follow our pattern for command arguments. Fixes golang/go#67920 Change-Id: Ia87535e333a35912247ff37f7a6dfb65f11f0745 Reviewed-on: https://go-review.googlesource.com/c/tools/+/642616 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Alan Donovan <[email protected]> Auto-Submit: Alan Donovan <[email protected]>
1 parent 7d99ad7 commit 79cde82

File tree

8 files changed

+24
-50
lines changed

8 files changed

+24
-50
lines changed

gopls/internal/cmd/codelens.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ Example:
4444
4545
$ gopls codelens a_test.go # list code lenses in a file
4646
$ gopls codelens a_test.go:10 # list code lenses on line 10
47-
$ gopls codelens a_test.go gopls.test # list gopls.test commands
48-
$ gopls codelens -exec a_test.go:10 gopls.test # run a specific test
47+
$ gopls codelens a_test.go "run test" # list gopls.run_tests commands
48+
$ gopls codelens -exec a_test.go:10 "run test" # run a specific test
4949
5050
codelens-flags:
5151
`)

gopls/internal/cmd/integration_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ func TestFail(t *testing.T) { t.Fatal("fail") }
213213
{
214214
res := gopls(t, tree, "codelens", "./a/a_test.go")
215215
res.checkExit(true)
216-
res.checkStdout(`a_test.go:3: "run test" \[gopls.test\]`)
217-
res.checkStdout(`a_test.go:4: "run test" \[gopls.test\]`)
216+
res.checkStdout(`a_test.go:3: "run test" \[gopls.run_tests\]`)
217+
res.checkStdout(`a_test.go:4: "run test" \[gopls.run_tests\]`)
218218
}
219219
// no codelens with title/position
220220
{

gopls/internal/cmd/usage/codelens.hlp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ Example:
1919

2020
$ gopls codelens a_test.go # list code lenses in a file
2121
$ gopls codelens a_test.go:10 # list code lenses on line 10
22-
$ gopls codelens a_test.go gopls.test # list gopls.test commands
23-
$ gopls codelens -exec a_test.go:10 gopls.test # run a specific test
22+
$ gopls codelens a_test.go "run test" # list gopls.run_tests commands
23+
$ gopls codelens -exec a_test.go:10 "run test" # run a specific test
2424

2525
codelens-flags:
2626
-d,-diff

gopls/internal/golang/code_lens.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,19 @@ func runTestCodeLens(ctx context.Context, snapshot *cache.Snapshot, fh file.Hand
4747
}
4848
puri := fh.URI()
4949
for _, fn := range testFuncs {
50-
cmd := command.NewTestCommand("run test", puri, []string{fn.name}, nil)
50+
cmd := command.NewRunTestsCommand("run test", command.RunTestsArgs{
51+
URI: puri,
52+
Tests: []string{fn.name},
53+
})
5154
rng := protocol.Range{Start: fn.rng.Start, End: fn.rng.Start}
5255
codeLens = append(codeLens, protocol.CodeLens{Range: rng, Command: cmd})
5356
}
5457

5558
for _, fn := range benchFuncs {
56-
cmd := command.NewTestCommand("run benchmark", puri, nil, []string{fn.name})
59+
cmd := command.NewRunTestsCommand("run benchmark", command.RunTestsArgs{
60+
URI: puri,
61+
Benchmarks: []string{fn.name},
62+
})
5763
rng := protocol.Range{Start: fn.rng.Start, End: fn.rng.Start}
5864
codeLens = append(codeLens, protocol.CodeLens{Range: rng, Command: cmd})
5965
}
@@ -72,7 +78,10 @@ func runTestCodeLens(ctx context.Context, snapshot *cache.Snapshot, fh file.Hand
7278
for _, fn := range benchFuncs {
7379
benches = append(benches, fn.name)
7480
}
75-
cmd := command.NewTestCommand("run file benchmarks", puri, nil, benches)
81+
cmd := command.NewRunTestsCommand("run file benchmarks", command.RunTestsArgs{
82+
URI: puri,
83+
Benchmarks: benches,
84+
})
7685
codeLens = append(codeLens, protocol.CodeLens{Range: rng, Command: cmd})
7786
}
7887
return codeLens, nil

gopls/internal/golang/codeaction.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,11 @@ func goTest(ctx context.Context, req *codeActionsRequest) error {
803803
return nil
804804
}
805805

806-
cmd := command.NewTestCommand("Run tests and benchmarks", req.loc.URI, tests, benchmarks)
806+
cmd := command.NewRunTestsCommand("Run tests and benchmarks", command.RunTestsArgs{
807+
URI: req.loc.URI,
808+
Tests: tests,
809+
Benchmarks: benchmarks,
810+
})
807811
req.addCommandAction(cmd, false)
808812
return nil
809813
}

gopls/internal/protocol/command/command_gen.go

Lines changed: 0 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gopls/internal/protocol/command/interface.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,7 @@ type Interface interface {
4747
// Applies a fix to a region of source code.
4848
ApplyFix(context.Context, ApplyFixArgs) (*protocol.WorkspaceEdit, error)
4949

50-
// Test: Run test(s) (legacy)
51-
//
52-
// Runs `go test` for a specific set of test or benchmark functions.
53-
//
54-
// This command is asynchronous; wait for the 'end' progress notification.
55-
//
56-
// This command is an alias for RunTests; the only difference
57-
// is the form of the parameters.
58-
//
59-
// TODO(adonovan): eliminate it.
60-
Test(context.Context, protocol.DocumentURI, []string, []string) error
61-
62-
// Test: Run test(s)
50+
// RunTests: Run tests
6351
//
6452
// Runs `go test` for a specific set of test or benchmark functions.
6553
//

gopls/internal/server/command.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -683,15 +683,6 @@ func dropDependency(pm *cache.ParsedModule, modulePath string) ([]protocol.TextE
683683
return protocol.EditsFromDiffEdits(pm.Mapper, diff)
684684
}
685685

686-
// Test is an alias for RunTests (with splayed arguments).
687-
func (c *commandHandler) Test(ctx context.Context, uri protocol.DocumentURI, tests, benchmarks []string) error {
688-
return c.RunTests(ctx, command.RunTestsArgs{
689-
URI: uri,
690-
Tests: tests,
691-
Benchmarks: benchmarks,
692-
})
693-
}
694-
695686
func (c *commandHandler) Doc(ctx context.Context, args command.DocArgs) (protocol.URI, error) {
696687
if args.Location.URI == "" {
697688
return "", errors.New("missing location URI")

0 commit comments

Comments
 (0)