...

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

Documentation: cmd/go/testdata/script

     1# This test illustrates a case where an upgrade–downgrade–upgrade cycle could
     2# add extraneous dependencies due to another module depending on an
     3# otherwise-unlisted version (such as a pseudo-version).
     4#
     5# This case corresponds to the "downhiddenartifact" test in the mvs package.
     6
     7# The initial package import graph used in the test looks like:
     8#
     9# a --- b
    10#  \     \
    11#   \     \
    12#    c --- d
    13#
    14# The module dependency graph initially looks like:
    15#
    16# a --- b.3
    17#  \      \
    18#   \      \
    19#   c.2 --- d.2
    20#
    21# c.1 --- b.2 (pseudo)
    22#
    23# b.1 --- e.1
    24
    25cp go.mod go.mod.orig
    26go mod tidy
    27cmp go.mod.orig go.mod
    28
    29# When we downgrade d.2 to d.1, no dependency on e should be added
    30# because nothing else in the module or import graph requires it.
    31go get example.net/d@v0.1.0
    32
    33go list -m all
    34stdout '^example.net/b v0.2.1-0.20210219000000-000000000000 '
    35stdout '^example.net/c v0.1.0 '
    36stdout '^example.net/d v0.1.0 '
    37! stdout '^example.net/e '
    38
    39-- go.mod --
    40module example.net/a
    41
    42go 1.16
    43
    44require (
    45	example.net/b v0.3.0
    46	example.net/c v0.2.0
    47)
    48
    49replace (
    50	example.net/b v0.1.0 => ./b1
    51	example.net/b v0.2.1-0.20210219000000-000000000000 => ./b2
    52	example.net/b v0.3.0 => ./b3
    53	example.net/c v0.1.0 => ./c1
    54	example.net/c v0.2.0 => ./c2
    55	example.net/d v0.1.0 => ./d
    56	example.net/d v0.2.0 => ./d
    57	example.net/e v0.1.0 => ./e
    58)
    59-- a.go --
    60package a
    61
    62import (
    63	_ "example.net/b"
    64	_ "example.net/c"
    65)
    66
    67-- b1/go.mod --
    68module example.net/b
    69
    70go 1.16
    71
    72require example.net/e v0.1.0
    73-- b1/b.go --
    74package b
    75
    76import _ "example.net/e"
    77
    78-- b2/go.mod --
    79module example.net/b
    80
    81go 1.16
    82-- b2/b.go --
    83package b
    84
    85-- b3/go.mod --
    86module example.net/b
    87
    88go 1.16
    89
    90require example.net/d v0.2.0
    91-- b3/b.go --
    92package b
    93
    94import _ "example.net/d"
    95-- c1/go.mod --
    96module example.net/c
    97
    98go 1.16
    99
   100require example.net/b v0.2.1-0.20210219000000-000000000000
   101-- c1/c.go --
   102package c
   103
   104import _ "example.net/b"
   105
   106-- c2/go.mod --
   107module example.net/c
   108
   109go 1.16
   110
   111require example.net/d v0.2.0
   112-- c2/c.go --
   113package c
   114
   115import _ "example.net/d"
   116
   117-- d/go.mod --
   118module example.net/d
   119
   120go 1.16
   121-- d/d.go --
   122package d
   123
   124-- e/go.mod --
   125module example.net/e
   126
   127go 1.16
   128-- e/e.go --
   129package e

View as plain text