github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/cmd/go/testdata/script/cover_cgo_xtest.txt (about)

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