...

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

Documentation: cmd/go/testdata/script

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

View as plain text