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

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