mirror of
https://github.com/golang/go
synced 2024-11-19 01:54:39 -07:00
866d71a317
TestBadGOPATH tests for a empty element in the GOPATH list using "GOPATH=:/path/to/gopath", assuming that ':' is the path list separator. On Windows the test fails, because Windows path list separator is ';'. Therefore this test isn't built for Windows. On Plan 9, os.PathListSeparator is '\000', so the test fails there too, and should not be built for Plan 9. Change-Id: Icdc2f8de098c1415103ec6124906ad6c578ad183 Reviewed-on: https://go-review.googlesource.com/c/tools/+/233718 Reviewed-by: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
37 lines
843 B
Go
37 lines
843 B
Go
// Copyright 2020 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// +build !windows,!plan9
|
|
|
|
package regtest
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"golang.org/x/tools/internal/lsp/fake"
|
|
)
|
|
|
|
func TestBadGOPATH(t *testing.T) {
|
|
const missingImport = `
|
|
-- main.go --
|
|
package main
|
|
|
|
func _() {
|
|
fmt.Println("Hello World")
|
|
}
|
|
`
|
|
// Test the case given in
|
|
// https://github.com/fatih/vim-go/issues/2673#issuecomment-622307211.
|
|
runner.Run(t, missingImport, func(t *testing.T, env *Env) {
|
|
env.OpenFile("main.go")
|
|
env.Await(env.DiagnosticAtRegexp("main.go", "fmt"))
|
|
if err := env.Editor.OrganizeImports(env.Ctx, "main.go"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}, WithEditorConfig(fake.EditorConfig{
|
|
Env: []string{fmt.Sprintf("GOPATH=:/path/to/gopath")},
|
|
}))
|
|
}
|