aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/testdata/script/install_modcacherw_issue64282.txt
blob: 3e1e6e562a3f7ae51f2c9ac2d923a120c37a9991 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Regression test for https://go.dev/issue/64282.
#
# 'go install' and 'go run' with pkg@version arguments should make
# a best effort to parse flags relevant to downloading modules
# (currently only -modcacherw) before actually downloading the module
# to identify which toolchain version to use.
#
# However, the best-effort flag parsing should not interfere with
# actual flag parsing if we don't switch toolchains. In particular,
# unrecognized flags should still be diagnosed after the module for
# the requested package has been downloaded and checked for toolchain
# upgrades.


! go install -cake=delicious -modcacherw example.com/printversion@v0.1.0
stderr '^flag provided but not defined: -cake$'
	# Because the -modcacherw flag was set, we should be able to modify the contents
	# of a directory within the module cache.
cp $WORK/extraneous.txt $GOPATH/pkg/mod/example.com/printversion@v0.1.0/extraneous_file.go
go clean -modcache


! go install -unknownflag -tags -modcacherw example.com/printversion@v0.1.0
stderr '^flag provided but not defined: -unknownflag$'
cp $WORK/extraneous.txt $GOPATH/pkg/mod/example.com/printversion@v0.1.0/extraneous_file.go
go clean -modcache


# Also try it with a 'go install' that succeeds.
# (But skip in short mode, because linking a binary is expensive.)
[!short] go install -modcacherw example.com/printversion@v0.1.0
[!short] cp $WORK/extraneous.txt $GOPATH/pkg/mod/example.com/printversion@v0.1.0/extraneous_file.go
[!short] go clean -modcache


# The flag should also be applied if given in GOFLAGS
# instead of on the command line.
env GOFLAGS=-modcacherw
! go install -cake=delicious example.com/printversion@v0.1.0
stderr '^flag provided but not defined: -cake$'
cp $WORK/extraneous.txt $GOPATH/pkg/mod/example.com/printversion@v0.1.0/extraneous_file.go


-- $WORK/extraneous.txt --
This is not a Go source file.