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

     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  
     7  go test -short -cover cgocover2
     8  stdout  'coverage:.*[1-9][0-9.]+%'
     9  ! stderr '[^0-9]0\.0%'
    10  
    11  -- go.mod --
    12  module cgocover2
    13  
    14  go 1.16
    15  -- p.go --
    16  package p
    17  
    18  /*
    19  void
    20  f(void)
    21  {
    22  }
    23  */
    24  import "C"
    25  
    26  var b bool
    27  
    28  func F() {
    29  	if b {
    30  		for {
    31  		}
    32  	}
    33  	C.f()
    34  }
    35  -- x_test.go --
    36  package p_test
    37  
    38  import (
    39  	. "cgocover2"
    40  	"testing"
    41  )
    42  
    43  func TestF(t *testing.T) {
    44  	F()
    45  }
    46  

View as plain text