mirror of
https://github.com/golang/go
synced 2024-11-18 11:44:45 -07:00
internal/lsp: have tests report a different application name to the main gopls binary
Change-Id: I246dc9c468ee35586a8332ebdf41f23521adbc6c Reviewed-on: https://go-review.googlesource.com/c/tools/+/186677 Run-TryBot: Ian Cottrell <iancottrell@google.com> Reviewed-by: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
38daa6564b
commit
625c92e46d
@ -19,5 +19,5 @@ import (
|
||||
|
||||
func main() {
|
||||
debug.Version += "-cmd.gopls"
|
||||
tool.Main(context.Background(), cmd.New("", nil), os.Args[1:])
|
||||
tool.Main(context.Background(), cmd.New("gopls-legacy", "", nil), os.Args[1:])
|
||||
}
|
||||
|
@ -17,5 +17,5 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
tool.Main(context.Background(), cmd.New("", nil), os.Args[1:])
|
||||
tool.Main(context.Background(), cmd.New("gopls", "", nil), os.Args[1:])
|
||||
}
|
||||
|
@ -45,6 +45,9 @@ type Application struct {
|
||||
// The base cache to use for sessions from this application.
|
||||
cache source.Cache
|
||||
|
||||
// The name of the binary, used in help and telemetry.
|
||||
name string
|
||||
|
||||
// The working directory to run commands in.
|
||||
wd string
|
||||
|
||||
@ -59,12 +62,13 @@ type Application struct {
|
||||
}
|
||||
|
||||
// Returns a new Application ready to run.
|
||||
func New(wd string, env []string) *Application {
|
||||
func New(name, wd string, env []string) *Application {
|
||||
if wd == "" {
|
||||
wd, _ = os.Getwd()
|
||||
}
|
||||
app := &Application{
|
||||
cache: cache.New(),
|
||||
name: name,
|
||||
wd: wd,
|
||||
env: env,
|
||||
}
|
||||
@ -72,7 +76,7 @@ func New(wd string, env []string) *Application {
|
||||
}
|
||||
|
||||
// Name implements tool.Application returning the binary name.
|
||||
func (app *Application) Name() string { return "gopls" }
|
||||
func (app *Application) Name() string { return app.name }
|
||||
|
||||
// Usage implements tool.Application returning empty extra argument usage.
|
||||
func (app *Application) Usage() string { return "<command> [command-flags] [command-args]" }
|
||||
|
@ -39,7 +39,7 @@ func testCommandLine(t *testing.T, exporter packagestest.Exporter) {
|
||||
r := &runner{
|
||||
exporter: exporter,
|
||||
data: data,
|
||||
app: cmd.New(data.Config.Dir, data.Exported.Config.Env),
|
||||
app: cmd.New("gopls-test", data.Config.Dir, data.Exported.Config.Env),
|
||||
ctx: tests.Context(t),
|
||||
}
|
||||
tests.Run(t, r, data)
|
||||
|
@ -55,7 +55,7 @@ func TestDefinitionHelpExample(t *testing.T) {
|
||||
fmt.Sprintf("%v:#%v", thisFile, cmd.ExampleOffset)} {
|
||||
args := append(baseArgs, query)
|
||||
got := captureStdOut(t, func() {
|
||||
tool.Main(tests.Context(t), cmd.New("", nil), args)
|
||||
tool.Main(tests.Context(t), cmd.New("gopls-test", "", nil), args)
|
||||
})
|
||||
if !expect.MatchString(got) {
|
||||
t.Errorf("test with %v\nexpected:\n%s\ngot:\n%s", args, expect, got)
|
||||
|
@ -37,7 +37,7 @@ func (r *runner) Format(t *testing.T, data tests.Formats) {
|
||||
//TODO: our error handling differs, for now just skip unformattable files
|
||||
continue
|
||||
}
|
||||
app := cmd.New(r.data.Config.Dir, r.data.Config.Env)
|
||||
app := cmd.New("gopls-test", r.data.Config.Dir, r.data.Config.Env)
|
||||
got := captureStdOut(t, func() {
|
||||
tool.Main(r.ctx, app, append([]string{"-remote=internal", "format"}, args...))
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user