-
Notifications
You must be signed in to change notification settings - Fork 17.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/go: add a flag to avoid creating unwritable directories in the mo…
…dule cache This change adds the '-modcacherw' build flag, which leaves newly-created directories (but not the files!) in the module cache read-write instead of making them unwritable. Fixes #31481 Change-Id: I7c21a53dd145676627c3b51096914ce797991d99 Reviewed-on: https://go-review.googlesource.com/c/go/+/202079 Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
- Loading branch information
Bryan C. Mills
committed
Oct 21, 2019
1 parent
b653c87
commit 84b0e36
Showing
8 changed files
with
71 additions
and
8 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Regression test for golang.org/issue/31481. | ||
|
||
env GO111MODULE=on | ||
|
||
# golang.org/issue/31481: an explicit flag should make directories in the module | ||
# cache writable in order to work around the historical inability of 'rm -rf' to | ||
# forcibly remove files in unwritable directories. | ||
go get -modcacherw -d rsc.io/[email protected] | ||
cp $WORK/extraneous.txt $GOPATH/pkg/mod/rsc.io/[email protected]/extraneous_file.go | ||
|
||
# After adding an extraneous file, 'go mod verify' should fail. | ||
! go mod verify | ||
|
||
# However, files within those directories should still be read-only to avoid | ||
# accidental mutations. | ||
# TODO: Today, this does not seem to be effective on Windows. | ||
# (https://golang.org/issue/35033) | ||
[!windows] [!root] ! cp $WORK/extraneous.txt $GOPATH/pkg/mod/rsc.io/[email protected]/go.mod | ||
|
||
# If all 'go' commands ran with the flag, the system's 'rm' binary | ||
# should be able to remove the module cache if the '-rf' flags are set. | ||
[!windows] [exec:rm] exec rm -rf $GOPATH/pkg/mod | ||
[!windows] [!exec:rm] go clean -modcache | ||
[windows] [exec:rmdir] exec rmdir /s /q $GOPATH\pkg\mod | ||
[windows] [!exec:rmdir] go clean -modcache | ||
! exists $GOPATH/pkg/mod | ||
|
||
# The directories in the module cache should by default be unwritable, | ||
# so that tests and tools will not accidentally add extraneous files to them. | ||
go get -d rsc.io/quote@latest | ||
[!windows] [!root] ! cp $WORK/extraneous.txt $GOPATH/pkg/mod/rsc.io/[email protected]/go.mod | ||
[!windows] [!root] ! cp $WORK/extraneous.txt $GOPATH/pkg/mod/rsc.io/[email protected]/extraneous_file.go | ||
! exists $GOPATH/pkg/mod/rsc.io/[email protected]/extraneous_file.go | ||
|
||
-- $WORK/extraneous.txt -- | ||
module oops | ||
-- go.mod -- | ||
module golang.org/issue/31481 |