Skip to content
Open
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
3 changes: 3 additions & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5t
golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY=
golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc=
golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8=
golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0=
golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI=
golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8=
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY=
golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210=
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/telemetry v0.0.0-20250710130107-8d8967aff50b/go.mod h1:4ZwOYna0/zsOKwuR5X/m0QFOJpSZvAxFfkQT+Erd9D4=
golang.org/x/telemetry v0.0.0-20250807160809-1a19826ec488/go.mod h1:fGb/2+tgXXjhjHsTNdVEEMZNWA0quBnfrO+AfoDSAKw=
golang.org/x/telemetry v0.0.0-20250908211612-aef8a434d053/go.mod h1:+nZKN+XVh4LCiA9DV3ywrzN4gumyCnKjau3NGb9SGoE=
golang.org/x/telemetry v0.0.0-20251008203120-078029d740a8/go.mod h1:Pi4ztBfryZoJEkyFTI5/Ocsu2jXyDr6iSdgJiYE/uwE=
golang.org/x/term v0.33.0/go.mod h1:s18+ql9tYWp1IfpV9DmCtQDDSRBUjKaw9M1eAv5UeF0=
golang.org/x/term v0.36.0 h1:zMPR+aF8gfksFprF/Nc/rd1wRS1EI6nDBGyWAvDzx2Q=
golang.org/x/term v0.36.0/go.mod h1:Qu394IJq6V6dCBRgwqshf3mPF85AqzYEzofzRdZkWss=
golang.org/x/tools v0.37.0/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w=
32 changes: 32 additions & 0 deletions internal/rule_tester/rule_tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,20 @@ func RunRuleTester(rootDir string, tsconfigPath string, t *testing.T, r *rule.Ru
onlyMode := slices.ContainsFunc(validTestCases, func(c ValidTestCase) bool { return c.Only }) ||
slices.ContainsFunc(invalidTestCases, func(c InvalidTestCase) bool { return c.Only })

// Track test statistics
var statsMu sync.Mutex
failedCount := 0
totalCount := len(validTestCases) + len(invalidTestCases)

// Print summary if any tests failed
t.Cleanup(func() {
statsMu.Lock()
defer statsMu.Unlock()
if failedCount > 0 {
t.Logf("❌ summary: %d/%d test cases passed", totalCount-failedCount, totalCount)
}
})

runLinter := func(t *testing.T, code string, options any, tsconfigPathOverride string, tsx bool) []rule.RuleDiagnostic {
var diagnosticsMu sync.Mutex
diagnostics := make([]rule.RuleDiagnostic, 0, 3)
Expand Down Expand Up @@ -116,6 +130,15 @@ func RunRuleTester(rootDir string, tsconfigPath string, t *testing.T, r *rule.Ru
t.SkipNow()
}

// Track if this test fails
t.Cleanup(func() {
if t.Failed() {
statsMu.Lock()
failedCount++
statsMu.Unlock()
}
})

diagnostics := runLinter(t, testCase.Code, testCase.Options, testCase.TSConfig, testCase.Tsx)
if len(diagnostics) != 0 {
// TODO: pretty errors
Expand All @@ -135,6 +158,15 @@ func RunRuleTester(rootDir string, tsconfigPath string, t *testing.T, r *rule.Ru
t.SkipNow()
}

// Track if this test fails
t.Cleanup(func() {
if t.Failed() {
statsMu.Lock()
failedCount++
statsMu.Unlock()
}
})

var initialDiagnostics []rule.RuleDiagnostic
outputs := make([]string, 0, 1)
code := testCase.Code
Expand Down