Black Lives Matter. Support the Equal Justice Initiative.

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

Documentation: cmd/go/testdata/script

     1  cp go.mod go.mod.orig
     2  
     3  
     4  # If a dependency cannot be resolved, 'go mod tidy' fails with an error message
     5  # explaining the problem and does not update the go.mod file.
     6  # TODO(bcmills): Ideally, with less redundancy than these error messages!
     7  
     8  ! go mod tidy
     9  
    10  stderr '^example.com/untidy imports\n\texample.net/directnotfound: cannot find module providing package example.net/directnotfound: module example.net/directnotfound: reading http://.*: 404 Not Found$'
    11  
    12  stderr '^example.com/untidy imports\n\texample.net/m imports\n\texample.net/indirectnotfound: cannot find module providing package example.net/indirectnotfound: module example.net/indirectnotfound: reading http://.*: 404 Not Found$'
    13  
    14  stderr '^example.com/untidy tested by\n\texample.com/untidy.test imports\n\texample.net/directtestnotfound: cannot find module providing package example.net/directtestnotfound: module example.net/directtestnotfound: reading http://.*: 404 Not Found$'
    15  
    16  stderr '^example.com/untidy imports\n\texample.net/m tested by\n\texample.net/m.test imports\n\texample.net/indirecttestnotfound: cannot find module providing package example.net/indirecttestnotfound: module example.net/indirecttestnotfound: reading http://.*: 404 Not Found$'
    17  
    18  cmp go.mod.orig go.mod
    19  
    20  
    21  # If a dependency cannot be resolved, 'go mod vendor' fails with an error message
    22  # explaining the problem, does not update the go.mod file, and does not create
    23  # the vendor directory.
    24  
    25  ! go mod vendor
    26  
    27  stderr '^example.com/untidy imports\n\texample.net/directnotfound: cannot find module providing package example.net/directnotfound: module example.net/directnotfound: reading http://.*: 404 Not Found$'
    28  
    29  stderr '^example.com/untidy imports\n\texample.net/m imports\n\texample.net/indirectnotfound: cannot find module providing package example.net/indirectnotfound: module example.net/indirectnotfound: reading http://.*: 404 Not Found$'
    30  
    31  stderr '^example.com/untidy tested by\n\texample.com/untidy.test imports\n\texample.net/directtestnotfound: cannot find module providing package example.net/directtestnotfound: module example.net/directtestnotfound: reading http://.*: 404 Not Found$'
    32  
    33  ! stderr 'indirecttestnotfound'  # Vendor prunes test dependencies.
    34  
    35  cmp go.mod.orig go.mod
    36  ! exists vendor
    37  
    38  
    39  # 'go mod tidy' still logs the errors, but succeeds and updates go.mod.
    40  
    41  go mod tidy -e
    42  stderr -count=4 'cannot find module providing package'
    43  cmp go.mod.final go.mod
    44  
    45  
    46  # 'go mod vendor -e' still logs the errors, but succeeds and updates go.mod.
    47  
    48  cp go.mod.orig go.mod
    49  go mod vendor -e
    50  stderr -count=3 'cannot find module providing package'
    51  cmp go.mod.final go.mod
    52  exists vendor/modules.txt
    53  exists vendor/example.net/m/m.go
    54  
    55  
    56  -- go.mod --
    57  module example.com/untidy
    58  go 1.16
    59  replace example.net/m v0.1.0 => ./m
    60  -- go.mod.final --
    61  module example.com/untidy
    62  
    63  go 1.16
    64  
    65  replace example.net/m v0.1.0 => ./m
    66  
    67  require example.net/m v0.1.0
    68  -- untidy.go --
    69  package untidy
    70  
    71  import (
    72  	_ "example.net/m"
    73  	_ "example.net/directnotfound"
    74  )
    75  -- untidy_test.go --
    76  package untidy_test
    77  
    78  import _ "example.net/directtestnotfound"
    79  -- m/go.mod --
    80  module example.net/m
    81  go 1.16
    82  -- m/m.go --
    83  package m
    84  
    85  import _ "example.net/indirectnotfound"
    86  -- m/m_test.go --
    87  package m_test
    88  
    89  import _ "example.net/indirecttestnotfound"
    90  

View as plain text