blob: a5410764bc00f86469f13173f0bf465d87be9cd4 [file] [log] [blame]
# Regression test for
env GO111MODULE=on
# 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
cp $WORK/extraneous.txt $GOPATH/pkg/mod/
# 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.
[!root] ! cp $WORK/extraneous.txt $GOPATH/pkg/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:cmd.exe] exec cmd.exe /c rmdir /s /q $GOPATH\pkg\mod
[windows] [!exec:cmd.exe] 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.
# Windows does not respect FILE_ATTRIBUTE_READONLY on directories, according
# to MSDN, so there we disable testing whether the directory itself is
# unwritable.
go get -d
[!root] ! cp $WORK/extraneous.txt $GOPATH/pkg/mod/
[!windows] [!root] ! cp $WORK/extraneous.txt $GOPATH/pkg/mod/
! exists $GOPATH/pkg/mod/
# Repeat part of the test with 'go mod download' instead of 'go get' to verify
# -modcacherw is supported on 'go mod' subcommands.
go clean -modcache
go mod download -modcacherw
cp $WORK/extraneous.txt $GOPATH/pkg/mod/
! go mod verify
[!root] ! cp $WORK/extraneous.txt $GOPATH/pkg/mod/
-- $WORK/extraneous.txt --
module oops
-- go.mod --