Skip to content

Commit 2c86713

Browse files
author
Bryan C. Mills
committed
cmd/go: expand tests for standard-library vendoring in GOPATH mode
This should help to catch any regressions in the course of implementing #26924. Updates #26924 Change-Id: Ide28a9aa0235867e0ce72f855fbed51c50e2c2f2 Reviewed-on: https://go-review.googlesource.com/c/163520 Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
1 parent d7518ac commit 2c86713

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

src/cmd/go/testdata/script/list_std.txt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,24 @@ env GO111MODULE=off
22

33
[!gc] skip
44

5-
# listing GOROOT should only find standard packages
5+
# Listing GOROOT should only find standard packages.
66
cd $GOROOT/src
77
go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}' ./...
88
! stdout .
99
# TODO: ignore _/blah/go/src in output
1010

11-
# our vendored packages should be reported as standard
12-
go list std cmd
11+
# Standard packages should include cmd, but not cmd/vendor.
12+
go list ./...
13+
stdout cmd/compile
14+
! stdout vendor/golang.org
15+
! stdout cmd/vendor
16+
17+
# In GOPATH mode, packages vendored into GOROOT should be reported as standard.
18+
go list -f '{{if .Standard}}{{.ImportPath}}{{end}}' std cmd
1319
stdout internal/x/net/http2/hpack
1420
stdout cmd/vendor/golang\.org/x/arch/x86/x86asm
21+
22+
# However, vendored packages should not match wildcard patterns beginning with cmd.
23+
go list cmd/...
24+
stdout cmd/compile
25+
! stdout cmd/vendor
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
env GO111MODULE=off
2+
3+
[!gc] skip
4+
5+
# 'go list' should report imports from _test.go in the TestImports field.
6+
go list -f '{{.TestImports}}'
7+
stdout net/http # from .TestImports
8+
9+
# 'go list -test' should report vendored transitive dependencies of _test.go
10+
# imports in the Deps field, with a 'vendor' prefix on their import paths.
11+
go list -test -f '{{.Deps}}'
12+
stdout internal/x/crypto # dep of .TestImports
13+
14+
-- go.mod --
15+
module m
16+
17+
-- x.go --
18+
package x
19+
20+
-- x_test.go --
21+
package x
22+
import "testing"
23+
import _ "net/http"
24+
func Test(t *testing.T) {}

0 commit comments

Comments
 (0)