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

     1  # Test listing with overlays
     2  
     3  # Overlay in an existing directory
     4  go list -overlay overlay.json  -f '{{.GoFiles}}' .
     5  stdout '^\[f.go\]$'
     6  
     7  # Overlays in a non-existing directory
     8  go list -overlay overlay.json -f '{{.GoFiles}}' ./dir
     9  stdout '^\[g.go\]$'
    10  
    11  # Overlays in an existing directory with already existing files
    12  go list -overlay overlay.json -f '{{.GoFiles}}' ./dir2
    13  stdout '^\[h.go i.go\]$'
    14  
    15  # Overlay that removes a file from a directory
    16  ! go list ./dir3 # contains a file without a package statement
    17  go list -overlay overlay.json -f '{{.GoFiles}}' ./dir3 # overlay removes that file
    18  
    19  # Walking through an overlay
    20  go list -overlay overlay.json ./...
    21  cmp stdout want-list.txt
    22  
    23  # TODO(#39958): assembly files, C files, files that require cgo preprocessing
    24  
    25  -- want-list.txt --
    26  m
    27  m/dir
    28  m/dir2
    29  m/dir3
    30  -- go.mod --
    31  // TODO(#39958): Support and test overlays including go.mod itself (especially if mod=readonly)
    32  module m
    33  
    34  go 1.16
    35  
    36  -- dir2/h.go --
    37  package dir2
    38  
    39  -- dir3/good.go --
    40  package dir3
    41  -- dir3/bad.go --
    42  // no package statement
    43  -- overlay.json --
    44  {
    45      "Replace": {
    46          "f.go": "overlay/f_go",
    47          "dir/g.go": "overlay/dir_g_go",
    48          "dir2/i.go": "overlay/dir2_i_go",
    49          "dir3/bad.go": ""
    50      }
    51  }
    52  -- overlay/f_go --
    53  package m
    54  
    55  func f() {
    56  }
    57  -- overlay/dir_g_go --
    58  package m
    59  
    60  func g() {
    61  }
    62  -- overlay/dir2_i_go --
    63  package dir2
    64  

View as plain text