| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
package workspace |
| 6 |
|
| 7 |
import ( |
| 8 |
"flag" |
| 9 |
"os" |
| 10 |
"runtime" |
| 11 |
"testing" |
| 12 |
|
| 13 |
. "golang.org/x/tools/gopls/internal/test/integration" |
| 14 |
) |
| 15 |
|
| 16 |
var go121bin = flag.String("go121bin", "", "bin directory containing go 1.21 or later") |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
func TestCanHandlePatchVersions(t *testing.T) { |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
if *go121bin == "" { |
| 30 |
t.Skip("-go121bin directory is not set") |
| 31 |
} |
| 32 |
|
| 33 |
if runtime.GOOS != "linux" && runtime.GOOS != "darwin" { |
| 34 |
t.Skip("requires linux or darwin") |
| 35 |
} |
| 36 |
|
| 37 |
path := os.Getenv("PATH") |
| 38 |
t.Setenv("PATH", *go121bin+":"+path) |
| 39 |
|
| 40 |
const files = ` |
| 41 |
-- go.mod -- |
| 42 |
module example.com/bar |
| 43 |
|
| 44 |
go 1.21.1 |
| 45 |
|
| 46 |
-- p.go -- |
| 47 |
package bar |
| 48 |
|
| 49 |
type I interface { string } |
| 50 |
` |
| 51 |
|
| 52 |
WithOptions( |
| 53 |
EnvVars{ |
| 54 |
"PATH": path, |
| 55 |
}, |
| 56 |
).Run(t, files, func(t *testing.T, env *Env) { |
| 57 |
env.OpenFile("p.go") |
| 58 |
env.AfterChange( |
| 59 |
NoDiagnostics(ForFile("p.go")), |
| 60 |
) |
| 61 |
}) |
| 62 |
} |