os,os/exec: should Environ record environment variables in the test log? #60057
Labels
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone
Since CL 81895,
os.Getenv
andos.LookupEnv
both record the keys in the test log:https://cs.opensource.google/go/go/+/master:src/os/env.go;l=98-115;drc=b2faff18ce28edad98303d2c3134dec1331fd7b5
However,
os.Environ
does not:https://cs.opensource.google/go/go/+/master:src/os/env.go;l=137-141;drc=b2faff18ce28edad98303d2c3134dec1331fd7b5
This means that, for example, a program that iterates over
os.Environ()
looking for keys has different caching behavior than one that callsLookupEnv
on those exact same keys. This difference is especially pronounced in tests that execute subprocesses, because the variables accessed by the subprocess (which may be very significant, especially in the case of libraries likegolang.org/x/tools/go/packages
!) do not end up recorded in the cache key.(For example, see the odd-looking
Getenv
loop intestenv.GoToolPath
!)It's not obvious to me whether the difference is an intentional decision or an oversight. Either way, I think we should consider recording all keys in the test log whenever
os.Environ
orexecenv.Default
is called.(CC @ianlancetaylor)
The text was updated successfully, but these errors were encountered: