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

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

View as plain text