1 # Regression test for golang.org/issue/34189 and golang.org/issue/34165:
2 # @latest, @upgrade, and @patch should prefer compatible versions over
3 # +incompatible ones, even if offered by a proxy.
4
5 [!net] skip
6
7 env GO111MODULE=on
8 env GOPROXY=
9 env GOSUMDB=
10
11 # github.com/russross/blackfriday v2.0.0+incompatible exists,
12 # and should be resolved if we ask for v2.0 explicitly.
13
14 go list -m github.com/russross/blackfriday@v2.0
15 stdout '^github.com/russross/blackfriday v2\.0\.0\+incompatible$'
16
17 # blackfriday v1.5.2 has a go.mod file, so v1.5.2 should be preferred over
18 # v2.0.0+incompatible when resolving latest, upgrade, and patch.
19
20 go list -m github.com/russross/blackfriday@latest
21 stdout '^github.com/russross/blackfriday v1\.'
22
23 go list -m github.com/russross/blackfriday@upgrade
24 stdout '^github.com/russross/blackfriday v1\.'
25
26 ! go list -m github.com/russross/blackfriday@patch
27 stderr '^go: github.com/russross/blackfriday@patch: can''t query version "patch" of module github.com/russross/blackfriday: no existing version is required$'
28
29 # If we're fetching directly from version control, ignored +incompatible
30 # versions should also be omitted by 'go list'.
31
32 # (Note that they may still be included in results from a proxy: in proxy mode,
33 # we would need to fetch the whole zipfile for the latest compatible version in
34 # order to determine whether it contains a go.mod file, and part of the point of
35 # the proxy is to avoid fetching unnecessary data.)
36
37 [!exec:git] stop
38 env GOPROXY=direct
39
40 go list -versions -m github.com/russross/blackfriday github.com/russross/blackfriday
41 stdout '^github.com/russross/blackfriday v1\.5\.1 v1\.5\.2' # and possibly others
42 ! stdout ' v2\.'
43
44 # However, if the latest compatible version does not include a go.mod file,
45 # +incompatible versions should still be listed, as they may still reflect the
46 # intent of the module author.
47
48 go list -versions -m github.com/rsc/legacytest
49 stdout '^github.com/rsc/legacytest v1\.0\.0 v1\.1\.0-pre v1\.2\.0 v2\.0\.0\+incompatible'
50
51 # If we're fetching directly from version control, asking for a commit hash
52 # corresponding to a +incompatible version should continue to produce the
53 # +incompatible version tagged for that commit, even if it is no longer listed.
54
55 go list -m github.com/russross/blackfriday@cadec560ec52
56 stdout '^github.com/russross/blackfriday v2\.0\.0\+incompatible$'
57
58 # Similarly, requesting an untagged commit should continue to produce a +incompatible
59 # pseudo-version.
60
61 go list -m github.com/rsc/legacytest@7303f7796364
62 stdout '^github.com/rsc/legacytest v2\.0\.1-0\.20180717164253-7303f7796364\+incompatible$'
63
64 -- go.mod --
65 module github.com/golang.org/issue/34165
66
View as plain text