On 24/08/2018 18:00, Ian Lance Taylor wrote:
On Fri, Aug 24, 2018 at 8:31 AM, Steven Hartland <ste...@multiplay.co.uk> wrote:
Hi all I've just been banging my head why test our linux test env isn't
caching tests and found that its down to -exec.

The docs (https://golang.org/cmd/go/#hdr-Build_and_test_caching) refer to
cacheable "test" flags but doesn't mention standard non-test flags.

In addition to this GODEBUG=gocachetest=1 reports all cases where it
disables caching except when there is a execCmd which simply skips setting
-test.testlogfile:
https://github.com/golang/go/blob/master/src/cmd/go/internal/test/test.go#L1107

This was the most frustrating part as it meant hacking the runtime to figure
out why caching was not working.

So two question:

Is disabling test caching with -exec really intended and why?
Would it be acceptable to have to option to cache with -exec?

In terms of background, we use -exec so we change the binary permissions so
the tests run correctly, it changes CAP's, without which the test wont run.
I'm sorry you had to hack the runtime, but I do want to mention that
this is documented at https://golang.org/cmd/go/#hdr-Test_packages:

     The rule for a match in the cache is that the run involves the
same test binary and the flags on the command line come entirely from
a restricted set of 'cacheable' test flags, defined as -cpu, -list,
-parallel, -run, -short, and -v. If a run of go test has any test or
non-test flags outside this set, the result is not cached.

To me it seems reasonable that we should be able to cache test results
if -exec is specified, though of course it means that the cache would
need to include the -exec argument in the cache key.  I suggest that
you open a feature request for that at https://golang.org/issue.
Thanks.

Ian
Thanks for the feedback Ian.

Issue https://golang.org/issue/27207 raised, as you've see, and PR to fix also pushed https://go-review.googlesource.com/c/go/+/131415

Fix was simple in the end as ExecCmd is already included in the cache.ActionID for tests, so only required removing the extra condition from builderRunTest and docs update, reviews appreciated.

    Regards
    Steve

--
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to