...

Text file src/cmd/go/testdata/script/mod_get_downup_indirect.txt

Documentation: cmd/go/testdata/script

     1# This test illustrates a case where downgrading one module may upgrade another.
     2# Compare to the downcross1 test case in cmd/go/internal/mvs/mvs_test.go.
     3
     4# The package import graph used in this test looks like:
     5#
     6# a ---- b
     7#   \     \
     8#    \     \
     9#     ----- c ---- d
    10#
    11# The module dependency graph originally looks like:
    12#
    13# a ---- b.2
    14#   \      \
    15#    \      \
    16#     ----- c.1 ---- d.2
    17#
    18# b.1 ---- c.2
    19#
    20# If we downgrade module d to version 1, we must downgrade b as well.
    21# If that downgrade selects b version 1, we will upgrade module c to version 2.
    22
    23cp go.mod go.mod.orig
    24go mod tidy
    25cmp go.mod.orig go.mod
    26
    27# Downgrading d to version 1 downgrades b, which upgrades c.
    28go get example.com/d@v0.1.0
    29go list -m all
    30stdout '^example.com/b v0.1.0 '
    31stdout '^example.com/c v0.2.0 '
    32stdout '^example.com/d v0.1.0 '
    33cmp go.mod go.mod.down1
    34
    35# Restoring c to version 1 upgrades d to meet c's requirements.
    36go get example.com/c@v0.1.0
    37go list -m all
    38! stdout '^example.com/b '
    39stdout '^example.com/c v0.1.0 '
    40stdout '^example.com/d v0.2.0 '
    41cmp go.mod go.mod.down2
    42
    43# If a user explicitly requests the incompatible versions together,
    44# 'go get' should explain why they are not compatible.
    45! go get example.com/c@v0.1.0 example.com/d@v0.1.0
    46stderr '^go: example\.com/c@v0\.1\.0 requires example\.com/d@v0\.2\.0, not example\.com/d@v0\.1\.0'
    47
    48-- go.mod --
    49module example.com/a
    50
    51go 1.15
    52
    53require (
    54	example.com/b v0.2.0
    55	example.com/c v0.1.0
    56)
    57
    58replace (
    59	example.com/b v0.1.0 => ./b1
    60	example.com/b v0.2.0 => ./b2
    61	example.com/c v0.1.0 => ./c1
    62	example.com/c v0.2.0 => ./c2
    63	example.com/d v0.1.0 => ./d
    64	example.com/d v0.2.0 => ./d
    65)
    66-- go.mod.down1 --
    67module example.com/a
    68
    69go 1.15
    70
    71require (
    72	example.com/b v0.1.0
    73	example.com/c v0.2.0
    74	example.com/d v0.1.0 // indirect
    75)
    76
    77replace (
    78	example.com/b v0.1.0 => ./b1
    79	example.com/b v0.2.0 => ./b2
    80	example.com/c v0.1.0 => ./c1
    81	example.com/c v0.2.0 => ./c2
    82	example.com/d v0.1.0 => ./d
    83	example.com/d v0.2.0 => ./d
    84)
    85-- go.mod.down2 --
    86module example.com/a
    87
    88go 1.15
    89
    90require example.com/c v0.1.0
    91
    92replace (
    93	example.com/b v0.1.0 => ./b1
    94	example.com/b v0.2.0 => ./b2
    95	example.com/c v0.1.0 => ./c1
    96	example.com/c v0.2.0 => ./c2
    97	example.com/d v0.1.0 => ./d
    98	example.com/d v0.2.0 => ./d
    99)
   100-- a.go --
   101package a
   102
   103import (
   104	_ "example.com/b"
   105	_ "example.com/c"
   106)
   107
   108-- b1/go.mod --
   109module example.com/b
   110
   111go 1.15
   112
   113require example.com/c v0.2.0
   114-- b1/b.go --
   115package b
   116
   117import _ "example.com/c"
   118
   119-- b2/go.mod --
   120module example.com/b
   121
   122go 1.15
   123
   124require example.com/c v0.1.0
   125-- b2/b.go --
   126package b
   127
   128import _ "example.com/c"
   129
   130-- c1/go.mod --
   131module example.com/c
   132
   133go 1.15
   134
   135require example.com/d v0.2.0
   136-- c1/c.go --
   137package c
   138
   139-- c2/go.mod --
   140module example.com/c
   141
   142go 1.15
   143-- c2/c.go --
   144package c
   145
   146-- d/go.mod --
   147module example.com/d
   148
   149go 1.15

View as plain text