mirror of
https://github.com/golang/go
synced 2024-11-20 09:24:50 -07:00
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: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
3ce46e3e9c
commit
1c08c728dc
@ -2106,11 +2106,16 @@ func TestCoverageWithCgo(t *testing.T) {
|
|||||||
t.Skip("skipping because cgo not enabled")
|
t.Skip("skipping because cgo not enabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
tg := testgo(t)
|
for _, dir := range []string{"cgocover", "cgocover2", "cgocover3", "cgocover4"} {
|
||||||
defer tg.cleanup()
|
t.Run(dir, func(t *testing.T) {
|
||||||
tg.run("test", "-short", "-cover", "./testdata/cgocover")
|
tg := testgo(t)
|
||||||
data := tg.getStdout() + tg.getStderr()
|
defer tg.cleanup()
|
||||||
checkCoverage(tg, data)
|
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) {
|
func TestCgoDependsOnSyscall(t *testing.T) {
|
||||||
|
@ -867,7 +867,7 @@ func (b *builder) test(p *Package) (buildAction, runAction, printAction *action,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
if len(ptest.GoFiles) > 0 {
|
if len(ptest.GoFiles)+len(ptest.CgoFiles) > 0 {
|
||||||
pmain.imports = append(pmain.imports, ptest)
|
pmain.imports = append(pmain.imports, ptest)
|
||||||
t.ImportTest = true
|
t.ImportTest = true
|
||||||
}
|
}
|
||||||
|
19
src/cmd/go/testdata/src/cgocover2/p.go
vendored
Normal file
19
src/cmd/go/testdata/src/cgocover2/p.go
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package p
|
||||||
|
|
||||||
|
/*
|
||||||
|
void
|
||||||
|
f(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
var b bool
|
||||||
|
|
||||||
|
func F() {
|
||||||
|
if b {
|
||||||
|
for {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
C.f()
|
||||||
|
}
|
10
src/cmd/go/testdata/src/cgocover2/x_test.go
vendored
Normal file
10
src/cmd/go/testdata/src/cgocover2/x_test.go
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package p_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
. "cgocover2"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestF(t *testing.T) {
|
||||||
|
F()
|
||||||
|
}
|
19
src/cmd/go/testdata/src/cgocover3/p.go
vendored
Normal file
19
src/cmd/go/testdata/src/cgocover3/p.go
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package p
|
||||||
|
|
||||||
|
/*
|
||||||
|
void
|
||||||
|
f(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
var b bool
|
||||||
|
|
||||||
|
func F() {
|
||||||
|
if b {
|
||||||
|
for {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
C.f()
|
||||||
|
}
|
1
src/cmd/go/testdata/src/cgocover3/p_test.go
vendored
Normal file
1
src/cmd/go/testdata/src/cgocover3/p_test.go
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
package p
|
10
src/cmd/go/testdata/src/cgocover3/x_test.go
vendored
Normal file
10
src/cmd/go/testdata/src/cgocover3/x_test.go
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package p_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
. "cgocover3"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestF(t *testing.T) {
|
||||||
|
F()
|
||||||
|
}
|
1
src/cmd/go/testdata/src/cgocover4/notcgo.go
vendored
Normal file
1
src/cmd/go/testdata/src/cgocover4/notcgo.go
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
package p
|
19
src/cmd/go/testdata/src/cgocover4/p.go
vendored
Normal file
19
src/cmd/go/testdata/src/cgocover4/p.go
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package p
|
||||||
|
|
||||||
|
/*
|
||||||
|
void
|
||||||
|
f(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
var b bool
|
||||||
|
|
||||||
|
func F() {
|
||||||
|
if b {
|
||||||
|
for {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
C.f()
|
||||||
|
}
|
10
src/cmd/go/testdata/src/cgocover4/x_test.go
vendored
Normal file
10
src/cmd/go/testdata/src/cgocover4/x_test.go
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package p_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
. "cgocover4"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestF(t *testing.T) {
|
||||||
|
F()
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user