Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go/internal/work: -overlay docs incorrectly exclude go test #66845

Closed
ramosbugs opened this issue Apr 16, 2024 · 2 comments
Closed

cmd/go/internal/work: -overlay docs incorrectly exclude go test #66845

ramosbugs opened this issue Apr 16, 2024 · 2 comments

Comments

@ramosbugs
Copy link

Go version

1.22.1

Output of go env in your module/workspace:

N/A

What did you do?

N/A

What did you see happen?

N/A

What did you expect to see?

46fa8af introduced support for the -overlay flag to go test as of Go 1.17 (see #44946).

However, the docs still state that "overlays will not appear when binaries and tests are run through go run and go test respectively.":

-overlay file
read a JSON config file that provides an overlay for build operations.
The file is a JSON struct with a single field, named 'Replace', that
maps each disk file path (a string) to its backing file path, so that
a build will run as if the disk file path exists with the contents
given by the backing file paths, or as if the disk file path does not
exist if its backing file path is empty. Support for the -overlay flag
has some limitations: importantly, cgo files included from outside the
include path must be in the same directory as the Go package they are
included from, and overlays will not appear when binaries and tests are
run through go run and go test respectively.

I believe that's specifically what 46fa8af changed with respect to go test (I'm not sure about go run).

@cherrymui
Copy link
Member

"overlays will not appear when binaries and tests are run through go run and go test respectively."

I think this meant to say that when the test binary runs (not when the test is built), the overlaid file is not present. I.e. if the test binary itself wants to read foo_test.go during the test execution, it sees the original file, not the overlaid file.

I think this works as intended. @matloob can correct me if I'm mistaken.

@cherrymui cherrymui closed this as not planned Won't fix, can't repro, duplicate, stale Apr 16, 2024
@matloob
Copy link
Contributor

matloob commented Apr 16, 2024

Yes, it's exactly as Cherry wrote.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants