aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/testdata/script/mod_prefer_compatible.txt
blob: 1b408c3e9e925d02cf6ea590bc721fb4880b2f7a (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Regression test for golang.org/issue/34189 and golang.org/issue/34165:
# @latest, @upgrade, and @patch should prefer compatible versions over
# +incompatible ones, even if offered by a proxy.

[!net] skip

env GO111MODULE=on
env GOPROXY=
env GOSUMDB=

# github.com/russross/blackfriday v2.0.0+incompatible exists,
# and should be resolved if we ask for v2.0 explicitly.

go list -m github.com/russross/blackfriday@v2.0
stdout '^github.com/russross/blackfriday v2\.0\.0\+incompatible$'

# blackfriday v1.5.2 has a go.mod file, so v1.5.2 should be preferred over
# v2.0.0+incompatible when resolving latest, upgrade, and patch.

go list -m github.com/russross/blackfriday@latest
stdout '^github.com/russross/blackfriday v1\.'

go list -m github.com/russross/blackfriday@upgrade
stdout '^github.com/russross/blackfriday v1\.'

! go list -m github.com/russross/blackfriday@patch
stderr '^go list -m: github.com/russross/blackfriday@patch: can''t query version "patch" of module github.com/russross/blackfriday: no existing version is required$'

# If we're fetching directly from version control, ignored +incompatible
# versions should also be omitted by 'go list'.

# (Note that they may still be included in results from a proxy: in proxy mode,
# we would need to fetch the whole zipfile for the latest compatible version in
# order to determine whether it contains a go.mod file, and part of the point of
# the proxy is to avoid fetching unnecessary data.)

[!exec:git] stop
env GOPROXY=direct

go list -versions -m github.com/russross/blackfriday github.com/russross/blackfriday
stdout '^github.com/russross/blackfriday v1\.5\.1 v1\.5\.2' # and possibly others
! stdout ' v2\.'

# However, if the latest compatible version does not include a go.mod file,
# +incompatible versions should still be listed, as they may still reflect the
# intent of the module author.

go list -versions -m github.com/rsc/legacytest
stdout '^github.com/rsc/legacytest v1\.0\.0 v1\.1\.0-pre v1\.2\.0 v2\.0\.0\+incompatible'

# If we're fetching directly from version control, asking for a commit hash
# corresponding to a +incompatible version should continue to produce the
# +incompatible version tagged for that commit, even if it is no longer listed.

go list -m github.com/russross/blackfriday@cadec560ec52
stdout '^github.com/russross/blackfriday v2\.0\.0\+incompatible$'

# Similarly, requesting an untagged commit should continue to produce a +incompatible
# pseudo-version.

go list -m github.com/rsc/legacytest@7303f7796364
stdout '^github.com/rsc/legacytest v2\.0\.1-0\.20180717164253-7303f7796364\+incompatible$'

-- go.mod --
module github.com/golang.org/issue/34165