...

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

Documentation: cmd/go/testdata/script

     1# Test listing with overlays
     2
     3# Overlay in an existing directory
     4go list -overlay overlay.json  -f '{{.GoFiles}}' .
     5stdout '^\[f.go\]$'
     6
     7# Overlays in a non-existing directory
     8go list -overlay overlay.json -f '{{.GoFiles}}' ./dir
     9stdout '^\[g.go\]$'
    10
    11# Overlays in an existing directory with already existing files
    12go list -overlay overlay.json -f '{{.GoFiles}}' ./dir2
    13stdout '^\[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
    17go list -overlay overlay.json -f '{{.GoFiles}}' ./dir3 # overlay removes that file
    18
    19# Walking through an overlay
    20go list -overlay overlay.json ./...
    21cmp stdout want-list.txt
    22
    23# TODO(#39958): assembly files, C files, files that require cgo preprocessing
    24
    25-- want-list.txt --
    26m
    27m/dir
    28m/dir2
    29m/dir3
    30-- go.mod --
    31// TODO(#39958): Support and test overlays including go.mod itself (especially if mod=readonly)
    32module m
    33
    34go 1.16
    35
    36-- dir2/h.go --
    37package dir2
    38
    39-- dir3/good.go --
    40package 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 --
    53package m
    54
    55func f() {
    56}
    57-- overlay/dir_g_go --
    58package m
    59
    60func g() {
    61}
    62-- overlay/dir2_i_go --
    63package dir2

View as plain text