@holmes-lab/holmes-kit 0.39.0 → 0.40.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +578 -6
- package/README.md +120 -41
- package/dist/.build-id +1 -1
- package/dist/holmes/admission/core/admission-policy.d.ts +37 -0
- package/dist/holmes/admission/core/admission-policy.js +147 -0
- package/dist/holmes/admission/core/bounded-reader.d.ts +56 -0
- package/dist/holmes/admission/core/bounded-reader.js +135 -0
- package/dist/holmes/admission/core/change-classifier.d.ts +34 -0
- package/dist/holmes/admission/core/change-classifier.js +278 -0
- package/dist/holmes/admission/core/config-loader.d.ts +30 -0
- package/dist/holmes/admission/core/config-loader.js +145 -0
- package/dist/holmes/admission/core/event-judgement.d.ts +37 -0
- package/dist/holmes/admission/core/event-judgement.js +251 -0
- package/dist/holmes/admission/core/path-rules.d.ts +35 -0
- package/dist/holmes/admission/core/path-rules.js +88 -0
- package/dist/holmes/admission/core/pin.d.ts +7 -0
- package/dist/holmes/admission/core/pin.js +29 -0
- package/dist/holmes/admission/core/ports.d.ts +48 -0
- package/dist/holmes/admission/core/ports.js +11 -0
- package/dist/holmes/admission/core/range-resolver.d.ts +32 -0
- package/dist/holmes/admission/core/range-resolver.js +51 -0
- package/dist/holmes/admission/core/self-containment.d.ts +1 -0
- package/dist/holmes/admission/core/self-containment.js +125 -0
- package/dist/holmes/admission/core/signature-source.d.ts +9 -0
- package/dist/holmes/admission/core/signature-source.js +4 -0
- package/dist/holmes/admission/core/transition-planner.d.ts +15 -0
- package/dist/holmes/admission/core/transition-planner.js +14 -0
- package/dist/holmes/admission/core/verdict.d.ts +38 -0
- package/dist/holmes/admission/core/verdict.js +17 -0
- package/dist/holmes/admission/core/wiring.d.ts +44 -0
- package/dist/holmes/admission/core/wiring.js +618 -0
- package/dist/holmes/admission/forge/git-object-port.d.ts +4 -0
- package/dist/holmes/admission/forge/git-object-port.js +132 -0
- package/dist/holmes/assoc/assoc-arm.d.ts +1 -1
- package/dist/holmes/assoc/assoc-arm.js +1 -1
- package/dist/holmes/cli/agents.d.ts +8 -0
- package/dist/holmes/cli/agents.js +9 -5
- package/dist/holmes/cli/approve-cli.d.ts +2 -0
- package/dist/holmes/cli/approve-cli.js +392 -0
- package/dist/holmes/cli/approve-ref.d.ts +13 -7
- package/dist/holmes/cli/approve-ref.js +30 -10
- package/dist/holmes/cli/approve-status.d.ts +26 -2
- package/dist/holmes/cli/approve-status.js +98 -18
- package/dist/holmes/cli/approve-watch.d.ts +5 -0
- package/dist/holmes/cli/approve-watch.js +10 -5
- package/dist/holmes/cli/approve.d.ts +49 -13
- package/dist/holmes/cli/approve.js +249 -67
- package/dist/holmes/cli/attest.js +2 -1
- package/dist/holmes/cli/autonomy.d.ts +4 -1
- package/dist/holmes/cli/autonomy.js +17 -10
- package/dist/holmes/cli/codex-oracle.d.ts +11 -0
- package/dist/holmes/cli/codex-oracle.js +5 -1
- package/dist/holmes/cli/codex-toml.d.ts +10 -0
- package/dist/holmes/cli/codex-toml.js +36 -2
- package/dist/holmes/cli/doctor-boundary.d.ts +76 -0
- package/dist/holmes/cli/doctor-boundary.js +308 -0
- package/dist/holmes/cli/doctor-locks.d.ts +15 -0
- package/dist/holmes/cli/doctor-locks.js +119 -0
- package/dist/holmes/cli/doctor.d.ts +2 -0
- package/dist/holmes/cli/doctor.js +34 -5
- package/dist/holmes/cli/flags.d.ts +23 -0
- package/dist/holmes/cli/flags.js +89 -0
- package/dist/holmes/cli/index.d.ts +5 -1
- package/dist/holmes/cli/index.js +226 -442
- package/dist/holmes/cli/init.js +33 -0
- package/dist/holmes/cli/interactive-prompt.d.ts +39 -2
- package/dist/holmes/cli/interactive-prompt.js +98 -16
- package/dist/holmes/cli/lock-recover.d.ts +5 -0
- package/dist/holmes/cli/lock-recover.js +126 -0
- package/dist/holmes/cli/mcp-processes.js +1 -1
- package/dist/holmes/cli/release-docs.js +1 -1
- package/dist/holmes/cli/run-exec.d.ts +141 -0
- package/dist/holmes/cli/run-exec.js +1435 -0
- package/dist/holmes/cli/run-provision.d.ts +3 -1
- package/dist/holmes/cli/run-provision.js +255 -44
- package/dist/holmes/cli/run-wiring.d.ts +69 -0
- package/dist/holmes/cli/run-wiring.js +270 -0
- package/dist/holmes/cli/run.d.ts +21 -0
- package/dist/holmes/cli/run.js +341 -92
- package/dist/holmes/cli/runtime-binding-approval.js +32 -19
- package/dist/holmes/cli/screen-safe.d.ts +3 -92
- package/dist/holmes/cli/screen-safe.js +18 -756
- package/dist/holmes/config/config.d.ts +19 -0
- package/dist/holmes/config/config.js +18 -3
- package/dist/holmes/cpg/foundation/language-matrix.js +2 -2
- package/dist/holmes/cpg/import-resolver.js +1 -1
- package/dist/holmes/governance/approval-decisions.d.ts +47 -0
- package/dist/holmes/governance/approval-decisions.js +29 -0
- package/dist/holmes/governance/approval-grants.d.ts +220 -1
- package/dist/holmes/governance/approval-grants.js +612 -33
- package/dist/holmes/governance/approval-queue.d.ts +26 -0
- package/dist/holmes/governance/approval-queue.js +109 -11
- package/dist/holmes/governance/approval-spend.d.ts +95 -0
- package/dist/holmes/governance/approval-spend.js +191 -0
- package/dist/holmes/governance/autonomous-shell.d.ts +61 -0
- package/dist/holmes/governance/autonomous-shell.js +332 -0
- package/dist/holmes/governance/autonomy.d.ts +12 -0
- package/dist/holmes/governance/autonomy.js +51 -15
- package/dist/holmes/governance/constitution.d.ts +5 -0
- package/dist/holmes/governance/constitution.js +32 -12
- package/dist/holmes/governance/full-autonomy.d.ts +10 -0
- package/dist/holmes/governance/full-autonomy.js +103 -7
- package/dist/holmes/governance/harness-catalog.d.ts +103 -0
- package/dist/holmes/governance/harness-catalog.js +348 -0
- package/dist/holmes/governance/human-channel.d.ts +38 -0
- package/dist/holmes/governance/human-channel.js +49 -0
- package/dist/holmes/governance/install-manifest.d.ts +22 -0
- package/dist/holmes/governance/install-manifest.js +160 -0
- package/dist/holmes/governance/ledger-rechain.js +2 -0
- package/dist/holmes/governance/ledger-store.conformance.d.ts +7 -1
- package/dist/holmes/governance/ledger-store.conformance.js +66 -0
- package/dist/holmes/governance/ledger-store.d.ts +88 -11
- package/dist/holmes/governance/ledger-store.js +186 -8
- package/dist/holmes/governance/provenance-chain.d.ts +16 -4
- package/dist/holmes/governance/provenance-chain.js +19 -4
- package/dist/holmes/governance/provenance-ledger.d.ts +6 -3
- package/dist/holmes/governance/provenance-ledger.js +53 -18
- package/dist/holmes/governance/push-gate-runner.d.ts +2 -0
- package/dist/holmes/governance/push-gate-runner.js +50 -9
- package/dist/holmes/governance/push-gate.d.ts +13 -2
- package/dist/holmes/governance/push-gate.js +106 -14
- package/dist/holmes/governance/recorded-pairs.d.ts +96 -0
- package/dist/holmes/governance/recorded-pairs.js +522 -0
- package/dist/holmes/governance/replica-id.d.ts +1 -1
- package/dist/holmes/governance/replica-id.js +1 -1
- package/dist/holmes/governance/spec-seam.d.ts +59 -0
- package/dist/holmes/governance/spec-seam.js +587 -0
- package/dist/holmes/governance/spend-kinds.d.ts +16 -0
- package/dist/holmes/governance/spend-kinds.js +18 -0
- package/dist/holmes/guardrail/advisory-line.d.ts +102 -0
- package/dist/holmes/guardrail/advisory-line.js +718 -0
- package/dist/holmes/guardrail/decision-ledger.d.ts +2 -1
- package/dist/holmes/guardrail/decision-ledger.js +2 -1
- package/dist/holmes/guardrail/impact-gate.d.ts +7 -0
- package/dist/holmes/guardrail/impact-gate.js +33 -6
- package/dist/holmes/guardrail/line-continuation.d.ts +8 -0
- package/dist/holmes/guardrail/line-continuation.js +39 -0
- package/dist/holmes/guardrail/operator-person.d.ts +28 -4
- package/dist/holmes/guardrail/operator-person.js +57 -11
- package/dist/holmes/guardrail/refusal-codes.d.ts +8 -3
- package/dist/holmes/guardrail/refusal-codes.js +64 -10
- package/dist/holmes/guardrail/risk-classifier.d.ts +15 -9
- package/dist/holmes/guardrail/risk-classifier.js +228 -16
- package/dist/holmes/guardrail/risk-gate.d.ts +2 -8
- package/dist/holmes/guardrail/risk-gate.js +7 -34
- package/dist/holmes/guardrail/risk-types.d.ts +10 -0
- package/dist/holmes/guardrail/run-plan-scope.js +3 -1
- package/dist/holmes/guardrail/run-refusals.js +24 -8
- package/dist/holmes/guardrail/run-stages.d.ts +5 -0
- package/dist/holmes/guardrail/run-stages.js +25 -5
- package/dist/holmes/guardrail/scope-judgment.js +1 -1
- package/dist/holmes/guardrail/shell-words.js +24 -3
- package/dist/holmes/guardrail/unresolved-write.d.ts +40 -0
- package/dist/holmes/guardrail/unresolved-write.js +556 -0
- package/dist/holmes/guardrail/write-target.d.ts +3 -0
- package/dist/holmes/guardrail/write-target.js +26 -5
- package/dist/holmes/hooks/pre-tool-use.d.ts +116 -1
- package/dist/holmes/hooks/pre-tool-use.js +1176 -170
- package/dist/holmes/hooks/rtm-refresh-child.d.ts +1 -1
- package/dist/holmes/hooks/rtm-refresh-child.js +1 -1
- package/dist/holmes/hooks/session-start.js +17 -1
- package/dist/holmes/hooks/stop.d.ts +23 -0
- package/dist/holmes/hooks/stop.js +86 -33
- package/dist/holmes/mcp/approval-adapters.js +3 -1
- package/dist/holmes/mcp/approval-commit.js +3 -2
- package/dist/holmes/mcp/approval-policy.d.ts +2 -1
- package/dist/holmes/mcp/approval-policy.js +3 -1
- package/dist/holmes/mcp/handlers/adoption.d.ts +1 -1
- package/dist/holmes/mcp/handlers/approval-ask.d.ts +3 -0
- package/dist/holmes/mcp/handlers/approval-ask.js +18 -7
- package/dist/holmes/mcp/handlers/entity-integration.d.ts +3 -3
- package/dist/holmes/mcp/handlers/entity-integration.js +29 -11
- package/dist/holmes/mcp/handlers/entity-renumber.d.ts +4 -4
- package/dist/holmes/mcp/handlers/entity-renumber.js +29 -11
- package/dist/holmes/mcp/handlers/entity-store.d.ts +2 -2
- package/dist/holmes/mcp/handlers/entity-store.js +133 -59
- package/dist/holmes/mcp/handlers/maintenance-analysis.d.ts +13 -0
- package/dist/holmes/mcp/handlers/maintenance-analysis.js +59 -2
- package/dist/holmes/mcp/handlers/operator-inspection.d.ts +9 -5
- package/dist/holmes/mcp/handlers/operator-inspection.js +79 -16
- package/dist/holmes/mcp/handlers/phase-queries.d.ts +1 -1
- package/dist/holmes/mcp/handlers/requirement-triage.d.ts +4 -4
- package/dist/holmes/mcp/handlers/review-evidence.d.ts +2 -2
- package/dist/holmes/mcp/handlers/review-evidence.js +35 -11
- package/dist/holmes/mcp/handlers/review-queries.d.ts +5 -0
- package/dist/holmes/mcp/handlers/review-queries.js +8 -1
- package/dist/holmes/mcp/handlers/review-verdict.d.ts +3 -0
- package/dist/holmes/mcp/handlers/review-verdict.js +10 -3
- package/dist/holmes/mcp/handlers/risk-assessment.d.ts +7 -2
- package/dist/holmes/mcp/handlers/risk-assessment.js +34 -12
- package/dist/holmes/mcp/handlers/runtime-binding-tool.d.ts +2 -2
- package/dist/holmes/mcp/handlers/slice-orchestration.d.ts +6 -1
- package/dist/holmes/mcp/handlers/slice-orchestration.js +14 -1
- package/dist/holmes/mcp/handlers/spec-approval.d.ts +15 -3
- package/dist/holmes/mcp/handlers/spec-approval.js +32 -5
- package/dist/holmes/mcp/handlers/spec-authoring.d.ts +2 -2
- package/dist/holmes/mcp/handlers/spec-authoring.js +19 -2
- package/dist/holmes/mcp/handlers/spec-lifecycle.d.ts +11 -38
- package/dist/holmes/mcp/handlers/spec-lifecycle.js +441 -94
- package/dist/holmes/mcp/handlers/spec-queries.d.ts +2 -2
- package/dist/holmes/mcp/handlers/taint-screening.d.ts +1 -1
- package/dist/holmes/mcp/handlers/taint-screening.js +2 -2
- package/dist/holmes/mcp/handlers/test-execution.d.ts +471 -4
- package/dist/holmes/mcp/handlers/test-execution.js +199 -21
- package/dist/holmes/mcp/handlers/workspace-queries.d.ts +2 -2
- package/dist/holmes/mcp/handlers.d.ts +557 -82
- package/dist/holmes/mcp/handlers.js +74 -23
- package/dist/holmes/mcp/harness-attestation.d.ts +78 -5
- package/dist/holmes/mcp/harness-attestation.js +325 -53
- package/dist/holmes/mcp/maintenance-analyze.d.ts +6 -1
- package/dist/holmes/mcp/maintenance-analyze.js +13 -11
- package/dist/holmes/mcp/maintenance-evidence.d.ts +9 -0
- package/dist/holmes/mcp/maintenance-evidence.js +35 -3
- package/dist/holmes/mcp/requirement-triage-evidence.js +22 -13
- package/dist/holmes/mcp/server-staleness.js +1 -1
- package/dist/holmes/mcp/server.js +9 -8
- package/dist/holmes/mcp/spec-id-guard.js +1 -1
- package/dist/holmes/mcp/tool-schemas.d.ts +13 -0
- package/dist/holmes/mcp/tool-schemas.js +42 -9
- package/dist/holmes/project/act-root.d.ts +19 -0
- package/dist/holmes/project/act-root.js +100 -0
- package/dist/holmes/project/baseline.d.ts +15 -2
- package/dist/holmes/project/baseline.js +14 -8
- package/dist/holmes/project/bounded-group.d.ts +47 -0
- package/dist/holmes/project/bounded-group.js +140 -0
- package/dist/holmes/project/bounded-io.d.ts +51 -2
- package/dist/holmes/project/bounded-io.js +140 -6
- package/dist/holmes/project/change-source.d.ts +4 -0
- package/dist/holmes/project/change-source.js +14 -6
- package/dist/holmes/project/instance-id.d.ts +10 -0
- package/dist/holmes/project/instance-id.js +233 -0
- package/dist/holmes/project/machine-identity.d.ts +25 -0
- package/dist/holmes/project/machine-identity.js +133 -0
- package/dist/holmes/project/owned-lock.d.ts +84 -0
- package/dist/holmes/project/owned-lock.js +263 -0
- package/dist/holmes/project/plain-lock-fs.d.ts +2 -0
- package/dist/holmes/project/plain-lock-fs.js +126 -0
- package/dist/holmes/project/request-lock.d.ts +85 -0
- package/dist/holmes/project/request-lock.js +459 -0
- package/dist/holmes/project/root.d.ts +12 -4
- package/dist/holmes/project/root.js +29 -8
- package/dist/holmes/project/run-records.d.ts +19 -0
- package/dist/holmes/project/run-records.js +94 -12
- package/dist/holmes/project/screen-text.d.ts +94 -0
- package/dist/holmes/project/screen-text.js +763 -0
- package/dist/holmes/project/spend-lock.d.ts +82 -0
- package/dist/holmes/project/spend-lock.js +413 -0
- package/dist/holmes/refresh/freshness-coordinator.d.ts +1 -1
- package/dist/holmes/refresh/freshness-coordinator.js +1 -1
- package/dist/holmes/review/condition-hunk-replay.js +4 -2
- package/dist/holmes/review/confidence-calibration.d.ts +1 -1
- package/dist/holmes/review/confidence-calibration.js +1 -1
- package/dist/holmes/review/content-verify.js +1 -1
- package/dist/holmes/review/evidence-mode.d.ts +21 -0
- package/dist/holmes/review/evidence-mode.js +33 -0
- package/dist/holmes/review/head-worktree.d.ts +55 -0
- package/dist/holmes/review/head-worktree.js +329 -0
- package/dist/holmes/review/hop-ablation.d.ts +4 -4
- package/dist/holmes/review/hop-ablation.js +5 -5
- package/dist/holmes/review/mrp.js +13 -3
- package/dist/holmes/review/point-in-time-replay.js +12 -3
- package/dist/holmes/review/rank-diagnosis.d.ts +2 -2
- package/dist/holmes/review/rank-diagnosis.js +1 -1
- package/dist/holmes/review/replay-corpus.d.ts +10 -4
- package/dist/holmes/review/replay-corpus.js +25 -9
- package/dist/holmes/review/requirement-triage.js +2 -2
- package/dist/holmes/review/run-provenance.d.ts +45 -0
- package/dist/holmes/review/run-provenance.js +314 -0
- package/dist/holmes/review/semantic-arm.d.ts +3 -3
- package/dist/holmes/review/semantic-arm.js +3 -3
- package/dist/holmes/review/test-evidence.d.ts +174 -0
- package/dist/holmes/review/test-evidence.js +330 -2
- package/dist/holmes/review/test-outcomes.js +3 -1
- package/dist/holmes/review/test-reports.d.ts +94 -0
- package/dist/holmes/review/test-reports.js +382 -0
- package/dist/holmes/review/test-runner.d.ts +180 -58
- package/dist/holmes/review/test-runner.js +560 -324
- package/dist/holmes/review/test-selection-breadth.js +2 -2
- package/dist/holmes/review/test-units.d.ts +159 -0
- package/dist/holmes/review/test-units.js +814 -0
- package/dist/holmes/review/verdicts.d.ts +105 -8
- package/dist/holmes/review/verdicts.js +640 -36
- package/dist/holmes/rtm/anchor-census.d.ts +9 -0
- package/dist/holmes/rtm/anchor-census.js +151 -0
- package/dist/holmes/rtm/anchor-ids.d.ts +25 -1
- package/dist/holmes/rtm/anchor-ids.js +45 -2
- package/dist/holmes/rtm/comment-ranges.d.ts +2 -0
- package/dist/holmes/rtm/comment-ranges.js +104 -0
- package/dist/holmes/rtm/counted-tests.d.ts +1 -0
- package/dist/holmes/rtm/counted-tests.js +63 -0
- package/dist/holmes/rtm/impact-advisory.d.ts +1 -1
- package/dist/holmes/rtm/known-defects.js +1 -1
- package/dist/holmes/rtm/localize.js +1 -1
- package/dist/holmes/rtm/taint-benchmark.d.ts +1 -1
- package/dist/holmes/rtm/taint-vocabulary.d.ts +1 -1
- package/dist/holmes/rtm/test-scope.d.ts +31 -0
- package/dist/holmes/rtm/test-scope.js +166 -5
- package/dist/holmes/rtm/trace-gaps.js +1 -1
- package/dist/holmes/runtime/dispatch.d.ts +10 -0
- package/dist/holmes/runtime/dispatch.js +12 -1
- package/dist/holmes/semantic/cloud-usage.d.ts +1 -1
- package/dist/holmes/semantic/cloud-usage.js +1 -1
- package/dist/holmes/semantic/unreadable-paths.d.ts +1 -1
- package/dist/holmes/semantic/unreadable-paths.js +1 -1
- package/dist/holmes/spec/approval-blockers.js +1 -1
- package/dist/holmes/spec/entity-store.d.ts +6 -1
- package/dist/holmes/spec/entity-store.js +16 -2
- package/dist/holmes/spec/entity-transaction.d.ts +7 -2
- package/dist/holmes/spec/entity-transaction.js +87 -170
- package/dist/holmes/spec/spec-store.d.ts +12 -6
- package/dist/holmes/spec/spec-store.js +4 -2
- package/dist/holmes/spec/spec-types.js +1 -1
- package/dist/holmes/spec/succession-guard.d.ts +56 -0
- package/dist/holmes/spec/succession-guard.js +187 -0
- package/dist/holmes/spec/succession.d.ts +70 -0
- package/dist/holmes/spec/succession.js +171 -0
- package/dist/holmes/spec/transition-policy.d.ts +2 -2
- package/docs/install-guide.md +9 -3
- package/docs/language-support.md +78 -0
- package/package.json +4 -3
- package/playbooks/author-slice/PLAYBOOK.md +1 -1
- package/playbooks/promote-slice/PLAYBOOK.md +5 -1
- package/playbooks/publish/PLAYBOOK.md +47 -34
- package/dist/holmes/review/manual-baseline.d.ts +0 -209
- package/dist/holmes/review/manual-baseline.js +0 -2847
|
@@ -33,16 +33,15 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.TAIL_MAX_CHARS = exports.RUNNER_TIMEOUT_MS = void 0;
|
|
36
|
+
exports.TAIL_MAX_CHARS = exports.UNSUPPORTED = exports.readJestReport = exports.wellShapedJson = exports.parseJUnitXmlFiles = exports.parseJUnitXmlOutcomes = exports.parseJUnitXmlCounts = exports.classifyJestOutcomes = exports.parseExecutedCounts = exports.goPackagesWithTestEvents = exports.parseGoTestJson = exports.projectFiles = exports.pytestRules = exports.BUILD_ROOTS = exports.normaliseExcludeDirs = exports.excludedDir = exports.scanEcosystems = exports.RUNNER_TIMEOUT_MS = void 0;
|
|
37
|
+
exports.runBounded = runBounded;
|
|
38
|
+
exports.runnerStopNote = runnerStopNote;
|
|
37
39
|
exports.planTestRun = planTestRun;
|
|
38
40
|
exports.ecosystemOf = ecosystemOf;
|
|
39
|
-
exports.parseGoTestJson = parseGoTestJson;
|
|
40
|
-
exports.parseExecutedCounts = parseExecutedCounts;
|
|
41
|
-
exports.classifyJestOutcomes = classifyJestOutcomes;
|
|
42
|
-
exports.parseJUnitXmlCounts = parseJUnitXmlCounts;
|
|
43
41
|
exports.jestEntry = jestEntry;
|
|
42
|
+
exports.testRunTimeoutMinutes = testRunTimeoutMinutes;
|
|
43
|
+
exports.testRunWorkers = testRunWorkers;
|
|
44
44
|
exports.runJestOutcomes = runJestOutcomes;
|
|
45
|
-
exports.parseJUnitXmlOutcomes = parseJUnitXmlOutcomes;
|
|
46
45
|
exports.detectProjectEcosystems = detectProjectEcosystems;
|
|
47
46
|
exports.runPytest = runPytest;
|
|
48
47
|
exports.parseCargoTest = parseCargoTest;
|
|
@@ -51,13 +50,18 @@ exports.runGradle = runGradle;
|
|
|
51
50
|
exports.runDotnet = runDotnet;
|
|
52
51
|
exports.runGo = runGo;
|
|
53
52
|
exports.runTestScope = runTestScope;
|
|
53
|
+
exports.runEcosystems = runEcosystems;
|
|
54
|
+
exports.coverageAfterRun = coverageAfterRun;
|
|
55
|
+
exports.environmentReason = environmentReason;
|
|
54
56
|
exports.tailOf = tailOf;
|
|
55
57
|
exports.failedTestSummary = failedTestSummary;
|
|
58
|
+
exports.redJestTail = redJestTail;
|
|
56
59
|
exports.summarizeJestJson = summarizeJestJson;
|
|
57
|
-
// @implements A-SPEC-102.1
|
|
60
|
+
// @implements A-SPEC-102.1, A-SPEC-128.4, A-SPEC-128.5, A-SPEC-128.6, A-SPEC-128.7, A-SPEC-128.8, A-SPEC-128.9, A-SPEC-128.10, A-SPEC-128.11, A-SPEC-128.12, A-SPEC-128.13
|
|
58
61
|
// @implements A-SPEC-647
|
|
59
|
-
// @implements A-SPEC-734
|
|
62
|
+
// @implements A-SPEC-734, A-SPEC-466.1, A-SPEC-466.2, A-SPEC-466.3, A-SPEC-466.4, A-SPEC-466.5, A-SPEC-466.6
|
|
60
63
|
const node_child_process_1 = require("node:child_process");
|
|
64
|
+
const bounded_group_1 = require("../project/bounded-group");
|
|
61
65
|
const fs = __importStar(require("node:fs"));
|
|
62
66
|
const os = __importStar(require("node:os"));
|
|
63
67
|
const path = __importStar(require("node:path"));
|
|
@@ -65,6 +69,10 @@ const path = __importStar(require("node:path"));
|
|
|
65
69
|
// `--version` probes above stay as they are: they do not judge anything.
|
|
66
70
|
const root_1 = require("../project/root");
|
|
67
71
|
const python_env_1 = require("./python-env");
|
|
72
|
+
const test_units_1 = require("./test-units");
|
|
73
|
+
const test_reports_1 = require("./test-reports");
|
|
74
|
+
const test_units_2 = require("./test-units");
|
|
75
|
+
const run_provenance_1 = require("./run-provenance");
|
|
68
76
|
// Runner stdout ceiling. Measured 2026-09-01 on this repo: a full `jest --json` for 289 suites /
|
|
69
77
|
// 4568 tests emits >2MB, and execFileSync's DEFAULT maxBuffer (1MB) kills the child with ENOBUFS —
|
|
70
78
|
// so a GREEN suite reported `passed: false`, twice, with no failing test named (the baseline never
|
|
@@ -80,16 +88,35 @@ exports.RUNNER_TIMEOUT_MS = 30 * 60_000;
|
|
|
80
88
|
const PROBE_TIMEOUT_MS = 10_000;
|
|
81
89
|
/** Round 14: the stop is recorded here and appended AFTER the runner's tail is taken (`tailOf` cut it — measured). */
|
|
82
90
|
let STOPPED = null;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
/**
|
|
92
|
+
* @implements A-SPEC-734.3 — the child leads a process group of its own (POSIX), and a child stopped at the bound takes
|
|
93
|
+
* that group with it: SIGKILL to the child alone left jest's forked workers running at 100% CPU (two per stopped run,
|
|
94
|
+
* 2026-10-26). The group id is the pid of the child this call spawned, ended as soon as the call returns. Windows has
|
|
95
|
+
* no groups; there the child alone is stopped, as before. Otherwise execFileSync's contract: stdout on exit 0, else a
|
|
96
|
+
* throw carrying stdout, stderr, status and code.
|
|
97
|
+
*/
|
|
98
|
+
/** @implements A-SPEC-466.6 — the bound of the run in progress; `runTestScope` sets it from timeoutMinutes. */
|
|
99
|
+
let RUN_BUDGET_MS = exports.RUNNER_TIMEOUT_MS;
|
|
100
|
+
function runBounded(cmd, args, opts, timeoutMs = RUN_BUDGET_MS) {
|
|
101
|
+
// @implements A-SPEC-734.4 — the group's whole lifetime lives in bounded-group: a watch shim ends it when this process
|
|
102
|
+
// goes, and the call ends it on the bound, an overflow or a signal, or when members outlive a normal exit
|
|
103
|
+
const { result: r, stopped, leftovers } = (0, bounded_group_1.boundedGroupSpawnSync)(cmd, args, opts, timeoutMs);
|
|
104
|
+
if (leftovers)
|
|
105
|
+
LEFTOVER = '[holmes-kit] the runner left processes in its group after it exited; they were ended';
|
|
106
|
+
if (!r.error && r.status === 0)
|
|
107
|
+
return r.stdout;
|
|
108
|
+
const e = (r.error ?? new Error(`Command failed: ${[cmd, ...args].join(' ')}\n${r.stderr ?? ''}`));
|
|
109
|
+
// execFileSync's fields, `output` included
|
|
110
|
+
Object.assign(e, { status: r.status, signal: r.signal, stdout: r.stdout, stderr: r.stderr, pid: r.pid, output: r.output });
|
|
111
|
+
if (stopped)
|
|
112
|
+
STOPPED = `[holmes-kit] the test run was stopped after ${boundText(timeoutMs)} — not judged`;
|
|
113
|
+
throw e;
|
|
92
114
|
}
|
|
115
|
+
/** @implements A-SPEC-734.4 — the bound in minutes, or in seconds below a minute. */
|
|
116
|
+
const boundText = (ms) => (ms >= 60_000 ? `${Math.round(ms / 60_000)} minutes` : `${Math.round(ms / 1000)} seconds`);
|
|
117
|
+
let LEFTOVER = null;
|
|
118
|
+
/** @implements A-SPEC-734.4 — the last stop note (tests read it). */
|
|
119
|
+
function runnerStopNote() { return STOPPED; }
|
|
93
120
|
function planTestRun(scope) {
|
|
94
121
|
if (scope.tier === 'full') {
|
|
95
122
|
return { mode: 'full', testFiles: [], reason: 'full regression — run the entire suite' };
|
|
@@ -103,6 +130,13 @@ function planTestRun(scope) {
|
|
|
103
130
|
reason: `${scope.tier} scope — run ${scope.impactedTestFiles.length} impacted test file(s)`,
|
|
104
131
|
};
|
|
105
132
|
}
|
|
133
|
+
var test_units_3 = require("./test-units");
|
|
134
|
+
Object.defineProperty(exports, "scanEcosystems", { enumerable: true, get: function () { return test_units_3.scanEcosystems; } });
|
|
135
|
+
Object.defineProperty(exports, "excludedDir", { enumerable: true, get: function () { return test_units_3.excludedDir; } });
|
|
136
|
+
Object.defineProperty(exports, "normaliseExcludeDirs", { enumerable: true, get: function () { return test_units_3.normaliseExcludeDirs; } });
|
|
137
|
+
Object.defineProperty(exports, "BUILD_ROOTS", { enumerable: true, get: function () { return test_units_3.BUILD_ROOTS; } });
|
|
138
|
+
Object.defineProperty(exports, "pytestRules", { enumerable: true, get: function () { return test_units_3.pytestRules; } });
|
|
139
|
+
Object.defineProperty(exports, "projectFiles", { enumerable: true, get: function () { return test_units_3.projectFiles; } });
|
|
106
140
|
/** Ecosystem of a test file, by extension/convention. `null` when no runner adapter exists for it. */
|
|
107
141
|
function ecosystemOf(file) {
|
|
108
142
|
if (/\.(ts|mts|cts|tsx|jsx|js|mjs|cjs)$/i.test(file))
|
|
@@ -130,150 +164,18 @@ function ecosystemOf(file) {
|
|
|
130
164
|
return 'dotnet';
|
|
131
165
|
return null; // cpp and non-test files — counted syntactically, not yet executable here
|
|
132
166
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
function
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
continue;
|
|
146
|
-
let evt;
|
|
147
|
-
try {
|
|
148
|
-
evt = JSON.parse(s);
|
|
149
|
-
}
|
|
150
|
-
catch {
|
|
151
|
-
continue;
|
|
152
|
-
}
|
|
153
|
-
if (!evt.Test || !evt.Package)
|
|
154
|
-
continue; // package-level result is not a test case
|
|
155
|
-
if (evt.Action === 'pass' || evt.Action === 'fail') { // skip is excluded; pass/fail both executed
|
|
156
|
-
counts[evt.Package] = (counts[evt.Package] ?? 0) + 1;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
return counts;
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Parse jest --json output into per-file EXECUTED case counts. This is the execution-proof upgrade
|
|
163
|
-
* over the syntactic countTestCases lower bound: a case only appears here if jest actually ran it
|
|
164
|
-
* (pending/skipped assertions are excluded), so `if(false){it(…)}`, aliasing, and other syntactic
|
|
165
|
-
* fabrications cannot produce evidence. Returns {} for unparseable output (caller falls back).
|
|
166
|
-
*/
|
|
167
|
-
function parseExecutedCounts(stdout, cwd) {
|
|
168
|
-
const start = stdout.indexOf('{');
|
|
169
|
-
if (start < 0)
|
|
170
|
-
return {};
|
|
171
|
-
let data;
|
|
172
|
-
try {
|
|
173
|
-
data = JSON.parse(stdout.slice(start));
|
|
174
|
-
}
|
|
175
|
-
catch {
|
|
176
|
-
return {};
|
|
177
|
-
}
|
|
178
|
-
const out = {};
|
|
179
|
-
for (const tr of data?.testResults ?? []) {
|
|
180
|
-
const abs = tr.name ?? tr.testFilePath ?? '';
|
|
181
|
-
if (!abs)
|
|
182
|
-
continue;
|
|
183
|
-
const ran = (tr.assertionResults ?? []).filter((a) => a.status === 'passed' || a.status === 'failed').length;
|
|
184
|
-
out[relTestPath(abs, cwd)] = ran;
|
|
185
|
-
}
|
|
186
|
-
return out;
|
|
187
|
-
}
|
|
188
|
-
/** Repo-relative, forward-slashed key for a jest test-file path — shared by the parsers below. */
|
|
189
|
-
function relTestPath(abs, cwd) {
|
|
190
|
-
const rel = abs.startsWith(cwd) ? abs.slice(cwd.length).replace(/^[/\\]/, '') : abs;
|
|
191
|
-
return rel.split('\\').join('/');
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* @implements A-SPEC-534.1
|
|
195
|
-
* Classify each jest-executed file into red-assertion | red-error | green from `jest --json` stdout.
|
|
196
|
-
* Pure; unparseable/empty input → {} (same fail-soft convention as parseExecutedCounts).
|
|
197
|
-
*
|
|
198
|
-
* A failed assertion anywhere in a file wins (`red-assertion`) — that is a real red. A file that ran
|
|
199
|
-
* NO assertions but errored (testExecError, or status 'failed' with an empty assertion list — a
|
|
200
|
-
* load/collection/import failure) is `red-error`, which ART-8 must not accept as a valid RED. A file
|
|
201
|
-
* that executed ≥1 assertion with none failing is `green`. A file that only pended/skipped carries no
|
|
202
|
-
* evidence and is omitted entirely.
|
|
203
|
-
*/
|
|
204
|
-
function classifyJestOutcomes(stdout, cwd) {
|
|
205
|
-
const start = stdout.indexOf('{');
|
|
206
|
-
if (start < 0)
|
|
207
|
-
return {};
|
|
208
|
-
let data;
|
|
209
|
-
try {
|
|
210
|
-
data = JSON.parse(stdout.slice(start));
|
|
211
|
-
}
|
|
212
|
-
catch {
|
|
213
|
-
return {};
|
|
214
|
-
}
|
|
215
|
-
const out = {};
|
|
216
|
-
for (const tr of data?.testResults ?? []) {
|
|
217
|
-
const abs = tr.name ?? tr.testFilePath ?? '';
|
|
218
|
-
if (!abs)
|
|
219
|
-
continue;
|
|
220
|
-
const rel = relTestPath(abs, cwd);
|
|
221
|
-
const assertions = tr.assertionResults ?? [];
|
|
222
|
-
if (assertions.some((a) => a.status === 'failed')) {
|
|
223
|
-
out[rel] = 'red-assertion';
|
|
224
|
-
continue;
|
|
225
|
-
}
|
|
226
|
-
const executed = assertions.filter((a) => a.status === 'passed' || a.status === 'failed').length;
|
|
227
|
-
const errored = !!tr.testExecError || tr.status === 'failed';
|
|
228
|
-
if (executed === 0) {
|
|
229
|
-
if (errored)
|
|
230
|
-
out[rel] = 'red-error'; // ran nothing AND failed → could not execute its cases
|
|
231
|
-
continue; // otherwise all pending/skipped → no evidence, omit
|
|
232
|
-
}
|
|
233
|
-
out[rel] = errored ? 'red-error' : 'green';
|
|
234
|
-
}
|
|
235
|
-
return out;
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Parse pytest's built-in JUnit XML into per-file EXECUTED case counts — the pytest analogue of
|
|
239
|
-
* parseExecutedCounts. `--junit-xml` ships with pytest core, so this needs no plugin, and it is the
|
|
240
|
-
* only pytest output that is both machine-readable and per-file.
|
|
241
|
-
*
|
|
242
|
-
* A `<testcase>` counts as executed unless it carries `<skipped>`, matching the jest rule where
|
|
243
|
-
* pending/skipped assertions are excluded. Errors and failures DO count: they executed.
|
|
244
|
-
*/
|
|
245
|
-
function parseJUnitXmlCounts(xml, ext = 'py') {
|
|
246
|
-
const out = {};
|
|
247
|
-
for (const m of xml.matchAll(/<testcase\b([^>]*?)(\/>|>([\s\S]*?)<\/testcase>)/g)) {
|
|
248
|
-
const attrs = m[1] ?? '';
|
|
249
|
-
const body = m[3] ?? '';
|
|
250
|
-
// `file` (xunit1 / dotnet loggers) is used verbatim when present. Otherwise the `classname`
|
|
251
|
-
// fallback maps to a source path — but the class↔file relationship is language-specific:
|
|
252
|
-
// @implements A-SPEC-137.3
|
|
253
|
-
// py : the MODULE names the file, the class is a nested segment. `tests.test_calc.TestThing`
|
|
254
|
-
// -> `tests/test_calc.py` (drop trailing Capitalized class segments).
|
|
255
|
-
// java/cs : the CLASS names the file. `com.x.FooTest` -> `com/x/FooTest.java` (keep all).
|
|
256
|
-
let file = /\bfile="([^"]*)"/.exec(attrs)?.[1];
|
|
257
|
-
if (!file) {
|
|
258
|
-
const cls = /\bclassname="([^"]*)"/.exec(attrs)?.[1];
|
|
259
|
-
if (!cls)
|
|
260
|
-
continue;
|
|
261
|
-
const parts = cls.split('.').filter(Boolean);
|
|
262
|
-
if (ext === 'py') {
|
|
263
|
-
while (parts.length > 1 && /^[A-Z]/.test(parts[parts.length - 1]))
|
|
264
|
-
parts.pop();
|
|
265
|
-
}
|
|
266
|
-
if (parts.length === 0)
|
|
267
|
-
continue;
|
|
268
|
-
file = `${parts.join('/')}.${ext}`;
|
|
269
|
-
}
|
|
270
|
-
if (/<skipped\b/.test(body))
|
|
271
|
-
continue;
|
|
272
|
-
const key = file.split('\\').join('/');
|
|
273
|
-
out[key] = (out[key] ?? 0) + 1;
|
|
274
|
-
}
|
|
275
|
-
return out;
|
|
276
|
-
}
|
|
167
|
+
// @implements A-SPEC-128.12 — the report readers live in review/test-reports (SRP); these names stay importable from here
|
|
168
|
+
// @implements A-SPEC-137.1, A-SPEC-137.3, A-SPEC-534.1 — the go, JUnit and jest-outcome readers they specify, re-exported
|
|
169
|
+
var test_reports_2 = require("./test-reports");
|
|
170
|
+
Object.defineProperty(exports, "parseGoTestJson", { enumerable: true, get: function () { return test_reports_2.parseGoTestJson; } });
|
|
171
|
+
Object.defineProperty(exports, "goPackagesWithTestEvents", { enumerable: true, get: function () { return test_reports_2.goPackagesWithTestEvents; } });
|
|
172
|
+
Object.defineProperty(exports, "parseExecutedCounts", { enumerable: true, get: function () { return test_reports_2.parseExecutedCounts; } });
|
|
173
|
+
Object.defineProperty(exports, "classifyJestOutcomes", { enumerable: true, get: function () { return test_reports_2.classifyJestOutcomes; } });
|
|
174
|
+
Object.defineProperty(exports, "parseJUnitXmlCounts", { enumerable: true, get: function () { return test_reports_2.parseJUnitXmlCounts; } });
|
|
175
|
+
Object.defineProperty(exports, "parseJUnitXmlOutcomes", { enumerable: true, get: function () { return test_reports_2.parseJUnitXmlOutcomes; } });
|
|
176
|
+
Object.defineProperty(exports, "parseJUnitXmlFiles", { enumerable: true, get: function () { return test_reports_2.parseJUnitXmlFiles; } });
|
|
177
|
+
Object.defineProperty(exports, "wellShapedJson", { enumerable: true, get: function () { return test_reports_2.wellShapedJson; } });
|
|
178
|
+
Object.defineProperty(exports, "readJestReport", { enumerable: true, get: function () { return test_reports_2.readJestReport; } });
|
|
277
179
|
/**
|
|
278
180
|
* @implements A-SPEC-466 — W-4. The TARGET repo's own jest entry, as its package declares it.
|
|
279
181
|
*
|
|
@@ -302,8 +204,75 @@ function jestEntry(cwd) {
|
|
|
302
204
|
return null;
|
|
303
205
|
}
|
|
304
206
|
}
|
|
207
|
+
/** @implements A-SPEC-128.6 — passed and failed cases only (skipped ones are not counted by the parsers). */
|
|
208
|
+
const casesRan = (executed) => Object.values(executed).reduce((a, b) => a + b, 0);
|
|
209
|
+
/**
|
|
210
|
+
* @implements A-SPEC-466.6 — test_run's `timeoutMinutes`, the run's time budget: absent or null is 30; an integer
|
|
211
|
+
* 1..180 is kept; anything else throws (never clamped). It is not a judgement input.
|
|
212
|
+
*/
|
|
213
|
+
function testRunTimeoutMinutes(value) {
|
|
214
|
+
if (value === undefined || value === null)
|
|
215
|
+
return exports.RUNNER_TIMEOUT_MS / 60_000;
|
|
216
|
+
if (typeof value === 'number' && Number.isInteger(value) && value >= 1 && value <= 180)
|
|
217
|
+
return value;
|
|
218
|
+
throw new Error(`timeoutMinutes must be an integer from 1 to 180 (got ${typeof value === 'string' ? JSON.stringify(value) : String(value)})`);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* @implements A-SPEC-466.1 — test_run's `workers`: absent stays absent; an integer 1..64 is kept; anything else
|
|
222
|
+
* throws, so a bad count is refused before any change set is derived or any runner starts.
|
|
223
|
+
*/
|
|
224
|
+
function testRunWorkers(value) {
|
|
225
|
+
if (value === undefined || value === null)
|
|
226
|
+
return undefined; // @implements A-SPEC-466.3 — null reads as omitted
|
|
227
|
+
if (typeof value === 'number' && Number.isInteger(value) && value >= 1 && value <= 64)
|
|
228
|
+
return value;
|
|
229
|
+
throw new Error(`workers must be an integer from 1 to 64 (got ${typeof value === 'string' ? JSON.stringify(value) : String(value)})`);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* @implements A-SPEC-128.12 — the one message for a configuration outside the 0.40.x supported surface (jest with one
|
|
233
|
+
* project and one unit, pytest under default naming, go). It leads every such environment reason.
|
|
234
|
+
*/
|
|
235
|
+
exports.UNSUPPORTED = '이 구성은 0.40.x가 증빙하지 않습니다 — 0.41 / 오너 결정';
|
|
236
|
+
/** @implements A-SPEC-128.12 — S7: a runner output that could not be read is a value (the unit's environment), never a throw. */
|
|
237
|
+
const unreadable = (what, out, workers) => ({ passed: false, tail: `runner output could not be read (${what}): ${firstLine(out) || '(empty)'}`, executed: {}, outcomes: {}, workers, testsRun: 0, environment: true });
|
|
238
|
+
/**
|
|
239
|
+
* @implements A-SPEC-128.12 — S2/S7: what `jest --showConfig` resolved for this unit, judged by test-units'
|
|
240
|
+
* `jestConfigSurface` (A-SPEC-128.13: one place) — the reason it is outside the surface or cannot be read, else null.
|
|
241
|
+
* No pattern is taken from it.
|
|
242
|
+
*/
|
|
243
|
+
function jestConfigReason(cmd, pre, cwd) {
|
|
244
|
+
let out;
|
|
245
|
+
try {
|
|
246
|
+
out = runBounded(cmd, [...pre, '--showConfig'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: (0, root_1.cleanTestEnv)() });
|
|
247
|
+
}
|
|
248
|
+
catch (e) {
|
|
249
|
+
const err = e;
|
|
250
|
+
out = `${err.stderr ?? ''}\n${err.stdout ?? ''}\n${err.message ?? ''}`;
|
|
251
|
+
}
|
|
252
|
+
const cfg = (0, test_reports_1.wellShapedJson)(out, test_reports_1.isJestConfig);
|
|
253
|
+
if (cfg === null || cfg.configs.length === 0)
|
|
254
|
+
return `runner output could not be read (jest --showConfig): ${firstLine(out) || '(empty)'}`;
|
|
255
|
+
const outside = (0, test_units_2.jestConfigSurface)(cfg);
|
|
256
|
+
return outside === null ? null : `${exports.UNSUPPORTED}: ${outside}`;
|
|
257
|
+
}
|
|
305
258
|
/** Run the jest half of a plan. */
|
|
306
|
-
function runJest(files, mode, cwd) {
|
|
259
|
+
function runJest(files, mode, cwd, opts = {}) {
|
|
260
|
+
// @implements A-SPEC-128.11 — P3: a full run's report is read from a file jest writes, so the user's console output
|
|
261
|
+
// on stdout cannot break it; a scoped run keeps its 466.1 argv
|
|
262
|
+
const reportDir = mode === 'full' ? fs.mkdtempSync(path.join(os.tmpdir(), 'holmes-jest-')) : null;
|
|
263
|
+
try {
|
|
264
|
+
return runJestWith(files, mode, cwd, opts, reportDir === null ? null : path.join(reportDir, 'report.json'));
|
|
265
|
+
}
|
|
266
|
+
finally {
|
|
267
|
+
if (reportDir !== null) {
|
|
268
|
+
try {
|
|
269
|
+
fs.rmSync(reportDir, { recursive: true, force: true });
|
|
270
|
+
}
|
|
271
|
+
catch { /* best effort */ }
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
function runJestWith(files, mode, cwd, opts, reportFile) {
|
|
307
276
|
// --runTestsByPath treats args as EXACT files (not testPathPattern REGEXes, which would over/mis-match
|
|
308
277
|
// or throw on a metachar); `--` + a leading-`./` guard so a path can never be read as a flag. NO
|
|
309
278
|
// --passWithNoTests on a scoped run (verification H5): if the resolved paths match ZERO tests
|
|
@@ -315,15 +284,36 @@ function runJest(files, mode, cwd) {
|
|
|
315
284
|
// (structurally no .cmd shim to ENOENT on); the npx spelling only as the fallback.
|
|
316
285
|
const entry = jestEntry(cwd);
|
|
317
286
|
const [cmd, ...pre] = entry !== null ? [process.execPath, entry] : ['npx', 'jest'];
|
|
287
|
+
// @implements A-SPEC-466.1 — absent, jest keeps the project's own maxWorkers
|
|
288
|
+
// @implements A-SPEC-466.2 — `applied` is the one value both the argv and the report are built from
|
|
289
|
+
const applied = opts.workers ?? null;
|
|
290
|
+
const workers = applied === null ? [] : [`--maxWorkers=${applied}`];
|
|
291
|
+
// @implements A-SPEC-128.12 — S2: holmes passes jest no ignore argument, so the user's configuration is never replaced
|
|
292
|
+
// (a CLI pattern applies to every project and hid one project's red, R1); exclusions are judged after the run
|
|
318
293
|
const args = mode === 'scoped'
|
|
319
|
-
? [...pre, '--silent', '--json', '--forceExit', '--runTestsByPath', '--', ...safeFiles]
|
|
320
|
-
: [...pre, '--silent', '--json', '--forceExit']; // round 13: an open handle after the last test must not hold the run
|
|
294
|
+
? [...pre, '--silent', '--json', '--forceExit', ...workers, '--runTestsByPath', '--', ...safeFiles]
|
|
295
|
+
: [...pre, '--silent', '--json', '--forceExit', ...workers, `--outputFile=${reportFile}`]; // round 13: an open handle after the last test must not hold the run
|
|
296
|
+
const ran = jestRun(cmd, args, cwd, mode, reportFile, applied);
|
|
297
|
+
if (mode !== 'full' || ran.environment === true)
|
|
298
|
+
return ran;
|
|
299
|
+
// @implements A-SPEC-128.12 — S2/S7: one project only; a configuration jest cannot print is environment
|
|
300
|
+
// @implements A-SPEC-128.13 — and no configured testNamePattern (a selection below the file)
|
|
301
|
+
const reason = jestConfigReason(cmd, pre, cwd);
|
|
302
|
+
return reason === null ? ran : { ...ran, passed: false, environment: true, tail: `${reason}\n${ran.tail}` };
|
|
303
|
+
}
|
|
304
|
+
function jestRun(cmd, args, cwd, mode, reportFile, applied) {
|
|
321
305
|
try {
|
|
322
|
-
const
|
|
306
|
+
const raw = runBounded(cmd, args, { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: (0, root_1.cleanTestEnv)() });
|
|
307
|
+
const out = mode === 'full' ? (0, test_reports_1.readJestReport)(reportFile, raw) : raw;
|
|
308
|
+
if (out === null)
|
|
309
|
+
return unreadable('jest --json', raw, applied);
|
|
323
310
|
// @implements A-SPEC-515.1 — the green path says what happened instead of handing back the
|
|
324
311
|
// whole `--json` document. `tailOf` wraps the result too, so an unexpectedly long summary is
|
|
325
312
|
// still bounded: a cap that any one path can escape is not a cap.
|
|
326
|
-
|
|
313
|
+
const executed = (0, test_reports_1.parseExecutedCounts)(out, cwd);
|
|
314
|
+
// @implements A-SPEC-128.13 — T1: exit 0 is not green when the report holds a failure (testFailureExitCode: 0)
|
|
315
|
+
const failed = (0, test_reports_1.jestReportFailed)(out);
|
|
316
|
+
return { passed: !failed, tail: tailOf(`${failed ? 'jest exited 0 but its report holds failures\n' : ''}${summarizeJestJson(out) ?? out}`), executed, outcomes: (0, test_reports_1.classifyJestOutcomes)(out, cwd), workers: applied, testsRun: casesRan(executed) };
|
|
327
317
|
}
|
|
328
318
|
catch (e) {
|
|
329
319
|
const err = e;
|
|
@@ -331,9 +321,19 @@ function runJest(files, mode, cwd) {
|
|
|
331
321
|
// classification (A-SPEC-534.1) — survives a red run.
|
|
332
322
|
// @implements A-SPEC-577.1 — the names first, then jest's own summary from stderr. Without the
|
|
333
323
|
// first half this tail was the tail of a JSON document: it said how many failed and never which.
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
324
|
+
// @implements A-SPEC-466.3 — the names and the stderr are bounded apart, so a long stderr cannot push the names out
|
|
325
|
+
// @implements A-SPEC-128.11 — P3: a red full run is read from its report file too; with no report at all the unit
|
|
326
|
+
// ran nothing readable and is environment (a jest that could not start: a configuration error, a missing preset)
|
|
327
|
+
const report = mode === 'full' ? (0, test_reports_1.readJestReport)(reportFile, err.stdout ?? '') : (err.stdout ?? '');
|
|
328
|
+
// jest's own answer for a unit with no test writes no report: it ran nothing, read as such (the tests, not environment)
|
|
329
|
+
if (report === null && /^No tests found, exiting with code 1/m.test(err.stderr ?? '')) {
|
|
330
|
+
return { passed: false, tail: tailOf(err.stderr ?? '', 3), executed: {}, outcomes: {}, workers: applied, testsRun: 0 };
|
|
331
|
+
}
|
|
332
|
+
if (report === null)
|
|
333
|
+
return unreadable('jest --json', `${err.stderr ?? ''}\n${err.stdout ?? ''}\n${err.message ?? ''}`, applied);
|
|
334
|
+
const tail = redJestTail(report, err.stderr ?? err.message ?? '');
|
|
335
|
+
const executed = (0, test_reports_1.parseExecutedCounts)(report, cwd);
|
|
336
|
+
return { passed: false, tail, executed, outcomes: (0, test_reports_1.classifyJestOutcomes)(report, cwd), workers: applied, testsRun: casesRan(executed) };
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
339
|
/**
|
|
@@ -341,113 +341,28 @@ function runJest(files, mode, cwd) {
|
|
|
341
341
|
* Run specific jest files and return only their RED-first outcomes — the runner `test_run --mutate`
|
|
342
342
|
* injects into runKillsOnFile. Scoped, jest only (the classifier is jest-only), fail-soft to {}.
|
|
343
343
|
*/
|
|
344
|
-
function runJestOutcomes(files, cwd) {
|
|
344
|
+
function runJestOutcomes(files, cwd, timeoutMinutes) {
|
|
345
345
|
if (files.length === 0)
|
|
346
346
|
return {};
|
|
347
|
-
|
|
347
|
+
// @implements A-SPEC-466.6 — a mutation's jest child is a runner child of the run too
|
|
348
|
+
return withRunBudget(timeoutMinutes, () => runJest(files, 'scoped', cwd).outcomes);
|
|
348
349
|
}
|
|
349
350
|
/** Run the pytest half of a plan, taking execution evidence from pytest's built-in JUnit XML. */
|
|
350
351
|
// @implements A-SPEC-502.1 — exported for the wiring test (a fake venv python capturing argv).
|
|
351
|
-
|
|
352
|
-
* @implements A-SPEC-647
|
|
353
|
-
* Per-file RED-first outcome from the same JUnit XML `parseJUnitXmlCounts` reads. Measured 2026-09-14
|
|
354
|
-
* in an external pytest project: a ranged test_run executed the anchored case and recorded NOTHING,
|
|
355
|
-
* because classification was jest-only — a Python project could never produce the red-assertion→green
|
|
356
|
-
* sequence ART-8 reads. `<error>` (collection/import/setup) is a red-error, `<failure>` (an assertion)
|
|
357
|
-
* a red-assertion, executed cases without either are green; a file with only skipped cases says nothing.
|
|
358
|
-
*/
|
|
359
|
-
function parseJUnitXmlOutcomes(xml, ext = 'py') {
|
|
360
|
-
const flags = new Map();
|
|
361
|
-
for (const m of xml.matchAll(/<testcase\b([^>]*?)(\/>|>([\s\S]*?)<\/testcase>)/g)) {
|
|
362
|
-
const attrs = m[1] ?? '';
|
|
363
|
-
const body = m[3] ?? '';
|
|
364
|
-
let file = /\bfile="([^"]*)"/.exec(attrs)?.[1];
|
|
365
|
-
if (!file) {
|
|
366
|
-
const cls = /\bclassname="([^"]*)"/.exec(attrs)?.[1];
|
|
367
|
-
if (!cls)
|
|
368
|
-
continue;
|
|
369
|
-
const parts = cls.split('.').filter(Boolean);
|
|
370
|
-
if (ext === 'py') {
|
|
371
|
-
while (parts.length > 1 && /^[A-Z]/.test(parts[parts.length - 1]))
|
|
372
|
-
parts.pop();
|
|
373
|
-
}
|
|
374
|
-
if (parts.length === 0)
|
|
375
|
-
continue;
|
|
376
|
-
file = `${parts.join('/')}.${ext}`;
|
|
377
|
-
}
|
|
378
|
-
const key = file.split('\\').join('/');
|
|
379
|
-
const f = flags.get(key) ?? { error: false, failure: false, executed: false };
|
|
380
|
-
if (/<error\b/.test(body))
|
|
381
|
-
f.error = true;
|
|
382
|
-
else if (/<failure\b/.test(body))
|
|
383
|
-
f.failure = true;
|
|
384
|
-
if (!/<skipped\b/.test(body))
|
|
385
|
-
f.executed = true;
|
|
386
|
-
flags.set(key, f);
|
|
387
|
-
}
|
|
388
|
-
const out = {};
|
|
389
|
-
for (const [file, f] of flags) {
|
|
390
|
-
if (f.error)
|
|
391
|
-
out[file] = 'red-error';
|
|
392
|
-
else if (f.failure)
|
|
393
|
-
out[file] = 'red-assertion';
|
|
394
|
-
else if (f.executed)
|
|
395
|
-
out[file] = 'green';
|
|
396
|
-
}
|
|
397
|
-
return out;
|
|
398
|
-
}
|
|
352
|
+
// @implements A-SPEC-647 — its per-file outcome reader (parseJUnitXmlOutcomes) lives in review/test-reports
|
|
399
353
|
/**
|
|
400
354
|
* @implements A-SPEC-647
|
|
401
355
|
* The ecosystems a project's OWN test files belong to, by file-name convention, under a bounded walk
|
|
402
356
|
* that skips vendored trees and virtualenvs. Measured: a full-tier run with no impacted list assumed
|
|
403
|
-
* the jest suite on a pytest-only project, ran nothing and reported passed:false.
|
|
404
|
-
*
|
|
357
|
+
* the jest suite on a pytest-only project, ran nothing and reported passed:false.
|
|
358
|
+
* @implements A-SPEC-128.5 — configuration files name an ecosystem too (a pytest.ini, a go.mod), the root's are read
|
|
359
|
+
* even where the walk stops early, and the skipped trees a project vendors are its own declaration
|
|
360
|
+
* (`ax.config.json` testRun.excludeDirs), not a name built in here. This repository lists `reference`.
|
|
405
361
|
*/
|
|
406
|
-
function detectProjectEcosystems(cwd) {
|
|
407
|
-
|
|
408
|
-
const found = new Set();
|
|
409
|
-
const walk = (dir, depth) => {
|
|
410
|
-
if (depth > 6)
|
|
411
|
-
return;
|
|
412
|
-
let entries;
|
|
413
|
-
try {
|
|
414
|
-
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
415
|
-
}
|
|
416
|
-
catch {
|
|
417
|
-
return;
|
|
418
|
-
}
|
|
419
|
-
if (entries.some((e) => e.isFile() && e.name === 'pyvenv.cfg'))
|
|
420
|
-
return; // a virtualenv is not the project
|
|
421
|
-
for (const e of entries) {
|
|
422
|
-
const name = e.name;
|
|
423
|
-
if (e.isDirectory()) {
|
|
424
|
-
if (SKIP_DIRS.has(name) || (name.startsWith('.') && name !== '.'))
|
|
425
|
-
continue;
|
|
426
|
-
if (name === '__tests__')
|
|
427
|
-
found.add('jest');
|
|
428
|
-
walk(path.join(dir, name), depth + 1);
|
|
429
|
-
continue;
|
|
430
|
-
}
|
|
431
|
-
if (!e.isFile())
|
|
432
|
-
continue;
|
|
433
|
-
if (/\.(test|spec)\.(ts|tsx|js|jsx|mjs|cjs|mts|cts)$/.test(name))
|
|
434
|
-
found.add('jest');
|
|
435
|
-
else if (/^(test_[^/]*|[^/]*_test)\.py$/.test(name) || name === 'conftest.py')
|
|
436
|
-
found.add('pytest');
|
|
437
|
-
else if (/_test\.go$/.test(name))
|
|
438
|
-
found.add('go');
|
|
439
|
-
else if (name === 'Cargo.toml')
|
|
440
|
-
found.add('rust');
|
|
441
|
-
else if (name === 'build.gradle' || name === 'build.gradle.kts')
|
|
442
|
-
found.add('java');
|
|
443
|
-
else if (/\.csproj$/.test(name))
|
|
444
|
-
found.add('dotnet');
|
|
445
|
-
}
|
|
446
|
-
};
|
|
447
|
-
walk(cwd, 0);
|
|
448
|
-
return [...found].sort();
|
|
362
|
+
function detectProjectEcosystems(cwd, opts = {}) {
|
|
363
|
+
return (0, test_units_1.scanEcosystems)(cwd, opts).detected;
|
|
449
364
|
}
|
|
450
|
-
function runPytest(files, mode, cwd) {
|
|
365
|
+
function runPytest(files, mode, cwd, ignore = [], pythonFrom, run) {
|
|
451
366
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'holmes-pytest-'));
|
|
452
367
|
const report = path.join(dir, 'report.xml');
|
|
453
368
|
// `python3 -m pytest` rather than a bare `pytest`, so the interpreter on PATH decides which
|
|
@@ -462,24 +377,48 @@ function runPytest(files, mode, cwd) {
|
|
|
462
377
|
// @implements A-SPEC-502.1 — BUG-2, both halves: the interpreter resolves from pyvenv.cfg
|
|
463
378
|
// evidence (HOLMES_PYTHON above all, python3 fallback byte-identical to the old path), and a
|
|
464
379
|
// conftest.py argument widens to its directory instead of collection-ERRORing the whole run.
|
|
465
|
-
|
|
380
|
+
// @implements A-SPEC-128.9 — `-p no:cacheprovider`: a test run leaves no .pytest_cache in the project; E3: an excluded
|
|
381
|
+
// or ignored tree is not collected
|
|
382
|
+
// @implements A-SPEC-128.11 — P3: `--rootdir` is the unit, so a pytest.ini above the repository cannot move the
|
|
383
|
+
// report's file keys out of it (pt-rootdir-above)
|
|
384
|
+
const rootdir = fs.existsSync(cwd) ? (0, root_1.canonicalPath)(cwd) : cwd;
|
|
385
|
+
// @implements A-SPEC-128.13 — W2: the work tree's interpreter (a .venv is not in HEAD)
|
|
386
|
+
const python = (0, python_env_1.pythonFor)(pythonFrom && fs.existsSync(pythonFrom) ? pythonFrom : cwd, { env: process.env, exists: fs.existsSync, platform: process.platform });
|
|
387
|
+
// @implements A-SPEC-128.14, A-SPEC-128.15, A-SPEC-128.16 — in HEAD's worktree: the pinned configuration and its confcutdir,
|
|
388
|
+
// the environment asked where HEAD's names resolve (refused before any test), and the loaded-module record
|
|
389
|
+
const prov = run ? (0, run_provenance_1.pytestRunProvenance)(dir, run, rootdir, python, (0, root_1.cleanTestEnv)(), (c, a, o) => runBounded(c, a, { ...o, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER })) : null;
|
|
390
|
+
if (prov?.refused) {
|
|
391
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
392
|
+
return { passed: false, tail: prov.refused, executed: {}, outcomes: {}, testsRun: 0, environment: true };
|
|
393
|
+
}
|
|
394
|
+
const args = ['-m', 'pytest', '-q', '-p', 'no:cacheprovider', '-o', 'junit_family=xunit1', `--junit-xml=${report}`, `--rootdir=${rootdir}`, ...(prov?.args ?? []),
|
|
395
|
+
...(mode === 'full' ? [`--confcutdir=${prov?.confcutdir ?? rootdir}`, ...ignore.map((d) => `--ignore=${d.replace(/\/+$/, '')}`)] : []),
|
|
466
396
|
...(mode === 'scoped' ? ['--', ...(0, python_env_1.pytestTargets)(files)] : [])];
|
|
467
|
-
const
|
|
397
|
+
const judged = (r) => { const why = prov?.judge(r.passed) ?? null; return why === null ? r : { passed: false, tail: why, executed: {}, outcomes: {}, testsRun: 0, environment: true }; };
|
|
468
398
|
const read = () => {
|
|
469
399
|
try {
|
|
470
|
-
return parseJUnitXmlCounts(fs.readFileSync(report, 'utf8'));
|
|
400
|
+
return (0, test_reports_1.parseJUnitXmlCounts)(fs.readFileSync(report, 'utf8'));
|
|
471
401
|
}
|
|
472
402
|
catch {
|
|
473
403
|
return {};
|
|
474
404
|
}
|
|
475
405
|
};
|
|
406
|
+
// @implements A-SPEC-128.10 — I3: every file pytest collected, skipped ones included
|
|
407
|
+
const reported = () => {
|
|
408
|
+
try {
|
|
409
|
+
return (0, test_reports_1.parseJUnitXmlFiles)(fs.readFileSync(report, 'utf8'));
|
|
410
|
+
}
|
|
411
|
+
catch {
|
|
412
|
+
return [];
|
|
413
|
+
}
|
|
414
|
+
};
|
|
476
415
|
// @implements A-SPEC-647 — per-file outcomes from the same report; in a scoped run a planned file the
|
|
477
416
|
// failed run never reached (no case at all — a collection error before its cases) is a red-error, so a
|
|
478
417
|
// RED that never ran is not mistaken for evidence of nothing.
|
|
479
418
|
const readOutcomes = (passed) => {
|
|
480
419
|
let outcomes = {};
|
|
481
420
|
try {
|
|
482
|
-
outcomes = parseJUnitXmlOutcomes(fs.readFileSync(report, 'utf8'));
|
|
421
|
+
outcomes = (0, test_reports_1.parseJUnitXmlOutcomes)(fs.readFileSync(report, 'utf8'));
|
|
483
422
|
}
|
|
484
423
|
catch {
|
|
485
424
|
outcomes = {};
|
|
@@ -498,13 +437,18 @@ function runPytest(files, mode, cwd) {
|
|
|
498
437
|
// @implements A-SPEC-651.1 — launch from the canonical spelling: pytest keys its JUnit `file`
|
|
499
438
|
// attribute relative to its rootdir, and an 8.3 invocation dir made that key climb out of the
|
|
500
439
|
// project (`../../…/tests/test_calc.py`, measured 2026-09-14 on Windows).
|
|
501
|
-
const out = runBounded(python, args, { cwd: fs.existsSync(cwd) ? (0, root_1.canonicalPath)(cwd) : cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: (0, root_1.cleanTestEnv)() });
|
|
502
|
-
|
|
440
|
+
const out = runBounded(python, args, { cwd: fs.existsSync(cwd) ? (0, root_1.canonicalPath)(cwd) : cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: prov ? prov.env((0, root_1.cleanTestEnv)()) : (0, root_1.cleanTestEnv)() });
|
|
441
|
+
const executed = read();
|
|
442
|
+
// @implements A-SPEC-128.13 — T1: exit 0 is not green when the JUnit report holds a failure or an error
|
|
443
|
+
const outcomes = readOutcomes(true);
|
|
444
|
+
const red = Object.values(outcomes).some((o) => o !== 'green');
|
|
445
|
+
return judged({ passed: !red, tail: tailOf(`${red ? 'pytest exited 0 but its report holds failures\n' : ''}${out}`), executed, outcomes, testsRun: casesRan(executed), reported: reported() });
|
|
503
446
|
}
|
|
504
447
|
catch (e) {
|
|
505
448
|
const err = e;
|
|
506
449
|
// A red pytest run still writes the XML, so execution evidence survives — same property as jest.
|
|
507
|
-
|
|
450
|
+
const executed = read();
|
|
451
|
+
return judged({ passed: false, tail: tailOf(`${err.stdout ?? ''}\n${err.stderr ?? err.message ?? ''}`), executed, outcomes: readOutcomes(false), testsRun: casesRan(executed), reported: reported() });
|
|
508
452
|
}
|
|
509
453
|
finally {
|
|
510
454
|
try {
|
|
@@ -566,7 +510,8 @@ function runCargo(files, _mode, cwd, opts) {
|
|
|
566
510
|
executed[f] = count; // crate-granular
|
|
567
511
|
// Executing nothing is not a pass, mirroring no-passWithNoTests.
|
|
568
512
|
const passed = ok && count > 0;
|
|
569
|
-
|
|
513
|
+
// @implements A-SPEC-128.5 — the crate's count once, whatever the per-file credit (a full run credits no file)
|
|
514
|
+
return { passed, tail: `[rust] cargo test: ${count} executed`, executed, testsRun: count };
|
|
570
515
|
}
|
|
571
516
|
/** Read every JUnit XML report under a directory (recursively) and sum their counts for `ext`. */
|
|
572
517
|
function readJUnitReports(dir, ext) {
|
|
@@ -585,7 +530,7 @@ function readJUnitReports(dir, ext) {
|
|
|
585
530
|
walk(p);
|
|
586
531
|
else if (e.name.endsWith('.xml')) {
|
|
587
532
|
try {
|
|
588
|
-
const counts = parseJUnitXmlCounts(fs.readFileSync(p, 'utf8'), ext);
|
|
533
|
+
const counts = (0, test_reports_1.parseJUnitXmlCounts)(fs.readFileSync(p, 'utf8'), ext);
|
|
589
534
|
for (const [k, v] of Object.entries(counts))
|
|
590
535
|
acc[k] = (acc[k] ?? 0) + v;
|
|
591
536
|
}
|
|
@@ -648,12 +593,15 @@ function runGradle(files, _mode, cwd, opts) {
|
|
|
648
593
|
try {
|
|
649
594
|
runBounded(cmd, args, { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: (0, root_1.cleanTestEnv)() });
|
|
650
595
|
}
|
|
651
|
-
catch {
|
|
652
|
-
|
|
653
|
-
|
|
596
|
+
catch (e) {
|
|
597
|
+
// @implements A-SPEC-128.10 — R4: the build tool itself missing is the environment, not the tests
|
|
598
|
+
if (e.code === 'ENOENT')
|
|
599
|
+
return { passed: false, tail: `${cmd} not found on PATH — cannot execute Java tests`, executed: {}, unsupported: files };
|
|
600
|
+
ok = false; // a failing test run still wrote the JUnit XML
|
|
601
|
+
}
|
|
654
602
|
const executed = readJUnitReports(path.join(cwd, reportDir), 'java');
|
|
655
603
|
const total = Object.values(executed).reduce((a, b) => a + b, 0);
|
|
656
|
-
return { passed: ok && total > 0, tail: `[java] ${cmd} ${args.join(' ')}: ${total} executed`, executed };
|
|
604
|
+
return { passed: ok && total > 0, tail: `[java] ${cmd} ${args.join(' ')}: ${total} executed`, executed, testsRun: total };
|
|
657
605
|
}
|
|
658
606
|
/**
|
|
659
607
|
* @implements A-SPEC-137.3
|
|
@@ -685,7 +633,7 @@ function runDotnet(files, _mode, cwd, opts) {
|
|
|
685
633
|
}
|
|
686
634
|
let executed = {};
|
|
687
635
|
try {
|
|
688
|
-
executed = parseJUnitXmlCounts(fs.readFileSync(report, 'utf8'), 'cs');
|
|
636
|
+
executed = (0, test_reports_1.parseJUnitXmlCounts)(fs.readFileSync(report, 'utf8'), 'cs');
|
|
689
637
|
}
|
|
690
638
|
catch { /* no report */ }
|
|
691
639
|
try {
|
|
@@ -693,7 +641,7 @@ function runDotnet(files, _mode, cwd, opts) {
|
|
|
693
641
|
}
|
|
694
642
|
catch { /* best effort */ }
|
|
695
643
|
const total = Object.values(executed).reduce((a, b) => a + b, 0);
|
|
696
|
-
return { passed: ok && total > 0, tail: `[dotnet] dotnet test: ${total} executed`, executed };
|
|
644
|
+
return { passed: ok && total > 0, tail: `[dotnet] dotnet test: ${total} executed`, executed, testsRun: total };
|
|
697
645
|
}
|
|
698
646
|
/**
|
|
699
647
|
* @implements A-SPEC-137.1
|
|
@@ -703,6 +651,7 @@ function runDotnet(files, _mode, cwd, opts) {
|
|
|
703
651
|
* `unsupported`, never a pass. `opts.goPresent` overrides the probe for testing.
|
|
704
652
|
*/
|
|
705
653
|
function runGo(files, mode, cwd, opts) {
|
|
654
|
+
const goEnv = { ...(0, root_1.cleanTestEnv)(), ...(opts?.env ?? {}) };
|
|
706
655
|
const present = opts?.goPresent ?? (() => {
|
|
707
656
|
try {
|
|
708
657
|
(0, node_child_process_1.execFileSync)('go', ['version'], { cwd, stdio: 'ignore', timeout: PROBE_TIMEOUT_MS });
|
|
@@ -722,10 +671,10 @@ function runGo(files, mode, cwd, opts) {
|
|
|
722
671
|
const tails = [];
|
|
723
672
|
let passed = true;
|
|
724
673
|
let anyExecuted = 0;
|
|
725
|
-
const runDir = (dirArg, creditFiles) => {
|
|
674
|
+
const runDir = (dirArg, creditFiles, onOutput) => {
|
|
726
675
|
let out = '';
|
|
727
676
|
try {
|
|
728
|
-
out = runBounded('go', ['test', '-json', dirArg], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env:
|
|
677
|
+
out = runBounded('go', ['test', '-json', dirArg], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: goEnv });
|
|
729
678
|
}
|
|
730
679
|
catch (e) {
|
|
731
680
|
const err = e;
|
|
@@ -733,15 +682,63 @@ function runGo(files, mode, cwd, opts) {
|
|
|
733
682
|
tails.push(err.stderr ? tailOf(err.stderr, 2) : (err.message ?? 'go test failed'));
|
|
734
683
|
passed = false;
|
|
735
684
|
}
|
|
736
|
-
|
|
685
|
+
// @implements A-SPEC-128.13 — T1: a named test's fail event is red whatever the exit code (TestMain's os.Exit(0))
|
|
686
|
+
const failedTests = (0, test_reports_1.goFailedTests)(out);
|
|
687
|
+
if (failedTests.length > 0) {
|
|
688
|
+
passed = false;
|
|
689
|
+
tails.push(`[go] failed: ${failedTests.slice(0, 5).join(', ')}`);
|
|
690
|
+
}
|
|
691
|
+
const perPkg = (0, test_reports_1.parseGoTestJson)(out);
|
|
737
692
|
const dirCount = Object.values(perPkg).reduce((a, b) => a + b, 0);
|
|
738
693
|
anyExecuted += dirCount;
|
|
739
694
|
for (const f of creditFiles)
|
|
740
695
|
executed[f] = (executed[f] ?? 0) + dirCount; // package-granular
|
|
696
|
+
if (onOutput)
|
|
697
|
+
onOutput(out);
|
|
741
698
|
tails.push(`[go] ${dirArg}: ${dirCount} executed`);
|
|
742
699
|
};
|
|
743
700
|
if (mode === 'full') {
|
|
744
|
-
|
|
701
|
+
// @implements A-SPEC-128.9 — E3: the module's packages minus the excluded or ignored trees
|
|
702
|
+
// @implements A-SPEC-128.10 — I3 at package granularity: each package's count is credited to its _test.go files, so a
|
|
703
|
+
// package whose tests did not run leaves its files unreported
|
|
704
|
+
let pkgs = [];
|
|
705
|
+
const base = fs.existsSync(cwd) ? (0, root_1.canonicalPath)(cwd) : cwd;
|
|
706
|
+
try {
|
|
707
|
+
pkgs = runBounded('go', ['list', '-f', '{{.ImportPath}}\t{{.Dir}}', './...'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: goEnv })
|
|
708
|
+
.split('\n').map((l) => l.trim()).filter(Boolean)
|
|
709
|
+
.map((l) => { const [importPath, dir] = l.split('\t'); return { importPath, rel: path.relative(base, (0, root_1.canonicalPath)(dir ?? base)).split(path.sep).join('/') }; });
|
|
710
|
+
}
|
|
711
|
+
catch {
|
|
712
|
+
pkgs = [];
|
|
713
|
+
}
|
|
714
|
+
const skip = (opts?.ignore ?? []).map((x) => x.replace(/\/+$/, ''));
|
|
715
|
+
const kept = pkgs.filter((p) => !skip.some((x) => p.rel === x || p.rel.startsWith(`${x}/`)));
|
|
716
|
+
const before = new Map();
|
|
717
|
+
const credit = (out) => {
|
|
718
|
+
const perPkg = (0, test_reports_1.parseGoTestJson)(out);
|
|
719
|
+
const seen = (0, test_reports_1.goPackagesWithTestEvents)(out);
|
|
720
|
+
for (const p of kept) {
|
|
721
|
+
const n = perPkg[p.importPath] ?? 0;
|
|
722
|
+
// @implements A-SPEC-128.11 — P5: a package whose tests all skipped ran them (go-skip); the count stays pass/fail
|
|
723
|
+
if (!seen.has(p.importPath) || before.has(p.importPath))
|
|
724
|
+
continue;
|
|
725
|
+
before.set(p.importPath, n);
|
|
726
|
+
let names = [];
|
|
727
|
+
try {
|
|
728
|
+
names = fs.readdirSync(path.join(base, p.rel)).filter((f) => f.endsWith('_test.go'));
|
|
729
|
+
}
|
|
730
|
+
catch {
|
|
731
|
+
names = [];
|
|
732
|
+
}
|
|
733
|
+
for (const f of names)
|
|
734
|
+
executed[p.rel === '' ? f : `${p.rel}/${f}`] = n;
|
|
735
|
+
}
|
|
736
|
+
};
|
|
737
|
+
if (skip.length === 0)
|
|
738
|
+
runDir('./...', [], credit);
|
|
739
|
+
else
|
|
740
|
+
for (const k of kept)
|
|
741
|
+
runDir(k.rel === '' ? '.' : `./${k.rel}`, [], credit);
|
|
745
742
|
}
|
|
746
743
|
else {
|
|
747
744
|
const byDir = new Map();
|
|
@@ -758,7 +755,8 @@ function runGo(files, mode, cwd, opts) {
|
|
|
758
755
|
// A run that executed NOTHING is not a pass — the same no-passWithNoTests rule jest/pytest hold.
|
|
759
756
|
if (anyExecuted === 0)
|
|
760
757
|
passed = false;
|
|
761
|
-
|
|
758
|
+
// @implements A-SPEC-128.5 — a full module run credits no file but its tests ran: the count rides apart from the credit
|
|
759
|
+
return { passed, tail: tails.join('\n'), executed, testsRun: anyExecuted };
|
|
762
760
|
}
|
|
763
761
|
/**
|
|
764
762
|
* Execute a plan (I/O). Deterministic inputs → deterministic command; the pass/fail is the suite's.
|
|
@@ -769,58 +767,234 @@ function runGo(files, mode, cwd, opts) {
|
|
|
769
767
|
* ecosystem has no adapter are returned in `unsupported` — never dropped quietly, because a scoped
|
|
770
768
|
* gate that ran part of its scope has verified less than it reports.
|
|
771
769
|
*/
|
|
772
|
-
function runTestScope(scope, cwd) {
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
770
|
+
function runTestScope(scope, cwd, opts = {}) {
|
|
771
|
+
return withRunBudget(opts.timeoutMinutes, () => runScopeWithinBudget(scope, cwd, opts));
|
|
772
|
+
}
|
|
773
|
+
/** @implements A-SPEC-466.6 — each runner child started inside `fn` takes the budget; the default comes back after. */
|
|
774
|
+
function withRunBudget(timeoutMinutes, fn) {
|
|
775
|
+
RUN_BUDGET_MS = (timeoutMinutes ?? exports.RUNNER_TIMEOUT_MS / 60_000) * 60_000;
|
|
776
|
+
try {
|
|
777
|
+
return fn();
|
|
776
778
|
}
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
779
|
+
finally {
|
|
780
|
+
RUN_BUDGET_MS = exports.RUNNER_TIMEOUT_MS;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* @implements A-SPEC-128.4 — which ecosystem groups a plan runs. A scoped plan groups its own files. A full plan runs
|
|
785
|
+
* every ecosystem the PROJECT has, together with those of the impacted test files: detecting from the impacted files
|
|
786
|
+
* alone let a full run of a jest+pytest project skip pytest and still record `mode: full` (review 2026-11-05, A H1).
|
|
787
|
+
* Jest is assumed only when the project shows no ecosystem at all, and the run says so.
|
|
788
|
+
*/
|
|
789
|
+
function runEcosystems(scope, plan, cwd, opts = {}) {
|
|
782
790
|
const groups = new Map();
|
|
783
791
|
const unsupported = [];
|
|
784
|
-
|
|
792
|
+
const notRun = [];
|
|
793
|
+
if (plan.mode !== 'full') {
|
|
794
|
+
for (const f of plan.testFiles) {
|
|
795
|
+
const eco = ecosystemOf(f);
|
|
796
|
+
if (!eco) {
|
|
797
|
+
unsupported.push(f);
|
|
798
|
+
continue;
|
|
799
|
+
}
|
|
800
|
+
groups.set(eco, [...(groups.get(eco) ?? []), f]);
|
|
801
|
+
}
|
|
802
|
+
const units = [...groups.entries()].map(([ecosystem, files]) => ({ ecosystem, dir: '', ignore: [], files }));
|
|
803
|
+
return { groups, units, unsupported, assumedJest: false, detected: [], detectedBy: {}, notRun, notDetected: [],
|
|
804
|
+
implementationCount: 0, implementationSample: [], notTests: [], expected: {}, codeRoots: [], buildRoots: [], sparseTests: [], outsideSurface: [], testFiles: [], notBuilt: [] };
|
|
805
|
+
}
|
|
806
|
+
// @implements A-SPEC-647 — run what the project HAS; @implements A-SPEC-128.4 — always, not only with no impacted file
|
|
807
|
+
// @implements A-SPEC-128.7 — I1: an impacted test file of an ecosystem with no unit is named in notRun, never run
|
|
808
|
+
// @implements A-SPEC-128.9 — E1: what runs is the project's execution units, each where its build root is
|
|
809
|
+
const scan = (0, test_units_1.scanEcosystems)(cwd, opts);
|
|
810
|
+
// @implements A-SPEC-128.12 — S1: only jest, pytest and go units run; the others are named outside the surface
|
|
811
|
+
const units = scan.units.filter((u) => SUPPORTED.has(u.ecosystem)).map((u) => ({ ...u, files: [] }));
|
|
812
|
+
let assumedJest = false;
|
|
813
|
+
// @implements A-SPEC-128.8 — jest is assumed only beside a root package.json (A M1);
|
|
814
|
+
// @implements A-SPEC-128.9 — and only where there is code to test (E2): nothing testable runs nothing
|
|
815
|
+
if (units.length === 0 && scan.implementationCount > 0 && fs.existsSync(path.join(cwd, 'package.json'))) {
|
|
816
|
+
units.push({ ecosystem: 'jest', dir: '', ignore: scan.excluded, files: [] });
|
|
817
|
+
assumedJest = true;
|
|
818
|
+
}
|
|
819
|
+
for (const u of units)
|
|
820
|
+
groups.set(u.ecosystem, []);
|
|
821
|
+
for (const f of scope.impactedTestFiles) {
|
|
785
822
|
const eco = ecosystemOf(f);
|
|
786
823
|
if (!eco) {
|
|
787
824
|
unsupported.push(f);
|
|
788
825
|
continue;
|
|
789
826
|
}
|
|
790
|
-
|
|
791
|
-
|
|
827
|
+
if (groups.has(eco) || notRun.some((n) => n.ecosystem === eco))
|
|
828
|
+
continue;
|
|
829
|
+
notRun.push({ ecosystem: eco, reason: `impacted ${eco} test files, but no ${eco} unit holds them — a full run runs the project's units only` });
|
|
792
830
|
}
|
|
793
|
-
// A
|
|
794
|
-
//
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
831
|
+
// @implements A-SPEC-128.13 — T4: a go unit expects only the _test.go files go builds here (go list, no tags); the rest
|
|
832
|
+
// are named in notBuilt and never refused (a red behind a build tag is a named limit)
|
|
833
|
+
const expected = { ...scan.expected };
|
|
834
|
+
const notBuilt = [];
|
|
835
|
+
for (const u of units.filter((x) => x.ecosystem === 'go')) {
|
|
836
|
+
const key = `go@${u.dir}`;
|
|
837
|
+
const listed = (0, test_units_2.goListTests)(cwd, u.dir);
|
|
838
|
+
if (listed === null || !expected[key])
|
|
839
|
+
continue;
|
|
840
|
+
for (const f of expected[key])
|
|
841
|
+
if (!listed.built.has(f))
|
|
842
|
+
notBuilt.push(f);
|
|
843
|
+
expected[key] = expected[key].filter((f) => listed.built.has(f));
|
|
844
|
+
}
|
|
845
|
+
return { groups, units, unsupported, assumedJest, detected: scan.detected, detectedBy: scan.detectedBy, notRun, notDetected: scan.notDetected,
|
|
846
|
+
implementationCount: scan.implementationCount, implementationSample: scan.implementationSample, notTests: scan.notTests,
|
|
847
|
+
expected, codeRoots: scan.codeRoots, buildRoots: scan.buildRoots, sparseTests: scan.sparseTests,
|
|
848
|
+
outsideSurface: scan.outsideSurface, testFiles: scan.testFiles, notBuilt: notBuilt.sort() };
|
|
849
|
+
}
|
|
850
|
+
const SUPPORTED = new Set(['jest', 'pytest', 'go']);
|
|
851
|
+
/**
|
|
852
|
+
* @implements A-SPEC-128.10 — I3 and R2, judged AFTER the run from what the runners reported: the expected test files
|
|
853
|
+
* a unit did not report (a runner configuration, a root narrower than the tree, a package that ran nothing), and the
|
|
854
|
+
* build roots whose code saw no executed test. Units that could not run (environment, stop) are judged elsewhere.
|
|
855
|
+
*/
|
|
856
|
+
function coverageAfterRun(expected, codeRoots, reported, executedByFile, skipUnits, buildRoots = [], testFiles) {
|
|
857
|
+
const notExecuted = [];
|
|
858
|
+
for (const [unit, files] of Object.entries(expected)) {
|
|
859
|
+
if (skipUnits.has(unit))
|
|
860
|
+
continue;
|
|
861
|
+
for (const f of files)
|
|
862
|
+
if (!reported.has(f))
|
|
863
|
+
notExecuted.push(f);
|
|
864
|
+
}
|
|
865
|
+
// @implements A-SPEC-128.12 — S5 (repairs 128.11 P2): a root's code is tested only by an executed test file whose OWN
|
|
866
|
+
// nearest build root is that root; that a unit ran is not evidence (root-unit-credit, ws-root-credit)
|
|
867
|
+
const roots = new Set(buildRoots);
|
|
868
|
+
const nearestRoot = (rel) => {
|
|
869
|
+
const parts = rel.split('/').slice(0, -1);
|
|
870
|
+
for (let i = parts.length; i > 0; i--) {
|
|
871
|
+
const d = parts.slice(0, i).join('/');
|
|
872
|
+
if (roots.has(d))
|
|
873
|
+
return d;
|
|
805
874
|
}
|
|
875
|
+
return '';
|
|
876
|
+
};
|
|
877
|
+
// @implements A-SPEC-128.13 — T3: only an executed test file of the scanned universe credits code (a test outside the
|
|
878
|
+
// repository or outside the scan credits nothing); when no universe is given, every executed file counts (scoped)
|
|
879
|
+
const universe = testFiles ? new Set(testFiles) : null;
|
|
880
|
+
const testedRoots = new Set();
|
|
881
|
+
for (const [f, n] of Object.entries(executedByFile))
|
|
882
|
+
if (n > 0 && (universe === null || universe.has(f)))
|
|
883
|
+
testedRoots.add(nearestRoot(f));
|
|
884
|
+
const tested = (root) => testedRoots.has(root);
|
|
885
|
+
const testsAt = (root) => (testFiles ?? []).filter((f) => nearestRoot(f) === root).length;
|
|
886
|
+
const untestedCode = codeRoots.filter((g) => !tested(g.root))
|
|
887
|
+
.map((g) => ({ root: g.root, sample: g.sample, ...(g.missingBuildFile ? { missingBuildFile: g.missingBuildFile } : {}), ...(testsAt(g.root) > 0 ? { testFiles: testsAt(g.root) } : {}) }));
|
|
888
|
+
return { notExecuted: notExecuted.sort(), untestedCode };
|
|
889
|
+
}
|
|
890
|
+
/**
|
|
891
|
+
* @implements A-SPEC-128.9 — E4: why a unit that ran nothing failed, when the cause is its environment, not its tests: a
|
|
892
|
+
* missing runner. Null when the unit executed a test or failed for any other reason (then it is the tests).
|
|
893
|
+
*/
|
|
894
|
+
function environmentReason(r, counted) {
|
|
895
|
+
// @implements A-SPEC-128.12 — an adapter that says environment is believed even when tests ran (jest projects, a
|
|
896
|
+
// configuration jest cannot print: the run executed, but it is not 0.40.x evidence)
|
|
897
|
+
if (r.environment === true)
|
|
898
|
+
return firstLine(r.tail);
|
|
899
|
+
if (r.passed || counted > 0)
|
|
900
|
+
return null;
|
|
901
|
+
if ((r.unsupported?.length ?? 0) > 0)
|
|
902
|
+
return firstLine(r.tail);
|
|
903
|
+
// @implements A-SPEC-128.10 — R4: only the RUNNER being absent; an ENOENT inside a test, or a module a test imports,
|
|
904
|
+
// is the tests (review 10:51, A H4 / A M4)
|
|
905
|
+
const m = /No module named '?pytest'?(?![\w.])|toolchain not found on PATH|java runtime not found|dotnet not found on PATH|not found on PATH — cannot execute|no gradle\/maven build file found/.exec(r.tail);
|
|
906
|
+
return m ? m[0] : null;
|
|
907
|
+
}
|
|
908
|
+
// @implements A-SPEC-128.12 — S2/S6: withoutExcluded (a unit's report without its excluded trees) lives in test-reports
|
|
909
|
+
function firstLine(s) {
|
|
910
|
+
return (s.split('\n').find((l) => l.trim() !== '') ?? s).trim().slice(0, 200);
|
|
911
|
+
}
|
|
912
|
+
function runScopeWithinBudget(scope, cwd, opts) {
|
|
913
|
+
const plan = planTestRun(scope);
|
|
914
|
+
if (plan.mode === 'noop') {
|
|
915
|
+
return { tier: scope.tier, mode: 'noop', ranFiles: [], passed: true, skipped: true, tail: plan.reason, workers: null };
|
|
806
916
|
}
|
|
807
|
-
|
|
808
|
-
|
|
917
|
+
const { units, unsupported, assumedJest, detected, detectedBy, notRun, notDetected, implementationCount, implementationSample, notTests, expected, codeRoots, buildRoots, sparseTests, outsideSurface, testFiles, notBuilt } = runEcosystems(scope, plan, cwd, { excludeDirs: opts.excludeDirs, isIgnored: opts.isIgnored });
|
|
918
|
+
// @implements A-SPEC-128.7 — what a full plan detected, left out and did not run travels with the result
|
|
919
|
+
// @implements A-SPEC-128.9 — with the implementation count E2 reads and the test-named files that hold no test
|
|
920
|
+
// @implements A-SPEC-128.13 — and the test-file count E2 also needs, and the go files this platform does not build
|
|
921
|
+
const named = plan.mode === 'full'
|
|
922
|
+
? { detectedBy, implementationCount, implementationSample, testFileCount: testFiles.length, ...(notRun.length ? { notRun } : {}),
|
|
923
|
+
...(notDetected.length ? { notDetected } : {}), ...(notTests.length ? { notTests } : {}), ...(notBuilt.length ? { notBuilt } : {}) } : {};
|
|
924
|
+
// @implements A-SPEC-128.12 — S1, S2, S3: outside the surface, one message, environment
|
|
925
|
+
// @implements A-SPEC-128.13 — W3: the work-tree rule is gone (a full run is HEAD's worktree); a configuration known to
|
|
926
|
+
// be outside the surface before the run starts no unit (B M2)
|
|
927
|
+
const surface = plan.mode !== 'full' ? [] : outsideSurface.map((o) => ({ ecosystem: o.ecosystem, dir: o.dir, reason: `${exports.UNSUPPORTED}: ${o.reason}` }));
|
|
928
|
+
if (units.length > 0 && surface.length === 0) {
|
|
929
|
+
const reported = new Set(); // @implements A-SPEC-128.10 — I3: every file a runner said it ran or collected
|
|
930
|
+
const skipUnits = new Set(); // units that could not run: their coverage is not the comparison's to judge
|
|
931
|
+
const runners = {
|
|
932
|
+
jest: (f, m, c) => (m === 'full' && jestEntry(c) === null
|
|
933
|
+
? { passed: false, tail: `jest is not installed for this unit (no local node_modules/jest from ${c})`, executed: {}, workers: null, environment: true }
|
|
934
|
+
: runJest(f, m, c, opts)),
|
|
935
|
+
pytest: (f, m, c, ignore) => runPytest(f, m, c, ignore, opts.sourceRoot ? path.join(opts.sourceRoot, path.relative(cwd, c)) : undefined, opts.sourceRoot && m === 'full' ? { root: cwd, sourceRoot: opts.sourceRoot } : undefined),
|
|
936
|
+
go: (f, m, c, ignore) => runGo(f, m, c, { ignore, env: (0, test_units_2.goWorkEnv)(cwd) }),
|
|
937
|
+
rust: (f, m, c) => runCargo(f, m, c), java: (f, m, c) => runGradle(f, m, c), dotnet: (f, m, c) => runDotnet(f, m, c),
|
|
938
|
+
};
|
|
809
939
|
const ran = [];
|
|
810
940
|
let passed = true;
|
|
811
941
|
const tails = [];
|
|
812
942
|
const executedByFile = {};
|
|
813
943
|
const outcomeByFile = {}; // @implements A-SPEC-534.5 — jest only
|
|
814
|
-
|
|
944
|
+
let workers = null; // @implements A-SPEC-466.2 — what the jest adapter placed on its argv
|
|
945
|
+
let testsRun = 0; // @implements A-SPEC-128.5
|
|
946
|
+
const testsRunBy = {}; // @implements A-SPEC-128.6 — per ecosystem, so none hides behind another
|
|
947
|
+
let stopped = false;
|
|
948
|
+
const failedBy = []; // @implements A-SPEC-128.7 — which runner was red, so a refusal can name its tree
|
|
949
|
+
const unitResults = []; // @implements A-SPEC-128.9 — per unit: every unit must run a test
|
|
950
|
+
const environment = [];
|
|
951
|
+
const keyed = (dir, rec) => (dir === '' ? rec : Object.fromEntries(Object.entries(rec).map(([k, v]) => [`${dir}/${k}`, v])));
|
|
952
|
+
for (const u of [...units].sort((a, b) => (a.ecosystem === b.ecosystem ? a.dir.localeCompare(b.dir) : a.ecosystem.localeCompare(b.ecosystem)))) {
|
|
953
|
+
const eco = u.ecosystem;
|
|
815
954
|
STOPPED = null;
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
955
|
+
LEFTOVER = null;
|
|
956
|
+
const unitCwd = u.dir === '' ? cwd : path.join(cwd, u.dir);
|
|
957
|
+
const raw = runners[eco](u.files, plan.mode, unitCwd, u.ignore);
|
|
958
|
+
// @implements A-SPEC-128.12 — S2/S6: exclusions judged after the run. A reported test under an excluded tree leaves
|
|
959
|
+
// the judgement and the counts; one that ran red is environment, named — never hidden
|
|
960
|
+
const { r, excludedRed } = plan.mode === 'full' ? (0, test_reports_1.withoutExcluded)(raw, u.ignore, u.dir) : { r: raw, excludedRed: [] };
|
|
961
|
+
if (eco === 'jest' && workers === null)
|
|
962
|
+
workers = r.workers ?? null;
|
|
963
|
+
if (!ran.includes(eco))
|
|
964
|
+
ran.push(eco);
|
|
965
|
+
passed = passed && r.passed && STOPPED === null && excludedRed.length === 0;
|
|
966
|
+
stopped = stopped || STOPPED !== null;
|
|
967
|
+
if ((!r.passed || STOPPED !== null) && !failedBy.includes(eco))
|
|
968
|
+
failedBy.push(eco);
|
|
969
|
+
// @implements A-SPEC-128.5 — an adapter that counts apart from its credit says so; jest and pytest credit every test
|
|
970
|
+
const own = r.testsRun;
|
|
971
|
+
// @implements A-SPEC-128.6 — every adapter counts for itself; one that does not reports 0, never a guess
|
|
972
|
+
const counted = typeof own === 'number' ? own : 0;
|
|
973
|
+
testsRunBy[eco] = (testsRunBy[eco] ?? 0) + counted;
|
|
974
|
+
testsRun += counted;
|
|
975
|
+
// @implements A-SPEC-128.13 — T3: a test the runner reported from outside the repository (roots or testpaths that
|
|
976
|
+
// leave it) is named, never credited; A-SPEC-128.14 — judged from the repository root (`../shared` from backend is inside)
|
|
977
|
+
const outside = Object.keys(r.executed).filter((k) => path.isAbsolute(k) || path.posix.normalize(u.dir === '' ? k : `${u.dir}/${k}`).startsWith('../'));
|
|
978
|
+
// every reason is kept: a jest projects configuration whose excluded tree also ran red names both
|
|
979
|
+
const reasons = STOPPED !== null ? [] : [environmentReason(r, counted),
|
|
980
|
+
excludedRed.length > 0 ? `제외한 트리의 시험이 실행됨 — 러너 설정에서도 빼야 함: ${excludedRed.slice(0, 5).join(', ')}` : null,
|
|
981
|
+
outside.length > 0 ? `tests outside the repository ran (${outside.slice(0, 3).join(', ')}) — they are not this commit's evidence` : null].filter((x) => x !== null);
|
|
982
|
+
if (outside.length > 0)
|
|
983
|
+
passed = false;
|
|
984
|
+
for (const reason of reasons)
|
|
985
|
+
environment.push({ ecosystem: eco, dir: u.dir, reason });
|
|
986
|
+
const env = reasons.length > 0 ? reasons.join(' | ') : null;
|
|
987
|
+
unitResults.push({ ecosystem: eco, dir: u.dir, testsRun: counted, passed: r.passed && STOPPED === null, ...(env !== null ? { environment: env } : {}) });
|
|
988
|
+
const label = u.dir === '' ? eco : `${eco} @ ${u.dir}`;
|
|
989
|
+
tails.push(`[${label}] ${r.tail}${STOPPED !== null ? `\n${STOPPED}` : ''}${LEFTOVER !== null ? `\n${LEFTOVER}` : ''}`);
|
|
990
|
+
Object.assign(executedByFile, keyed(u.dir, r.executed));
|
|
991
|
+
for (const f of [...Object.keys(r.executed), ...(r.reported ?? [])])
|
|
992
|
+
reported.add(u.dir === '' ? f : `${u.dir}/${f}`);
|
|
993
|
+
if (env !== null || STOPPED !== null)
|
|
994
|
+
skipUnits.add(`${eco}@${u.dir}`);
|
|
821
995
|
const adapterOutcomes = r.outcomes;
|
|
822
996
|
if (adapterOutcomes)
|
|
823
|
-
Object.assign(outcomeByFile, adapterOutcomes);
|
|
997
|
+
Object.assign(outcomeByFile, keyed(u.dir, adapterOutcomes));
|
|
824
998
|
// @implements A-SPEC-137.1 — an adapter whose toolchain is absent reports its files as
|
|
825
999
|
// unsupported; merge them so a scope that could not run them never reads as fully covered.
|
|
826
1000
|
const adapterUnsupported = r.unsupported;
|
|
@@ -828,14 +1002,30 @@ function runTestScope(scope, cwd) {
|
|
|
828
1002
|
unsupported.push(...adapterUnsupported);
|
|
829
1003
|
}
|
|
830
1004
|
if (assumedJest) {
|
|
831
|
-
tails.push('[assumption] full run
|
|
1005
|
+
tails.push('[assumption] full run found no test ecosystem in the project — defaulted to the jest suite');
|
|
832
1006
|
}
|
|
833
1007
|
if (unsupported.length) {
|
|
834
1008
|
tails.push(`[unsupported] ${unsupported.length} test file(s) have no runner adapter: ${unsupported.slice(0, 5).join(', ')}`);
|
|
835
1009
|
}
|
|
1010
|
+
// @implements A-SPEC-128.11 — P6: tests a sparse checkout left out of the work tree cannot run here
|
|
1011
|
+
if (plan.mode === 'full' && sparseTests.length > 0) {
|
|
1012
|
+
passed = false;
|
|
1013
|
+
environment.push({ ecosystem: 'git', dir: '', reason: `sparse checkout — 증빙할 수 없음: ${sparseTests.length} test file(s) outside the work tree, e.g. ${sparseTests.slice(0, 3).join(', ')}` });
|
|
1014
|
+
tails.push(`[sparse] ${sparseTests.length} test file(s) are not in the work tree (skip-worktree): ${sparseTests.slice(0, 5).join(', ')}`);
|
|
1015
|
+
}
|
|
1016
|
+
// @implements A-SPEC-128.10 — I3 and R2, after the run
|
|
1017
|
+
const coverage = plan.mode === 'full' ? coverageAfterRun(expected, codeRoots, reported, executedByFile, skipUnits, buildRoots, testFiles) : null;
|
|
1018
|
+
if (coverage?.notExecuted.length)
|
|
1019
|
+
tails.push(`[not run] ${coverage.notExecuted.length} detected test file(s) did not run: ${coverage.notExecuted.slice(0, 5).join(', ')}`);
|
|
1020
|
+
if (coverage?.untestedCode.length)
|
|
1021
|
+
tails.push(`[untested] code with no executed test under: ${coverage.untestedCode.map((g) => g.root || '(root)').join(', ')}`);
|
|
836
1022
|
return {
|
|
837
1023
|
tier: scope.tier, mode: plan.mode, ranFiles: plan.testFiles, passed, skipped: false,
|
|
838
|
-
tail: tails.join('\n'), executedByFile, ranWith: ran,
|
|
1024
|
+
tail: tails.join('\n'), executedByFile, ranWith: ran, workers, testsRun, testsRunBy, stopped, detected, failedBy, ...named,
|
|
1025
|
+
...(plan.mode === 'full' ? { units: unitResults } : {}), ...(environment.length ? { environment } : {}),
|
|
1026
|
+
...(coverage?.notExecuted.length ? { notExecuted: coverage.notExecuted.slice(0, 200) } : {}),
|
|
1027
|
+
...(coverage?.untestedCode.length ? { untestedCode: coverage.untestedCode } : {}),
|
|
1028
|
+
workersIgnoredBy: opts.workers === undefined ? [] : ran.filter((eco) => eco !== 'jest'),
|
|
839
1029
|
...(Object.keys(outcomeByFile).length ? { outcomeByFile } : {}),
|
|
840
1030
|
...(unsupported.length ? { unsupported } : {}),
|
|
841
1031
|
};
|
|
@@ -845,8 +1035,15 @@ function runTestScope(scope, cwd) {
|
|
|
845
1035
|
// the no-passWithNoTests rule exists to prevent.
|
|
846
1036
|
return {
|
|
847
1037
|
tier: scope.tier, mode: plan.mode, ranFiles: plan.testFiles, passed: false, skipped: false,
|
|
848
|
-
|
|
849
|
-
|
|
1038
|
+
// @implements A-SPEC-128.8 — a full plan with nothing detected at the root says so, not "no adapter for 0 files"
|
|
1039
|
+
tail: surface.length > 0 ? `no unit started — outside the 0.40.x surface:\n${surface.map((s) => s.reason).join('\n')}`
|
|
1040
|
+
: plan.mode === 'full' && unsupported.length === 0
|
|
1041
|
+
? `no test unit in the project — nothing ran${implementationCount > 0 ? ` (implementation code without tests, e.g. ${implementationSample.join(', ')})` : ''}`
|
|
1042
|
+
: `no runner adapter for ${unsupported.length} test file(s): ${unsupported.slice(0, 5).join(', ')}`,
|
|
1043
|
+
executedByFile: {}, unsupported, ranWith: [], workers: null, testsRun: 0, testsRunBy: {}, stopped: false, detected, ...named,
|
|
1044
|
+
...(plan.mode === 'full' ? { units: [] } : {}), ...(surface.length ? { environment: surface } : {}),
|
|
1045
|
+
// @implements A-SPEC-128.10 — R2: with no unit, every build root's code is untested (and names a missing build file)
|
|
1046
|
+
...(plan.mode === 'full' && surface.length === 0 && codeRoots.length ? { untestedCode: codeRoots.map((g) => ({ root: g.root, sample: g.sample, ...(g.missingBuildFile ? { missingBuildFile: g.missingBuildFile } : {}) })) } : {}),
|
|
850
1047
|
};
|
|
851
1048
|
}
|
|
852
1049
|
// @implements A-SPEC-515.1
|
|
@@ -912,18 +1109,32 @@ function failedTestSummary(stdout, limit = 5) {
|
|
|
912
1109
|
if (j === null || typeof j !== 'object' || !Array.isArray(j.testResults))
|
|
913
1110
|
return null;
|
|
914
1111
|
const failures = [];
|
|
1112
|
+
const broken = [];
|
|
915
1113
|
for (const file of j.testResults) {
|
|
916
1114
|
const base = typeof file?.name === 'string' ? file.name.split(/[\\/]/).pop() ?? file.name : '(unknown file)';
|
|
1115
|
+
const before = failures.length;
|
|
917
1116
|
for (const a of Array.isArray(file?.assertionResults) ? file.assertionResults : []) {
|
|
918
1117
|
if (a?.status !== 'failed')
|
|
919
1118
|
continue;
|
|
920
1119
|
const msg = Array.isArray(a.failureMessages) ? a.failureMessages.find((m) => typeof m === 'string' && m.trim() !== '') : undefined;
|
|
1120
|
+
// @implements A-SPEC-466.4 \u2014 one line per name, each part bounded on its own, so one long message pushes no name out
|
|
921
1121
|
failures.push({
|
|
922
|
-
where: `${base} \u203a ${String(a.title ?? '(untitled)')}`,
|
|
923
|
-
first: typeof msg === 'string' ? (msg.trim().split('\n')[0] ?? '') : '',
|
|
1122
|
+
where: clip(`${base} \u203a ${String(a.title ?? '(untitled)').replace(/\s+/g, ' ').trim()}`, WHERE_MAX),
|
|
1123
|
+
first: clip(typeof msg === 'string' ? (msg.trim().split('\n')[0] ?? '') : '', FIRST_MAX),
|
|
924
1124
|
});
|
|
925
1125
|
}
|
|
1126
|
+
// @implements A-SPEC-466.3 \u2014 a suite that failed with no failing assertion (it did not compile, its teardown threw)
|
|
1127
|
+
// is named too, with the first line of its message
|
|
1128
|
+
// @implements A-SPEC-466.4 \u2014 the cause line: jest opens the message with a `\u25cf Test suite failed to run` header
|
|
1129
|
+
if (file?.status === 'failed' && failures.length === before) {
|
|
1130
|
+
const message = typeof file.message === 'string' ? file.message.replace(/\u001b\[[0-9;]*m/g, '') : '';
|
|
1131
|
+
const cause = message.split('\n').map((l) => l.trim()).find((l) => l !== '' && !l.startsWith('\u25cf')) ?? '';
|
|
1132
|
+
broken.push({ where: clip(`${base} \u203a (suite failed to run)`, WHERE_MAX), first: clip(cause, FIRST_MAX) });
|
|
1133
|
+
}
|
|
926
1134
|
}
|
|
1135
|
+
// @implements A-SPEC-466.5 \u2014 suites that failed to run come first: in a real mixed run (24 failing assertions, 2
|
|
1136
|
+
// broken suites) the five-name bound was spent on assertions and no broken suite was named
|
|
1137
|
+
failures.unshift(...broken);
|
|
927
1138
|
if (failures.length === 0)
|
|
928
1139
|
return null;
|
|
929
1140
|
const shown = failures.slice(0, Math.max(0, limit));
|
|
@@ -933,6 +1144,31 @@ function failedTestSummary(stdout, limit = 5) {
|
|
|
933
1144
|
lines.push(` \u2026 \uc678 ${rest}\uac74`);
|
|
934
1145
|
return lines.join('\n');
|
|
935
1146
|
}
|
|
1147
|
+
/** @implements A-SPEC-466.4 \u2014 each failure line's own bound: `file \u203a title` and its first message line. */
|
|
1148
|
+
const WHERE_MAX = 200;
|
|
1149
|
+
const FIRST_MAX = 300;
|
|
1150
|
+
/** @implements A-SPEC-466.4 \u2014 `text` cut to at most `max` characters, marked `\u2026`, never inside a surrogate pair. */
|
|
1151
|
+
function clip(text, max) {
|
|
1152
|
+
if (text.length <= max)
|
|
1153
|
+
return text;
|
|
1154
|
+
let end = max - 1;
|
|
1155
|
+
if (/[\uD800-\uDBFF]/.test(text[end - 1] ?? ''))
|
|
1156
|
+
end -= 1;
|
|
1157
|
+
return `${text.slice(0, end)}\u2026`;
|
|
1158
|
+
}
|
|
1159
|
+
/**
|
|
1160
|
+
* @implements A-SPEC-466.3, A-SPEC-466.4 \u2014 the tail of a red jest run. The failing names come first; jest's stderr
|
|
1161
|
+
* follows with a bound of its own. One `tailOf` over both kept the last lines and cut the front, so a long stderr pushed
|
|
1162
|
+
* every name out (2026-11-04, `27bc0c40`: five failures, none named). The name block is bounded by its parts: five names
|
|
1163
|
+
* of at most WHERE_MAX and FIRST_MAX characters and one count line, so the whole tail stays under 7,000 characters.
|
|
1164
|
+
* Without readable jest JSON the tail is what it always was.
|
|
1165
|
+
*/
|
|
1166
|
+
function redJestTail(stdout, stderr) {
|
|
1167
|
+
const named = failedTestSummary(stdout);
|
|
1168
|
+
if (named === null)
|
|
1169
|
+
return tailOf(`${stdout}\n${stderr}`, { lines: 6 });
|
|
1170
|
+
return `${named}\n${tailOf(stderr, { lines: 30 })}`;
|
|
1171
|
+
}
|
|
936
1172
|
function summarizeJestJson(stdout) {
|
|
937
1173
|
// The payload is not the whole of stdout. A suite that logs anything prints it BEFORE the JSON,
|
|
938
1174
|
// and this repository's own suite does: measured, the first live run after this function landed
|