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

     1  # This test covers a crazy edge-case involving wildcards and multiple passes of
     2  # patch-upgrades, but if we get it right we probably get many other edge-cases
     3  # right too.
     4  
     5  go list -m all
     6  stdout '^example.net/a v0.1.0 '
     7  ! stdout '^example.net/b '
     8  
     9  
    10  # Requesting pattern example.../b by itself fails: there is no such module
    11  # already in the build list, and the wildcard in the first element prevents us
    12  # from attempting to resolve a new module whose path is a prefix of the pattern.
    13  
    14  ! go get -u=patch example.../b@upgrade
    15  stderr '^go: no modules to query for example\.\.\./b@upgrade because first path element contains a wildcard$'
    16  
    17  
    18  # Patching . causes a patch to example.net/a, which introduces a new match
    19  # for example.net/b/..., which is itself patched and causes another upgrade to
    20  # example.net/a, which is then patched again.
    21  
    22  go get -u=patch . example.../b@upgrade
    23  go list -m all
    24  stdout '^example.net/a v0.2.1 '  # upgraded by dependency of b and -u=patch
    25  stdout '^example.net/b v0.2.0 '  # introduced by patch of a and upgraded by wildcard
    26  
    27  
    28  -- go.mod --
    29  module example
    30  
    31  go 1.16
    32  
    33  require example.net/a v0.1.0
    34  
    35  replace (
    36  	example.net/a v0.1.0 => ./a10
    37  	example.net/a v0.1.1 => ./a11
    38  	example.net/a v0.2.0 => ./a20
    39  	example.net/a v0.2.1 => ./a20
    40  	example.net/b v0.1.0 => ./b1
    41  	example.net/b v0.1.1 => ./b1
    42  	example.net/b v0.2.0 => ./b2
    43  )
    44  -- example.go --
    45  package example
    46  
    47  import _ "example.net/a"
    48  
    49  -- a10/go.mod --
    50  module example.net/a
    51  
    52  go 1.16
    53  -- a10/a.go --
    54  package a
    55  
    56  -- a11/go.mod --
    57  module example.net/a
    58  
    59  go 1.16
    60  
    61  require example.net/b v0.1.0
    62  -- a11/a.go --
    63  package a
    64  -- a11/unimported/unimported.go --
    65  package unimported
    66  
    67  import _ "example.net/b"
    68  
    69  
    70  -- a20/go.mod --
    71  module example.net/a
    72  
    73  go 1.16
    74  -- a20/a.go --
    75  package a
    76  
    77  -- b1/go.mod --
    78  module example.net/b
    79  
    80  go 1.16
    81  -- b1/b.go --
    82  package b
    83  
    84  -- b2/go.mod --
    85  module example.net/b
    86  
    87  go 1.16
    88  
    89  require example.net/a v0.2.0
    90  -- b2/b.go --
    91  package b
    92  -- b2/b_test.go --
    93  package b_test
    94  
    95  import _ "example.net/a"
    96  

View as plain text