...

Text file src/cmd/go/testdata/script/cover_cgo_xtest.txt

Documentation: cmd/go/testdata/script

     1[short] skip
     2[!cgo] skip
     3[compiler:gccgo] skip # gccgo has no cover tool
     4
     5# Test cgo coverage with an external test.
     6
     7go test -short -cover cgocover2
     8stdout  'coverage:.*[1-9][0-9.]+%'
     9! stderr '[^0-9]0\.0%'
    10
    11-- go.mod --
    12module cgocover2
    13
    14go 1.16
    15-- p.go --
    16package p
    17
    18/*
    19void
    20f(void)
    21{
    22}
    23*/
    24import "C"
    25
    26var b bool
    27
    28func F() {
    29	if b {
    30		for {
    31		}
    32	}
    33	C.f()
    34}
    35-- x_test.go --
    36package p_test
    37
    38import (
    39	. "cgocover2"
    40	"testing"
    41)
    42
    43func TestF(t *testing.T) {
    44	F()
    45}

View as plain text