a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
35 lines
982 B
Go
35 lines
982 B
Go
package codeowners_test
|
|
|
|
import (
|
|
"sync"
|
|
"testing"
|
|
|
|
"github.com/zzet/gortex/internal/codeowners"
|
|
)
|
|
|
|
// TestMatchFile_ConcurrentNoRace exercises MatchFile from many goroutines over
|
|
// a single shared rule list — the way the indexer's per-file coverage
|
|
// goroutines (applyCoverageDomains) call it. Pre-fix, matchPattern lazily
|
|
// compiled and cached r.matcher without synchronisation, so concurrent first
|
|
// calls raced on the shared *Rule (and on the half-published GitIgnore). Run
|
|
// under -race; it must be clean.
|
|
func TestMatchFile_ConcurrentNoRace(t *testing.T) {
|
|
rules := codeowners.Parse([]byte(
|
|
"*.go @gophers\n" +
|
|
"/docs/ @writers\n" +
|
|
"src/**/*.ts @frontend @core\n" +
|
|
"*.md @docs\n",
|
|
))
|
|
paths := []string{"main.go", "docs/readme.md", "src/a/b/c.ts", "x/y/z.py", "pkg/foo.go", "README.md"}
|
|
|
|
var wg sync.WaitGroup
|
|
for range 64 {
|
|
wg.Go(func() {
|
|
for i := range 200 {
|
|
_ = codeowners.MatchFile(paths[i%len(paths)], rules)
|
|
}
|
|
})
|
|
}
|
|
wg.Wait()
|
|
}
|