]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: make vet work with -overlay
authorRuss Cox <rsc@golang.org>
Sun, 17 Nov 2024 21:52:25 +0000 (16:52 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 19 Nov 2024 19:46:57 +0000 (19:46 +0000)
It never worked before, an apparent oversight.
This will also make tests work, since tests run vet.

The new FIPS mode will use overlays, so this was
keeping go test from working in that mode.

Fixes #44957.

Change-Id: I3a77846b3b3f9a3a53118aaece93ee93214a36a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/629199
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
src/cmd/go/internal/work/exec.go
src/cmd/go/testdata/script/build_overlay.txt

index 2fa950f13b85b4b617377e5426104c294841e681..70d9a588cc4d23810ba25e336d16d9b8450ea385 100644 (file)
@@ -858,7 +858,7 @@ OverlayLoop:
                embed.Patterns = p.Internal.Embed
                embed.Files = make(map[string]string)
                for _, file := range p.EmbedFiles {
-                       embed.Files[file] = filepath.Join(p.Dir, file)
+                       embed.Files[file] = fsys.Actual(filepath.Join(p.Dir, file))
                }
                js, err := json.MarshalIndent(&embed, "", "\t")
                if err != nil {
@@ -1175,9 +1175,9 @@ func buildVetConfig(a *Action, srcfiles []string) {
                ID:           a.Package.ImportPath,
                Compiler:     cfg.BuildToolchainName,
                Dir:          a.Package.Dir,
-               GoFiles:      mkAbsFiles(a.Package.Dir, gofiles),
-               NonGoFiles:   mkAbsFiles(a.Package.Dir, nongofiles),
-               IgnoredFiles: mkAbsFiles(a.Package.Dir, ignored),
+               GoFiles:      actualFiles(mkAbsFiles(a.Package.Dir, gofiles)),
+               NonGoFiles:   actualFiles(mkAbsFiles(a.Package.Dir, nongofiles)),
+               IgnoredFiles: actualFiles(mkAbsFiles(a.Package.Dir, ignored)),
                ImportPath:   a.Package.ImportPath,
                ImportMap:    make(map[string]string),
                PackageFile:  make(map[string]string),
@@ -3383,6 +3383,15 @@ func mkAbsFiles(dir string, files []string) []string {
        return abs
 }
 
+// actualFiles applies fsys.Actual to the list of files.
+func actualFiles(files []string) []string {
+       a := make([]string, len(files))
+       for i, f := range files {
+               a[i] = fsys.Actual(f)
+       }
+       return a
+}
+
 // passLongArgsInResponseFiles modifies cmd such that, for
 // certain programs, long arguments are passed in "response files", a
 // file on disk with the arguments, with one arg per line. An actual
index b64bc0261422ab2b8a403daa9661daa37417a7d9..1111d119ba28417b84802ec1a4631552e11a294c 100644 (file)
@@ -22,6 +22,8 @@ go build -overlay overlay.json -o print_abspath$GOEXE ./printpath
 exec ./print_abspath$GOEXE
 stdout $WORK[/\\]gopath[/\\]src[/\\]m[/\\]printpath[/\\]main.go
 
+go vet -overlay overlay.json ./printpath
+
 go build -overlay overlay.json -o print_trimpath$GOEXE -trimpath ./printpath
 exec ./print_trimpath$GOEXE
 stdout ^m[/\\]printpath[/\\]main.go