-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
proposal: testing: set an environment variable to indicate we're in a test #66122
Comments
I wonder if the variable should contain some more metadata — perhaps the package path under test? (The test can theoretically infer that itself from its working directory, but if the test starts a Separately, I have been wondering whether |
This partially duplicates the Is this something that would be broadly useful, given If this is mostly just needed for the
(Only subprocesses that are created with an inherited environment.) |
Thanks for filing this issue. For a motivating example: gopls invokes the Go command thousands of times during its test suite, on tiny workspaces, with various non-standard permutations of settings. We don't want these invocations to drown out or pollute data collected from "real" uses of the Go command, either directly from the command line or during a real gopls session. And while there may be few developers working on gopls, there are many other tools that integrate with the Go command in tests. I think we need some sort of across-the-board solution like this, though I don't feel strongly about the details of the solution. |
The flip-side of that is: if there are features of the Go toolchain that are primarily useful in tests, and users are actually relying on them there, then it would be nice to have telemetry for that usage so that we don't incidentally break those tests. |
I agree with @findleyr that we need some sort of across-the-board solution and I also don't feel strongly about the details of the solution. The reason why |
I'll retract this proposal. We've decided it's okay to capture data from testing. |
Proposal Details
This proposal is to have the testing package set a new GO_TESTING environment variable, perhaps for the duration of
testing.(*M).Run
, to indicate that it's running a test. This would allow subprocesses started by the test to know that they're running as part of a test.This is useful so that the Go toolchain could suppress telemetry when it's invoked by a test to avoid contaminating users' telemetry data.
@bcmills @adonovan @findleyr
The text was updated successfully, but these errors were encountered: