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

     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  
    25  cp go.mod go.mod.orig
    26  go mod tidy
    27  cmp 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.
    31  go get example.net/d@v0.1.0
    32  
    33  go list -m all
    34  stdout '^example.net/b v0.2.1-0.20210219000000-000000000000 '
    35  stdout '^example.net/c v0.1.0 '
    36  stdout '^example.net/d v0.1.0 '
    37  ! stdout '^example.net/e '
    38  
    39  -- go.mod --
    40  module example.net/a
    41  
    42  go 1.16
    43  
    44  require (
    45  	example.net/b v0.3.0
    46  	example.net/c v0.2.0
    47  )
    48  
    49  replace (
    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 --
    60  package a
    61  
    62  import (
    63  	_ "example.net/b"
    64  	_ "example.net/c"
    65  )
    66  
    67  -- b1/go.mod --
    68  module example.net/b
    69  
    70  go 1.16
    71  
    72  require example.net/e v0.1.0
    73  -- b1/b.go --
    74  package b
    75  
    76  import _ "example.net/e"
    77  
    78  -- b2/go.mod --
    79  module example.net/b
    80  
    81  go 1.16
    82  -- b2/b.go --
    83  package b
    84  
    85  -- b3/go.mod --
    86  module example.net/b
    87  
    88  go 1.16
    89  
    90  require example.net/d v0.2.0
    91  -- b3/b.go --
    92  package b
    93  
    94  import _ "example.net/d"
    95  -- c1/go.mod --
    96  module example.net/c
    97  
    98  go 1.16
    99  
   100  require example.net/b v0.2.1-0.20210219000000-000000000000
   101  -- c1/c.go --
   102  package c
   103  
   104  import _ "example.net/b"
   105  
   106  -- c2/go.mod --
   107  module example.net/c
   108  
   109  go 1.16
   110  
   111  require example.net/d v0.2.0
   112  -- c2/c.go --
   113  package c
   114  
   115  import _ "example.net/d"
   116  
   117  -- d/go.mod --
   118  module example.net/d
   119  
   120  go 1.16
   121  -- d/d.go --
   122  package d
   123  
   124  -- e/go.mod --
   125  module example.net/e
   126  
   127  go 1.16
   128  -- e/e.go --
   129  package e
   130  

View as plain text