mirror of
https://github.com/golang/go.git
synced 2025-05-05 23:53:05 +00: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() {
|
func main() {
|
||||||
debug.Version += "-cmd.gopls"
|
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() {
|
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.
|
// The base cache to use for sessions from this application.
|
||||||
cache source.Cache
|
cache source.Cache
|
||||||
|
|
||||||
|
// The name of the binary, used in help and telemetry.
|
||||||
|
name string
|
||||||
|
|
||||||
// The working directory to run commands in.
|
// The working directory to run commands in.
|
||||||
wd string
|
wd string
|
||||||
|
|
||||||
@ -59,12 +62,13 @@ type Application struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns a new Application ready to run.
|
// Returns a new Application ready to run.
|
||||||
func New(wd string, env []string) *Application {
|
func New(name, wd string, env []string) *Application {
|
||||||
if wd == "" {
|
if wd == "" {
|
||||||
wd, _ = os.Getwd()
|
wd, _ = os.Getwd()
|
||||||
}
|
}
|
||||||
app := &Application{
|
app := &Application{
|
||||||
cache: cache.New(),
|
cache: cache.New(),
|
||||||
|
name: name,
|
||||||
wd: wd,
|
wd: wd,
|
||||||
env: env,
|
env: env,
|
||||||
}
|
}
|
||||||
@ -72,7 +76,7 @@ func New(wd string, env []string) *Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Name implements tool.Application returning the binary name.
|
// 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.
|
// Usage implements tool.Application returning empty extra argument usage.
|
||||||
func (app *Application) Usage() string { return "<command> [command-flags] [command-args]" }
|
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{
|
r := &runner{
|
||||||
exporter: exporter,
|
exporter: exporter,
|
||||||
data: data,
|
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),
|
ctx: tests.Context(t),
|
||||||
}
|
}
|
||||||
tests.Run(t, r, data)
|
tests.Run(t, r, data)
|
||||||
|
@ -55,7 +55,7 @@ func TestDefinitionHelpExample(t *testing.T) {
|
|||||||
fmt.Sprintf("%v:#%v", thisFile, cmd.ExampleOffset)} {
|
fmt.Sprintf("%v:#%v", thisFile, cmd.ExampleOffset)} {
|
||||||
args := append(baseArgs, query)
|
args := append(baseArgs, query)
|
||||||
got := captureStdOut(t, func() {
|
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) {
|
if !expect.MatchString(got) {
|
||||||
t.Errorf("test with %v\nexpected:\n%s\ngot:\n%s", args, expect, 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
|
//TODO: our error handling differs, for now just skip unformattable files
|
||||||
continue
|
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() {
|
got := captureStdOut(t, func() {
|
||||||
tool.Main(r.ctx, app, append([]string{"-remote=internal", "format"}, args...))
|
tool.Main(r.ctx, app, append([]string{"-remote=internal", "format"}, args...))
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user