Commit 1c08c728 authored by Russ Cox's avatar Russ Cox

cmd/go: fix coverage in xtest of cgo package

Cover-annotated cgo-rebuilt package for xtest was
not linked into package graph and so not being rebuilt.
Link into package graph.

Fixes #13625.

Change-Id: I685f7276f92bbc85fbc4b389111c83d9fe517637
Reviewed-on: https://go-review.googlesource.com/32614
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent 3ce46e3e
......@@ -2106,11 +2106,16 @@ func TestCoverageWithCgo(t *testing.T) {
t.Skip("skipping because cgo not enabled")
}
tg := testgo(t)
defer tg.cleanup()
tg.run("test", "-short", "-cover", "./testdata/cgocover")
data := tg.getStdout() + tg.getStderr()
checkCoverage(tg, data)
for _, dir := range []string{"cgocover", "cgocover2", "cgocover3", "cgocover4"} {
t.Run(dir, func(t *testing.T) {
tg := testgo(t)
defer tg.cleanup()
tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata"))
tg.run("test", "-short", "-cover", dir)
data := tg.getStdout() + tg.getStderr()
checkCoverage(tg, data)
})
}
}
func TestCgoDependsOnSyscall(t *testing.T) {
......
......@@ -867,7 +867,7 @@ func (b *builder) test(p *Package) (buildAction, runAction, printAction *action,
if err != nil {
return nil, nil, nil, err
}
if len(ptest.GoFiles) > 0 {
if len(ptest.GoFiles)+len(ptest.CgoFiles) > 0 {
pmain.imports = append(pmain.imports, ptest)
t.ImportTest = true
}
......
package p
/*
void
f(void)
{
}
*/
import "C"
var b bool
func F() {
if b {
for {
}
}
C.f()
}
package p_test
import (
. "cgocover2"
"testing"
)
func TestF(t *testing.T) {
F()
}
package p
/*
void
f(void)
{
}
*/
import "C"
var b bool
func F() {
if b {
for {
}
}
C.f()
}
package p_test
import (
. "cgocover3"
"testing"
)
func TestF(t *testing.T) {
F()
}
package p
/*
void
f(void)
{
}
*/
import "C"
var b bool
func F() {
if b {
for {
}
}
C.f()
}
package p_test
import (
. "cgocover4"
"testing"
)
func TestF(t *testing.T) {
F()
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment