mirror of
https://github.com/golang/go
synced 2024-11-18 11:04:42 -07:00
cmd/guru: remove Go 1.9 handling, since we no longer support 1.8
Some tests were split off for Go 1.9, when we still supported Go 1.8. This change recombines them and removes the special handling for 1.9. Fixes golang/go#24421 Change-Id: Ic871f4c3af4bb90b00cdd6d7b8f3253783554535 Reviewed-on: https://go-review.googlesource.com/c/161000 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org>
This commit is contained in:
parent
021ffbf1e9
commit
d810ce9e47
@ -236,10 +236,9 @@ func TestGuru(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, filename := range []string{
|
||||
"testdata/src/alias/alias.go", // iff guru.HasAlias (go1.9)
|
||||
"testdata/src/alias/alias.go",
|
||||
"testdata/src/calls/main.go",
|
||||
"testdata/src/describe/main.go",
|
||||
"testdata/src/describe/main19.go", // iff go1.9
|
||||
"testdata/src/freevars/main.go",
|
||||
"testdata/src/implements/main.go",
|
||||
"testdata/src/implements-methods/main.go",
|
||||
@ -256,7 +255,6 @@ func TestGuru(t *testing.T) {
|
||||
"testdata/src/calls-json/main.go",
|
||||
"testdata/src/peers-json/main.go",
|
||||
"testdata/src/definition-json/main.go",
|
||||
"testdata/src/definition-json/main19.go",
|
||||
"testdata/src/describe-json/main.go",
|
||||
"testdata/src/implements-json/main.go",
|
||||
"testdata/src/implements-methods-json/main.go",
|
||||
@ -273,15 +271,6 @@ func TestGuru(t *testing.T) {
|
||||
// wording for a "no such file or directory" error.
|
||||
t.Skip()
|
||||
}
|
||||
if filename == "testdata/src/alias/alias.go" && !guru.HasAlias {
|
||||
t.Skip()
|
||||
}
|
||||
if strings.HasSuffix(filename, "19.go") && !contains(build.Default.ReleaseTags, "go1.9") {
|
||||
// TODO(adonovan): recombine the 'describe' and 'definition'
|
||||
// tests once we drop support for go1.8.
|
||||
t.Skip()
|
||||
}
|
||||
|
||||
json := strings.Contains(filename, "-json/")
|
||||
queries := parseQueries(t, filename)
|
||||
golden := filename + "lden"
|
||||
@ -325,15 +314,6 @@ func TestGuru(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func contains(haystack []string, needle string) bool {
|
||||
for _, x := range haystack {
|
||||
if needle == x {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func TestIssue14684(t *testing.T) {
|
||||
var buildContext = build.Default
|
||||
buildContext.GOPATH = "testdata"
|
||||
|
@ -9,6 +9,7 @@ package definition
|
||||
import (
|
||||
"lib"
|
||||
lib2 "lib"
|
||||
"nosuchpkg"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -27,6 +28,7 @@ func main() {
|
||||
var _ lib.Const // @definition qualified-const "Const"
|
||||
var _ lib2.Type // @definition qualified-type-renaming "Type"
|
||||
var _ lib.Nonesuch // @definition qualified-nomember "Nonesuch"
|
||||
var _ nosuchpkg.T // @definition qualified-nopkg "nosuchpkg"
|
||||
|
||||
var u U
|
||||
print(u.field) // @definition select-field "field"
|
||||
|
@ -11,17 +11,17 @@ Error: no object for identifier
|
||||
}
|
||||
-------- @definition lexical-func --------
|
||||
{
|
||||
"objpos": "$GOPATH/src/definition-json/main.go:36:6",
|
||||
"objpos": "$GOPATH/src/definition-json/main.go:38:6",
|
||||
"desc": "func f"
|
||||
}
|
||||
-------- @definition lexical-var --------
|
||||
{
|
||||
"objpos": "$GOPATH/src/definition-json/main.go:18:6",
|
||||
"objpos": "$GOPATH/src/definition-json/main.go:19:6",
|
||||
"desc": "var x"
|
||||
}
|
||||
-------- @definition lexical-shadowing --------
|
||||
{
|
||||
"objpos": "$GOPATH/src/definition-json/main.go:21:5",
|
||||
"objpos": "$GOPATH/src/definition-json/main.go:22:5",
|
||||
"desc": "var x"
|
||||
}
|
||||
-------- @definition qualified-type --------
|
||||
@ -52,14 +52,19 @@ Error: no object for identifier
|
||||
-------- @definition qualified-nomember --------
|
||||
|
||||
Error: couldn't find declaration of Nonesuch in "lib"
|
||||
-------- @definition qualified-nopkg --------
|
||||
{
|
||||
"objpos": "testdata/src/definition-json/main.go:12:2",
|
||||
"desc": "package nosuchpkg"
|
||||
}
|
||||
-------- @definition select-field --------
|
||||
{
|
||||
"objpos": "testdata/src/definition-json/main.go:38:16",
|
||||
"objpos": "testdata/src/definition-json/main.go:40:16",
|
||||
"desc": "field field int"
|
||||
}
|
||||
-------- @definition select-method --------
|
||||
{
|
||||
"objpos": "testdata/src/definition-json/main.go:40:10",
|
||||
"objpos": "testdata/src/definition-json/main.go:42:10",
|
||||
"desc": "func (T).method()"
|
||||
}
|
||||
-------- @definition embedded-other-file --------
|
||||
@ -85,6 +90,6 @@ Error: int is built in
|
||||
}
|
||||
-------- @definition embedded-same-file --------
|
||||
{
|
||||
"objpos": "$GOPATH/src/definition-json/main.go:38:6",
|
||||
"objpos": "$GOPATH/src/definition-json/main.go:40:6",
|
||||
"desc": "type T"
|
||||
}
|
||||
|
@ -1,5 +0,0 @@
|
||||
package definition
|
||||
|
||||
import "nosuchpkg"
|
||||
|
||||
var _ nosuchpkg.T // @definition qualified-nopkg "nosuchpkg"
|
@ -1,5 +0,0 @@
|
||||
-------- @definition qualified-nopkg --------
|
||||
{
|
||||
"objpos": "testdata/src/definition-json/main19.go:3:8",
|
||||
"desc": "package nosuchpkg"
|
||||
}
|
5
cmd/guru/testdata/src/describe/main.go
vendored
5
cmd/guru/testdata/src/describe/main.go
vendored
@ -8,9 +8,14 @@ package describe // @describe pkgdecl "describe"
|
||||
|
||||
import (
|
||||
"lib"
|
||||
"nosuchpkg" // @describe badimport1 "nosuchpkg"
|
||||
nosuchpkg2 "nosuchpkg" // @describe badimport2 "nosuchpkg2"
|
||||
_ "unsafe" // @describe unsafe "unsafe"
|
||||
)
|
||||
|
||||
var _ nosuchpkg.T
|
||||
var _ nosuchpkg2.T
|
||||
|
||||
type cake float64 // @describe type-ref-builtin "float64"
|
||||
|
||||
const c = iota // @describe const-ref-iota "iota"
|
||||
|
6
cmd/guru/testdata/src/describe/main.golden
vendored
6
cmd/guru/testdata/src/describe/main.golden
vendored
@ -14,6 +14,12 @@ definition of package "describe"
|
||||
const pi untyped float = 3.141
|
||||
const pie cake = 3.141
|
||||
|
||||
-------- @describe badimport1 --------
|
||||
import of package "nosuchpkg"
|
||||
|
||||
-------- @describe badimport2 --------
|
||||
reference to package "nosuchpkg"
|
||||
|
||||
-------- @describe unsafe --------
|
||||
import of package "unsafe"
|
||||
builtin Alignof
|
||||
|
13
cmd/guru/testdata/src/describe/main19.go
vendored
13
cmd/guru/testdata/src/describe/main19.go
vendored
@ -1,13 +0,0 @@
|
||||
package describe
|
||||
|
||||
// The behavior of "describe" on a non-existent import changed
|
||||
// when go/types started returning fake packages, so this test
|
||||
// is executed only under go1.9.
|
||||
|
||||
import (
|
||||
"nosuchpkg" // @describe badimport1 "nosuchpkg"
|
||||
nosuchpkg2 "nosuchpkg" // @describe badimport2 "nosuchpkg2"
|
||||
)
|
||||
|
||||
var _ nosuchpkg.T
|
||||
var _ nosuchpkg2.T
|
6
cmd/guru/testdata/src/describe/main19.golden
vendored
6
cmd/guru/testdata/src/describe/main19.golden
vendored
@ -1,6 +0,0 @@
|
||||
-------- @describe badimport1 --------
|
||||
import of package "nosuchpkg"
|
||||
|
||||
-------- @describe badimport2 --------
|
||||
reference to package "nosuchpkg"
|
||||
|
18
cmd/guru/testdata/src/referrers-json/main.golden
vendored
18
cmd/guru/testdata/src/referrers-json/main.golden
vendored
@ -6,35 +6,35 @@
|
||||
"package": "definition-json",
|
||||
"refs": [
|
||||
{
|
||||
"pos": "testdata/src/definition-json/main.go:18:8",
|
||||
"pos": "testdata/src/definition-json/main.go:19:8",
|
||||
"text": "\tvar x lib.T // @definition lexical-pkgname \"lib\""
|
||||
},
|
||||
{
|
||||
"pos": "testdata/src/definition-json/main.go:24:8",
|
||||
"pos": "testdata/src/definition-json/main.go:25:8",
|
||||
"text": "\tvar _ lib.Type // @definition qualified-type \"Type\""
|
||||
},
|
||||
{
|
||||
"pos": "testdata/src/definition-json/main.go:25:8",
|
||||
"pos": "testdata/src/definition-json/main.go:26:8",
|
||||
"text": "\tvar _ lib.Func // @definition qualified-func \"Func\""
|
||||
},
|
||||
{
|
||||
"pos": "testdata/src/definition-json/main.go:26:8",
|
||||
"pos": "testdata/src/definition-json/main.go:27:8",
|
||||
"text": "\tvar _ lib.Var // @definition qualified-var \"Var\""
|
||||
},
|
||||
{
|
||||
"pos": "testdata/src/definition-json/main.go:27:8",
|
||||
"pos": "testdata/src/definition-json/main.go:28:8",
|
||||
"text": "\tvar _ lib.Const // @definition qualified-const \"Const\""
|
||||
},
|
||||
{
|
||||
"pos": "testdata/src/definition-json/main.go:28:8",
|
||||
"pos": "testdata/src/definition-json/main.go:29:8",
|
||||
"text": "\tvar _ lib2.Type // @definition qualified-type-renaming \"Type\""
|
||||
},
|
||||
{
|
||||
"pos": "testdata/src/definition-json/main.go:29:8",
|
||||
"pos": "testdata/src/definition-json/main.go:30:8",
|
||||
"text": "\tvar _ lib.Nonesuch // @definition qualified-nomember \"Nonesuch\""
|
||||
},
|
||||
{
|
||||
"pos": "testdata/src/definition-json/main.go:61:2",
|
||||
"pos": "testdata/src/definition-json/main.go:63:2",
|
||||
"text": "\tlib.Type // @definition embedded-other-pkg \"Type\""
|
||||
}
|
||||
]
|
||||
@ -43,7 +43,7 @@
|
||||
"package": "describe",
|
||||
"refs": [
|
||||
{
|
||||
"pos": "testdata/src/describe/main.go:87:8",
|
||||
"pos": "testdata/src/describe/main.go:92:8",
|
||||
"text": "\tvar _ lib.Outer // @describe lib-outer \"Outer\""
|
||||
}
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user