check-safety/check_orchtests.go
Alex Dunmow c4d01de82c feat: concise output + diff-scoped any check
Reporter is now a collector: checks declare a verdict (OK/Skip/Warn/Fail/
Fatal) plus findings, and a single central render() prints output. Default
output is silent on pass/skip — only FAIL/WARN/ERR checks print, followed by
one tally line, so a clean run is two lines. --verbose restores full per-check
output. All ~30 checks were converted to this API; orphaned guidance/label
helpers (printPerTargetOKLines, per-check *Help blocks, colors_format.go) were
removed.

The any-usage check (2e) now defaults to only the unstaged working-tree diff
(changed lines), via a new per-repo git-diff index in changedlines.go; --all-any
restores the full scan. Not-a-git-repo / no-diff warns on nothing.

Golden fixtures regenerated; integration tests updated to the new format; added
unit tests for the diff index.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-04 01:16:56 +08:00

41 lines
1.3 KiB
Go

package main
import "strings"
func init() {
register(Check{
Seq: 31,
ID: "3b",
Title: "Orchestrator backend tests",
Run: func(ctx *ScanContext, rep *Reporter) {
var orchestratorTestTargets []goTestTarget
if ctx.orchestratorOnly {
orchestratorTestTargets = discoverOrchestratorTestTargetsFromRoot(orchestratorRepoRoot())
} else {
orchestratorTestTargets = discoverOrchestratorTestTargets(ctx.repoRoot, ctx.backendDir, ctx.includeCoreTargets)
}
if len(orchestratorTestTargets) > 0 {
completedOrchestratorTargets, orchestratorFailures, orchestratorErr := runGoTestTargets(orchestratorTestTargets)
if orchestratorErr != nil {
rep.Fatal("failed to run orchestrator tests: %v", orchestratorErr)
}
if len(orchestratorFailures) > 0 {
rep.Fail("%d orchestrator test target(s) failed", len(orchestratorFailures))
for _, failure := range orchestratorFailures {
rep.Findingf("[%s] %s", failure.stage, failure.target)
if failure.output != "" {
for line := range strings.SplitSeq(failure.output, "\n") {
rep.Findingf(" %s", line)
}
}
}
} else {
rep.OK("Orchestrator tests clean for %d target(s)", len(completedOrchestratorTargets))
}
} else {
rep.Skip("orchestrator backend not found or not part of this scan")
}
},
})
}