-
Notifications
You must be signed in to change notification settings - Fork 17.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/go: restore default vet analyzers for targets in GOROOT
This fixes a regression introduced in CL 209498, found while investigating #32471. Also fix $WORK replacement in cmd/go/internal/work.(*Builder).Showcmd when b.WorkDir includes a backslash and appears in a quoted string. That fix is needed in order to write a precise test that passes under Windows, since Windows directories nearly always include backslashes. Updates #35837 Change-Id: I5fddc5435d5d283a3e598989209d873b59b0a39c Reviewed-on: https://go-review.googlesource.com/c/go/+/210937 Run-TryBot: Bryan C. Mills <bcmills@google.com> Reviewed-by: Jay Conrod <jayconrod@google.com>
- Loading branch information
Bryan C. Mills
committed
Dec 12, 2019
1 parent
a15b5d3
commit c39cd41
Showing
3 changed files
with
39 additions
and
7 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,8 +1,34 @@ | ||
env GO111MODULE=off | ||
env GO111MODULE=on | ||
|
||
# Issue 35837. Verify that "go vet -<analyzer> <std package>" works if 'pwd' is not $GOROOT/src | ||
# we utilize the package runtime/testdata/testprog as the issue is specific to vetting standard package | ||
|
||
go vet -n -unreachable=false runtime/testdata/testprog | ||
# Regression test for issue 35837: "go vet -<analyzer> <std package>" | ||
# did not apply the requested analyzer. | ||
go vet -n -unreachable=false encoding/binary | ||
stderr '-unreachable=false' | ||
stderr '-unsafeptr=false' | ||
! stderr '-unsafeptr=false' | ||
|
||
[short] stop | ||
env GOCACHE=$WORK/gocache | ||
env GOTMPDIR=$WORK/tmp | ||
go env GOTMPDIR | ||
stdout '/tmp' | ||
|
||
# "go test" on a user package should by default enable an explicit whitelist of analyzers. | ||
go test -x -run=none . | ||
stderr '[/\\]vet'$GOEXE'["]? .* -errorsas .* ["]?\$WORK[/\\][^ ]*[/\\]vet\.cfg' | ||
|
||
# "go test" on a standard package should by default disable an explicit blacklist. | ||
go test -x -run=none encoding/binary | ||
stderr '[/\\]vet'$GOEXE'["]? -unsafeptr=false ["]?\$WORK[/\\][^ ]*[/\\]vet\.cfg' | ||
|
||
# Both should allow users to override via the -vet flag. | ||
go test -x -vet=unreachable -run=none . | ||
stderr '[/\\]vet'$GOEXE'["]? -unreachable ["]?\$WORK[/\\][^ ]*[/\\]vet\.cfg' | ||
go test -x -vet=unreachable -run=none encoding/binary | ||
stderr '[/\\]vet'$GOEXE'["]? -unreachable ["]?\$WORK[/\\][^ ]*[/\\]vet\.cfg' | ||
|
||
-- go.mod -- | ||
module example.com/x | ||
-- x.go -- | ||
package x | ||
-- x_test.go -- | ||
package x |