> I interpret that to mean you are changing the umask before running `go test`. That is, you might run `go test` with different umask values and don't want the cached results to ignore the umask value. As did Ian if I correctly understood their reply. The discussion then evolved into how a specific unit test can safely change the umask without affecting other unit tests. Running unit tests with different umask values is a different problem from how to write unit tests that modify the umask value.
That is correct. Unfortunately there seems to be a lack of knowledge in some cases of what umask is and how it behaves, which is why the discussion got sidetracked.
> At this point it is unclear, at least to me, what problem you are trying to solve.
I want go test to invalidate its cache when the umask is changed, i.e. I want the following sequence of commands to work correctly:
$ umask 002
$ go test ./...
$ umask 022
$ go test ./... # should not use cache
$ go test ./... # should use cache
Currently, the go test cache does not record the umask, so it incorrectly re-uses the cached test results in the second invocation of go test. It should instead invalidate the cache.
Note that go test does record the external files used by the tests and the external environment variables used by the tests, and so it correctly invalidates the cache when any of them change. I would like the cache to also be invalidated when the external umask changes. Alternately put, go test already has special case code for external changes to files and environment variables, and I would like extend that to external umask changes too.
Hope this makes my request clearer.
I'd be delighted to submit at CL to do this (it's probably 10-20 lines of code with almost no performance penalty [1]), but I want to check that it has a reasonable chance to being accepted before I start the work.
[1] The performance cost is two very fast syscalls during startup.