-
Notifications
You must be signed in to change notification settings - Fork 17.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
search.CleanPatterns now preserves backslash separators in absolute paths in Windows. These had resulted in inconsistent error messages. search.MatchPackagesInFS is now more accepting of patterns with backslashes. It was inconsistent before. Several tests are fixed to work with Windows (mostly to match slashes or backslashes). Fixes #25300 Change-Id: Ibbf9ccd145353f7e3d345205c6fcc01d7066d1c2 Reviewed-on: https://go-review.googlesource.com/c/go/+/206144 Run-TryBot: Jay Conrod <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]>
- Loading branch information
Jay Conrod
committed
Nov 11, 2019
1 parent
275a7be
commit 70be481
Showing
9 changed files
with
130 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,93 @@ | ||
[short] skip | ||
|
||
env -r GOROOT_REGEXP=$GOROOT | ||
env -r WORK_REGEXP='$WORK' # don't expand $WORK; grep replaces $WORK in text before matching. | ||
env GOROOT GOROOT_REGEXP WORK WORK_REGEXP | ||
env GO111MODULE=on | ||
|
||
# A binary built without -trimpath should contain the current workspace | ||
# and GOROOT for debugging and stack traces. | ||
cd a | ||
go build -o hello.exe hello.go | ||
grep -q $WORK_REGEXP hello.exe | ||
grep -q $GOROOT_REGEXP hello.exe | ||
go build -o $WORK/paths-a.exe paths.go | ||
exec $WORK/paths-a.exe $WORK/paths-a.exe | ||
stdout 'binary contains GOPATH: true' | ||
stdout 'binary contains GOROOT: true' | ||
|
||
# A binary built with -trimpath should not contain the current workspace | ||
# or GOROOT. | ||
go build -trimpath -o hello.exe hello.go | ||
! grep -q $GOROOT_REGEXP hello.exe | ||
! grep -q $WORK_REGEXP hello.exe | ||
go build -trimpath -o $WORK/paths-a.exe paths.go | ||
exec $WORK/paths-a.exe $WORK/paths-a.exe | ||
stdout 'binary contains GOPATH: false' | ||
stdout 'binary contains GOROOT: false' | ||
|
||
# A binary from an external module built with -trimpath should not contain | ||
# the current workspace or GOROOT. | ||
cd $WORK | ||
env GO111MODULE=on | ||
go get -trimpath rsc.io/fortune | ||
! grep -q $GOROOT_REGEXP $GOPATH/bin/fortune$GOEXE | ||
! grep -q $WORK_REGEXP $GOPATH/bin/fortune$GOEXE | ||
exec $WORK/paths-a.exe $GOPATH/bin/fortune$GOEXE | ||
stdout 'binary contains GOPATH: false' | ||
stdout 'binary contains GOROOT: false' | ||
|
||
# Two binaries built from identical packages in different directories | ||
# should be identical. | ||
cd $GOPATH/src/a | ||
go build -trimpath -o $WORK/a-GOPATH.exe . | ||
cd $WORK/_alt/src/a | ||
go build -trimpath -o $WORK/a-alt.exe . | ||
cmp -q $WORK/a-GOPATH.exe $WORK/a-alt.exe | ||
# TODO(golang.org/issue/35435): at the moment, they are not. | ||
#mkdir $GOPATH/src/b | ||
#cp $GOPATH/src/a/go.mod $GOPATH/src/b/go.mod | ||
#cp $GOPATH/src/a/paths.go $GOPATH/src/b/paths.go | ||
#cd $GOPATH/src/b | ||
#go build -trimpath -o $WORK/paths-b.exe . | ||
#cmp -q $WORK/paths-a.exe $WORK/paths-b.exe | ||
|
||
[!exec:gccgo] stop | ||
|
||
# Binaries built using gccgo should also be identical to each other. | ||
# A binary built with gccgo without -trimpath should contain the current | ||
# GOPATH and GOROOT. | ||
env GO111MODULE=off # The current released gccgo does not support builds in module mode. | ||
cd $GOPATH/src/a | ||
go build -compiler=gccgo -trimpath -o $WORK/gccgo-GOPATH.exe . | ||
go build -compiler=gccgo -o $WORK/gccgo-paths-a.exe . | ||
exec $WORK/gccgo-paths-a.exe $WORK/gccgo-paths-b.exe | ||
stdout 'binary contains GOPATH: true' | ||
stdout 'binary contains GOROOT: true' | ||
|
||
env old_gopath=$GOPATH | ||
env GOPATH=$WORK/_alt | ||
cd $WORK/_alt/src/a | ||
go build -compiler=gccgo -trimpath -o $WORK/gccgo-alt.exe . | ||
cd $WORK | ||
! grep -q $GOROOT_REGEXP gccgo-GOPATH.exe | ||
! grep -q $WORK_REGEXP gccgo-GOPATH.exe | ||
cmp -q gccgo-GOPATH.exe gccgo-alt.exe | ||
# A binary built with gccgo with -trimpath should not contain GOPATH or GOROOT. | ||
go build -compiler=gccgo -trimpath -o $WORK/gccgo-paths-a.exe . | ||
exec $WORK/gccgo-paths-a.exe $WORK/gccgo-paths-b.exe | ||
stdout 'binary contains GOPATH: false' | ||
stdout 'binary contains GOROOT: false' | ||
|
||
# Two binaries built from identical packages in different directories | ||
# should be identical. | ||
# TODO(golang.org/issue/35435): at the moment, they are not. | ||
#cd ../b | ||
#go build -compiler=gccgo -trimpath -o $WORK/gccgo-paths-b.exe . | ||
#cmp -q $WORK/gccgo-paths-a.exe $WORK/gccgo-paths-b.exe | ||
|
||
-- $GOPATH/src/a/hello.go -- | ||
-- $GOPATH/src/a/paths.go -- | ||
package main | ||
func main() { println("hello") } | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"io/ioutil" | ||
"log" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
func main() { | ||
exe := os.Args[1] | ||
data, err := ioutil.ReadFile(exe) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
gopath := []byte(filepath.ToSlash(os.Getenv("GOPATH"))) | ||
if len(gopath) == 0 { | ||
log.Fatal("GOPATH not set") | ||
} | ||
fmt.Printf("binary contains GOPATH: %v\n", bytes.Contains(data, gopath)) | ||
|
||
goroot := []byte(filepath.ToSlash(os.Getenv("GOROOT"))) | ||
if len(goroot) == 0 { | ||
log.Fatal("GOROOT not set") | ||
} | ||
fmt.Printf("binary contains GOROOT: %v\n", bytes.Contains(data, goroot)) | ||
} | ||
-- $GOPATH/src/a/go.mod -- | ||
module example.com/a | ||
-- $WORK/_alt/src/a/hello.go -- | ||
package main | ||
func main() { println("hello") } | ||
-- $WORK/_alt/src/a/go.mod -- | ||
module example.com/a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
[short] skip | ||
[!net] skip | ||
[!exec:git] skip | ||
|
||
env GO111MODULE=on | ||
env GOPROXY=direct | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,10 +12,10 @@ stdout ^math$ | |
go list -f '{{.ImportPath}}' . | ||
stdout ^x$ | ||
! go list -f '{{.ImportPath}}' $GOPATH/pkg/mod/rsc.io/[email protected] | ||
stderr '^can.t load package: package '$WORK'[/\\]gopath/pkg/mod/rsc.io/[email protected]: can only use path@version syntax with .go get.' | ||
stderr '^can.t load package: package '$WORK'[/\\]gopath[/\\]pkg[/\\]mod[/\\]rsc.io[/\\][email protected]: can only use path@version syntax with .go get.' | ||
|
||
go list -e -f '{{with .Error}}{{.}}{{end}}' $GOPATH/pkg/mod/rsc.io/[email protected] | ||
stdout '^package '$WORK'[/\\]gopath/pkg/mod/rsc.io/[email protected]: can only use path@version syntax with .go get.' | ||
stdout '^package '$WORK'[/\\]gopath[/\\]pkg[/\\]mod[/\\]rsc.io[/\\][email protected]: can only use path@version syntax with .go get.' | ||
go mod download rsc.io/[email protected] | ||
go list -f '{{.ImportPath}}' $GOPATH/pkg/mod/rsc.io/[email protected] | ||
stdout '^rsc.io/quote$' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ env GOPATH=$WORK/gopath1 | |
[windows] env GOPROXY=file:///$WORK/sumproxy,https://proxy.golang.org | ||
[!windows] env GOPROXY=file://$WORK/sumproxy,https://proxy.golang.org | ||
! go get -d golang.org/x/[email protected] | ||
stderr '^go get golang.org/x/[email protected]: golang.org/x/[email protected]: verifying module: golang.org/x/[email protected]: reading file://.*/sumdb/sum.golang.org/lookup/golang.org/x/[email protected]: (no such file or directory|.*cannot find the file specified.*)' | ||
stderr '^go get golang.org/x/[email protected]: golang.org/x/[email protected]: verifying module: golang.org/x/[email protected]: reading file://.*/sumdb/sum.golang.org/lookup/golang.org/x/[email protected]: (no such file or directory|.*cannot find the path specified.*)' | ||
|
||
# If the proxy does not claim to support the database, | ||
# checksum verification should fall through to the next proxy, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,7 +62,7 @@ stdout '^'$WORK'[/\\]auto[/\\]replacement-version$' | |
go mod edit -go=1.14 | ||
|
||
! go list -f {{.Dir}} -tags tools all | ||
stderr '^go: inconsistent vendoring in '$WORK/auto':$' | ||
stderr '^go: inconsistent vendoring in '$WORK[/\\]auto':$' | ||
stderr '^\texample.com/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt' | ||
stderr '^\texample.com/unused: is replaced in go.mod, but not marked as replaced in vendor/modules.txt' | ||
stderr '^\texample.com/[email protected]: is replaced in go.mod, but not marked as replaced in vendor/modules.txt' | ||
|
@@ -131,7 +131,7 @@ stdout '^'$WORK'[/\\]auto[/\\]vendor[/\\]example.com[/\\]version$' | |
cp go.mod.orig go.mod | ||
go mod edit -go=1.14 | ||
! go list -f {{.Dir}} -tags tools all | ||
stderr '^go: inconsistent vendoring in '$WORK/auto':$' | ||
stderr '^go: inconsistent vendoring in '$WORK[/\\]auto':$' | ||
stderr '^\texample.com/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt' | ||
stderr '^\texample.com/unused: is replaced in go.mod, but not marked as replaced in vendor/modules.txt' | ||
stderr '^\texample.com/[email protected]: is replaced in go.mod, but not marked as replaced in vendor/modules.txt' | ||
|
@@ -149,7 +149,7 @@ stdout '^'$WORK'[/\\]auto[/\\]vendor[/\\]example.com[/\\]version$' | |
# ...but a version mismatch for an explicit dependency should be noticed. | ||
cp $WORK/modules-bad-1.13.txt vendor/modules.txt | ||
! go list -mod=vendor -f {{.Dir}} -tags tools all | ||
stderr '^go: inconsistent vendoring in '$WORK/auto':$' | ||
stderr '^go: inconsistent vendoring in '$WORK[/\\]auto':$' | ||
stderr '^\texample.com/[email protected]: is explicitly required in go.mod, but vendor/modules.txt indicates example.com/[email protected]$' | ||
stderr '\n\nrun .go mod vendor. to sync, or use -mod=mod or -mod=readonly to ignore the vendor directory$' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters