...

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

Documentation: cmd/go/testdata/script

     1# go list should skip 'ignore' directives
     2# See golang.org/issue/42965
     3
     4env ROOT=$WORK${/}gopath${/}src
     5
     6# no ignore directive; should not skip any directories.
     7cp go.mod.orig go.mod
     8go list -x ./...
     9stdout 'example/foo/secret'
    10stdout 'example/pkg/foo'
    11stdout 'example/pkg/fo$'
    12! stderr 'ignoring directory'
    13
    14# ignored ./foo should be skipped.
    15cp go.mod.relative go.mod
    16go list -x ./...
    17stdout 'example/pkg/foo'
    18stdout 'example/pkg/fo$'
    19! stdout 'example/foo/secret'
    20stderr 'ignoring directory '$ROOT''${/}'foo'
    21! stderr 'ignoring directory '$ROOT''${/}'pkg'${/}'foo'
    22
    23# ignored foo; any foo should be skipped.
    24cp go.mod.any go.mod
    25go list -x ./...
    26stdout 'example/pkg/fo$'
    27! stdout 'example/pkg/foo'
    28! stdout 'example/foo/secret'
    29stderr 'ignoring directory '$ROOT''${/}'foo'
    30stderr 'ignoring directory '$ROOT''${/}'pkg'${/}'foo'
    31
    32# non-existent ignore; should not skip any directories.
    33cp go.mod.dne go.mod
    34go list -x ./...
    35stdout 'example/foo/secret'
    36stdout 'example/pkg/foo'
    37stdout 'example/pkg/fo$'
    38! stderr 'ignoring directory'
    39
    40# ignored fo; should not skip foo/ and should skip fo/
    41cp go.mod.partial go.mod
    42go list -x ./...
    43! stderr 'ignoring directory '$ROOT''${/}'foo'
    44stderr 'ignoring directory '$ROOT''${/}'pkg'${/}'fo$'
    45! stderr 'ignoring directory '$ROOT''${/}'pkg'${/}'foo'
    46
    47# ignored pkg/foo; should skip pkg/foo/
    48cp go.mod.tree go.mod
    49go list -x ./...
    50stdout 'example/foo/secret'
    51stdout 'example/pkg/fo$'
    52stderr 'ignoring directory '$ROOT''${/}'pkg'${/}'foo'
    53
    54# ignored /pkg/foo/; should skip pkg/foo/
    55cp go.mod.sep1 go.mod
    56go list -x ./...
    57stdout 'example/foo/secret'
    58stdout 'example/pkg/fo$'
    59stderr 'ignoring directory '$ROOT''${/}'pkg'${/}'foo'
    60
    61# ignored pkg/foo/; should skip pkg/foo/
    62cp go.mod.sep2 go.mod
    63go list -x ./...
    64stdout 'example/foo/secret'
    65stdout 'example/pkg/fo$'
    66stderr 'ignoring directory '$ROOT''${/}'pkg'${/}'foo'
    67
    68# ignored /pkg/foo; should skip pkg/foo/
    69cp go.mod.sep3 go.mod
    70go list -x ./...
    71stdout 'example/foo/secret'
    72stdout 'example/pkg/fo$'
    73stderr 'ignoring directory '$ROOT''${/}'pkg'${/}'foo'
    74
    75-- foo/secret/secret.go --
    76package secret
    77
    78const Secret = "this should be ignored"
    79-- pkg/foo/foo.go --
    80package foo
    81
    82const Bar = "Hello from foo!"
    83-- pkg/fo/fo.go --
    84package fo
    85
    86const Gar = "Hello from fo!"
    87-- go.mod.orig --
    88module example
    89
    90go 1.24
    91
    92-- go.mod.relative --
    93module example
    94
    95go 1.24
    96
    97ignore ./foo
    98
    99-- go.mod.any --
   100module example
   101
   102go 1.24
   103
   104ignore foo
   105
   106-- go.mod.dne --
   107module example
   108
   109go 1.24
   110
   111ignore bar
   112
   113-- go.mod.partial --
   114module example
   115
   116go 1.24
   117
   118ignore fo
   119
   120-- go.mod.tree --
   121module example
   122
   123go 1.24
   124
   125ignore pkg/foo
   126
   127-- go.mod.sep1 --
   128module example
   129
   130go 1.24
   131
   132ignore /pkg/foo/
   133
   134-- go.mod.sep2 --
   135module example
   136
   137go 1.24
   138
   139ignore pkg/foo/
   140
   141-- go.mod.sep3 --
   142module example
   143
   144go 1.24
   145
   146ignore /pkg/foo
   147
   148-- main.go --
   149package main
   150
   151func main() {}

View as plain text