github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/cmd/go/testdata/script/mod_list_bad_import.txt (about)

     1  # This test matches list_bad_import, but in module mode.
     2  # Please keep them in sync.
     3  
     4  env GO111MODULE=on
     5  cd example.com
     6  
     7  # Without -e, listing an otherwise-valid package with an unsatisfied direct import should fail.
     8  # BUG: Today it succeeds.
     9  go list -f '{{if .Error}}error{{end}} {{if .Incomplete}}incomplete{{end}} {{range .DepsErrors}}bad dep: {{.Err}}{{end}}' example.com/direct
    10  ! stdout ^error
    11  stdout 'incomplete'
    12  stdout 'bad dep: .*example.com/notfound'
    13  
    14  # Listing with -deps should also fail.
    15  # BUG: Today, it does not.
    16  # ! go list -deps example.com/direct
    17  # stderr example.com/notfound
    18  go list -deps example.com/direct
    19  stdout example.com/notfound
    20  
    21  
    22  # Listing an otherwise-valid package that imports some *other* package with an
    23  # unsatisfied import should also fail.
    24  # BUG: Today, it succeeds.
    25  go list -f '{{if .Error}}error{{end}} {{if .Incomplete}}incomplete{{end}} {{range .DepsErrors}}bad dep: {{.Err}}{{end}}' example.com/indirect
    26  ! stdout ^error
    27  stdout incomplete
    28  stdout 'bad dep: .*example.com/notfound'
    29  
    30  # Again, -deps should fail.
    31  # BUG: Again, it does not.
    32  # ! go list -deps example.com/indirect
    33  # stderr example.com/notfound
    34  go list -deps example.com/indirect
    35  stdout example.com/notfound
    36  
    37  
    38  # Listing the missing dependency directly should fail outright...
    39  ! go list -f '{{if .Error}}error{{end}} {{if .Incomplete}}incomplete{{end}}' example.com/notfound
    40  stderr 'cannot find module providing package example.com/notfound'
    41  ! stdout error
    42  ! stdout incomplete
    43  
    44  # ...but listing with -e should succeed.
    45  go list -e -f '{{if .Error}}error{{end}} {{if .Incomplete}}incomplete{{end}}' example.com/notfound
    46  stdout error
    47  stdout incomplete
    48  
    49  
    50  # The pattern "all" should match only packages that actually exist,
    51  # ignoring those whose existence is merely implied by imports.
    52  go list -e -f '{{.ImportPath}} {{.Error}}' all
    53  stdout example.com/direct
    54  stdout example.com/indirect
    55  # TODO: go list creates a dummy package with the import-not-found
    56  # but really the Error belongs on example.com/direct, and this package
    57  # should not be printed.
    58  # ! stdout example.com/notfound
    59  
    60  
    61  -- example.com/go.mod --
    62  module example.com
    63  
    64  -- example.com/direct/direct.go --
    65  package direct
    66  import _ "example.com/notfound"
    67  
    68  -- example.com/indirect/indirect.go --
    69  package indirect
    70  import _ "example.com/direct"
    71  
    72  -- example.com/notfound/README --
    73  This directory intentionally left blank.