Skip to content

Commit

Permalink
Filter pkg with tests in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszcl committed Oct 18, 2024
1 parent 66674e5 commit 22afe2a
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions tools/flakeguard/golang/golang.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"os/exec"
"strings"
"sync"

"github.com/smartcontractkit/chainlink-testing-framework/tools/flakeguard/utils"
)
Expand Down Expand Up @@ -185,14 +186,26 @@ func hasTests(pkgName string) (bool, error) {
// Filter out test packages with no actual test functions
func FilterPackagesWithTests(pkgs []string) []string {
var testPkgs []string
var mutex sync.Mutex
var wg sync.WaitGroup

for _, pkg := range pkgs {
hasT, err := hasTests(pkg)
if err != nil {
fmt.Printf("Error checking for tests in package %s: %s\n", pkg, err)
}
if hasT {
testPkgs = append(testPkgs, pkg)
}
wg.Add(1)
go func(p string) {
defer wg.Done()
hasT, err := hasTests(p)
if err != nil {
fmt.Printf("Error checking for tests in package %s: %s\n", p, err)
return
}
if hasT {
mutex.Lock()
testPkgs = append(testPkgs, p)
mutex.Unlock()
}
}(pkg)
}

wg.Wait()
return testPkgs
}

0 comments on commit 22afe2a

Please sign in to comment.