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