1
0
mirror of https://github.com/golang/go synced 2024-09-30 16:08:36 -06: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:
Rebecca Stambler 2019-02-04 13:53:25 -05:00
parent 021ffbf1e9
commit d810ce9e47
10 changed files with 35 additions and 66 deletions

View File

@ -236,10 +236,9 @@ func TestGuru(t *testing.T) {
} }
for _, filename := range []string{ 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/calls/main.go",
"testdata/src/describe/main.go", "testdata/src/describe/main.go",
"testdata/src/describe/main19.go", // iff go1.9
"testdata/src/freevars/main.go", "testdata/src/freevars/main.go",
"testdata/src/implements/main.go", "testdata/src/implements/main.go",
"testdata/src/implements-methods/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/calls-json/main.go",
"testdata/src/peers-json/main.go", "testdata/src/peers-json/main.go",
"testdata/src/definition-json/main.go", "testdata/src/definition-json/main.go",
"testdata/src/definition-json/main19.go",
"testdata/src/describe-json/main.go", "testdata/src/describe-json/main.go",
"testdata/src/implements-json/main.go", "testdata/src/implements-json/main.go",
"testdata/src/implements-methods-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. // wording for a "no such file or directory" error.
t.Skip() 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/") json := strings.Contains(filename, "-json/")
queries := parseQueries(t, filename) queries := parseQueries(t, filename)
golden := filename + "lden" 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) { func TestIssue14684(t *testing.T) {
var buildContext = build.Default var buildContext = build.Default
buildContext.GOPATH = "testdata" buildContext.GOPATH = "testdata"

View File

@ -9,6 +9,7 @@ package definition
import ( import (
"lib" "lib"
lib2 "lib" lib2 "lib"
"nosuchpkg"
) )
func main() { func main() {
@ -27,6 +28,7 @@ func main() {
var _ lib.Const // @definition qualified-const "Const" var _ lib.Const // @definition qualified-const "Const"
var _ lib2.Type // @definition qualified-type-renaming "Type" var _ lib2.Type // @definition qualified-type-renaming "Type"
var _ lib.Nonesuch // @definition qualified-nomember "Nonesuch" var _ lib.Nonesuch // @definition qualified-nomember "Nonesuch"
var _ nosuchpkg.T // @definition qualified-nopkg "nosuchpkg"
var u U var u U
print(u.field) // @definition select-field "field" print(u.field) // @definition select-field "field"

View File

@ -11,17 +11,17 @@ Error: no object for identifier
} }
-------- @definition lexical-func -------- -------- @definition lexical-func --------
{ {
"objpos": "$GOPATH/src/definition-json/main.go:36:6", "objpos": "$GOPATH/src/definition-json/main.go:38:6",
"desc": "func f" "desc": "func f"
} }
-------- @definition lexical-var -------- -------- @definition lexical-var --------
{ {
"objpos": "$GOPATH/src/definition-json/main.go:18:6", "objpos": "$GOPATH/src/definition-json/main.go:19:6",
"desc": "var x" "desc": "var x"
} }
-------- @definition lexical-shadowing -------- -------- @definition lexical-shadowing --------
{ {
"objpos": "$GOPATH/src/definition-json/main.go:21:5", "objpos": "$GOPATH/src/definition-json/main.go:22:5",
"desc": "var x" "desc": "var x"
} }
-------- @definition qualified-type -------- -------- @definition qualified-type --------
@ -52,14 +52,19 @@ Error: no object for identifier
-------- @definition qualified-nomember -------- -------- @definition qualified-nomember --------
Error: couldn't find declaration of Nonesuch in "lib" 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 -------- -------- @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" "desc": "field field int"
} }
-------- @definition select-method -------- -------- @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()" "desc": "func (T).method()"
} }
-------- @definition embedded-other-file -------- -------- @definition embedded-other-file --------
@ -85,6 +90,6 @@ Error: int is built in
} }
-------- @definition embedded-same-file -------- -------- @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" "desc": "type T"
} }

View File

@ -1,5 +0,0 @@
package definition
import "nosuchpkg"
var _ nosuchpkg.T // @definition qualified-nopkg "nosuchpkg"

View File

@ -1,5 +0,0 @@
-------- @definition qualified-nopkg --------
{
"objpos": "testdata/src/definition-json/main19.go:3:8",
"desc": "package nosuchpkg"
}

View File

@ -8,9 +8,14 @@ package describe // @describe pkgdecl "describe"
import ( import (
"lib" "lib"
_ "unsafe" // @describe unsafe "unsafe" "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" type cake float64 // @describe type-ref-builtin "float64"
const c = iota // @describe const-ref-iota "iota" const c = iota // @describe const-ref-iota "iota"

View File

@ -14,6 +14,12 @@ definition of package "describe"
const pi untyped float = 3.141 const pi untyped float = 3.141
const pie cake = 3.141 const pie cake = 3.141
-------- @describe badimport1 --------
import of package "nosuchpkg"
-------- @describe badimport2 --------
reference to package "nosuchpkg"
-------- @describe unsafe -------- -------- @describe unsafe --------
import of package "unsafe" import of package "unsafe"
builtin Alignof builtin Alignof

View File

@ -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

View File

@ -1,6 +0,0 @@
-------- @describe badimport1 --------
import of package "nosuchpkg"
-------- @describe badimport2 --------
reference to package "nosuchpkg"

View File

@ -6,35 +6,35 @@
"package": "definition-json", "package": "definition-json",
"refs": [ "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\"" "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\"" "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\"" "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\"" "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\"" "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\"" "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\"" "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\"" "text": "\tlib.Type // @definition embedded-other-pkg \"Type\""
} }
] ]
@ -43,7 +43,7 @@
"package": "describe", "package": "describe",
"refs": [ "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\"" "text": "\tvar _ lib.Outer // @describe lib-outer \"Outer\""
} }
] ]