]> git.ipfire.org Git - thirdparty/gcc.git/blob - libgo/go/cmd/go/testdata/script/mod_readonly.txt
libgo: update to Go1.14rc1 release
[thirdparty/gcc.git] / libgo / go / cmd / go / testdata / script / mod_readonly.txt
1 env GO111MODULE=on
2 [short] skip
3
4 # -mod=readonly must not resolve missing modules nor update go.mod
5 env GOFLAGS=-mod=readonly
6 go mod edit -fmt
7 cp go.mod go.mod.empty
8 ! go list all
9 stderr '^can''t load package: x.go:2:8: cannot find module providing package rsc\.io/quote: import lookup disabled by -mod=readonly'
10 cmp go.mod go.mod.empty
11
12 # -mod=readonly should be set implicitly if the go.mod file is read-only
13 chmod 0400 go.mod
14 env GOFLAGS=
15 ! go list all
16 stderr '^can''t load package: x.go:2:8: cannot find module providing package rsc\.io/quote: import lookup disabled by -mod=readonly\n\t\(go.mod file is read-only\.\)$'
17
18 chmod 0600 go.mod
19 env GOFLAGS=-mod=readonly
20
21 # update go.mod - go get allowed
22 go get rsc.io/quote
23 grep rsc.io/quote go.mod
24
25 # update go.mod - go mod tidy allowed
26 cp go.mod.empty go.mod
27 go mod tidy
28 cp go.mod go.mod.tidy
29
30 # -mod=readonly must succeed once go.mod is up-to-date...
31 go list all
32
33 # ... even if it needs downloads
34 go clean -modcache
35 go list all
36
37 # -mod=readonly must not cause 'go list -m' to fail.
38 # (golang.org/issue/36478)
39 go list -m all
40 ! stderr 'cannot query module'
41
42 # -mod=readonly should reject inconsistent go.mod files
43 # (ones that would be rewritten).
44 go mod edit -require rsc.io/sampler@v1.2.0
45 cp go.mod go.mod.inconsistent
46 ! go list
47 stderr 'go: updates to go.mod needed, disabled by -mod=readonly'
48 cmp go.mod go.mod.inconsistent
49
50 # However, it should not reject files missing a 'go' directive,
51 # since that was not always required.
52 cp go.mod.nogo go.mod
53 go list all
54
55 # Nor should it reject files with redundant (not incorrect)
56 # requirements.
57 cp go.mod.redundant go.mod
58 go list all
59
60 cp go.mod.indirect go.mod
61 go list all
62
63 -- go.mod --
64 module m
65
66 go 1.20
67
68 -- x.go --
69 package x
70 import _ "rsc.io/quote"
71 -- go.mod.nogo --
72 module m
73
74 require (
75 rsc.io/quote v1.5.2
76 rsc.io/testonly v1.0.0 // indirect
77 )
78 -- go.mod.redundant --
79 module m
80
81 go 1.20
82
83 require (
84 rsc.io/quote v1.5.2
85 rsc.io/sampler v1.3.0 // indirect
86 rsc.io/testonly v1.0.0 // indirect
87 )
88 -- go.mod.indirect --
89 module m
90
91 go 1.20
92
93 require (
94 rsc.io/quote v1.5.2 // indirect
95 rsc.io/sampler v1.3.0 // indirect
96 rsc.io/testonly v1.0.0 // indirect
97 )