]> Cypherpunks repositories - gostls13.git/commit
cmd/go: fix coverage rebuild corner case
authorRuss Cox <rsc@golang.org>
Thu, 4 Jan 2018 18:07:44 +0000 (13:07 -0500)
committerRuss Cox <rsc@golang.org>
Thu, 4 Jan 2018 20:11:39 +0000 (20:11 +0000)
commit29208ce548f156d68269bf529dc7605d568a8f67
tree948e99885c0ccb1517ad4e1648bb0e3074ce4af8
parent5d647f2b51d9f54ee990fdd04fd8bc036c43e8de
cmd/go: fix coverage rebuild corner case

If you have a package p1 with an xtest (package p1_test)
that imports p2, where p2 itself imports p1, then when
trying to do coverage for p1 we need to make sure to
recompile p2. The problem was that the overall package
import graph looked like:

    main -> p1_test -> p2 -> p1

Since we were recompiling p1 with coverage, we correctly
figured out that because p2 depends on a package being
recompiled due to coverage, p2 also needs to be split (forked) to
insert the dependency on the modified p1. But then we used
the same logic to split p1_test and main, with the effect that
the changes to p2 and p1_test and main were lost, since the
caller was still holding on to the original main, not the split version.

Change the code to treat main and p1_test as "already split"
and just update them in place.

Fixes #23314.

Change-Id: If7edeca6e39cdaeb5b9380d00b0c7d8c5891f086
Reviewed-on: https://go-review.googlesource.com/86237
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/go/go_test.go
src/cmd/go/internal/test/test.go
src/cmd/go/testdata/src/coverdep2/p1/p.go [new file with mode: 0644]
src/cmd/go/testdata/src/coverdep2/p1/p_test.go [new file with mode: 0644]
src/cmd/go/testdata/src/coverdep2/p2/p2.go [new file with mode: 0644]