Skip to content
This repository was archived by the owner on Aug 17, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions instrumentation/testing/init.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
package testing

import (
"flag"
"reflect"
"testing"

"go.undefinedlabs.com/scopeagent/instrumentation"
"go.undefinedlabs.com/scopeagent/reflection"
)

var (
parallel int
)

// Initialize the testing instrumentation
func Init(m *testing.M) {
flag.Parse()
fPtr := flag.Lookup("test.parallel")
if fPtr != nil {
parallel = (*fPtr).Value.(flag.Getter).Get().(int)
instrumentation.Logger().Println("parallel flag set to:", parallel)
}

if tPointer, err := reflection.GetFieldPointerOf(m, "tests"); err == nil {
intTests := (*[]testing.InternalTest)(tPointer)
tests := make([]testing.InternalTest, 0)
Expand Down
2 changes: 1 addition & 1 deletion instrumentation/testing/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (test *Test) end() {

if testing.CoverMode() != "" {
// Checks if the current test is running parallel to extract the coverage or not
if reflection.GetIsParallel(test.t) {
if reflection.GetIsParallel(test.t) && parallel > 1 {
instrumentation.Logger().Printf("CodePath in parallel test is not supported: %v\n", test.t.Name())
restoreCoverageCounters()
} else if cov := endCoverage(); cov != nil {
Expand Down