Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions release-files.json
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@
"tests/repo/test-discovery.test.ts",
"tests/repo/test-fixture-ownership.test.ts",
"tests/repo/test-framework.test.ts",
"tests/repo/test-universe-empty-reason.test.ts",
"tests/repo/tool-config-reasons.test.ts",
"tests/repo/tsconfig-variant-reason.test.ts",
"tests/repo/tsconfig-newer-options.test.ts",
Expand Down
5 changes: 4 additions & 1 deletion src/repo/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,10 @@ export async function buildDependencyGraph(
profile.testFilePaths = [...new Set([...profile.testFilePaths, ...adapterTests])].sort();
if (profile.testUniverse) {
profile.testUniverse.discoveredTestFiles = profile.testFilePaths.length;
profile.testUniverse.blindSpot = (profile.testUniverse.declaredFrameworks.length > 0 || contributions.some((item) => item.id === "go" || item.id === "maven" || item.id === "python" || item.id === "rust")) && profile.testFilePaths.length === 0;
const runners: Record<string, string> = { go: "go test", maven: "Maven", python: "pytest", rust: "cargo test" };
const adapterRunners = contributions.flatMap((item) => runners[item.id] ? [runners[item.id]!] : []);
if (adapterRunners.length) profile.testUniverse.adapterRunners = adapterRunners;
profile.testUniverse.blindSpot = (profile.testUniverse.declaredFrameworks.length > 0 || adapterRunners.length > 0) && profile.testFilePaths.length === 0;
}
const entryPointPaths = new Set(profile.entryPoints.map((e) => e.path));

Expand Down
3 changes: 2 additions & 1 deletion src/repo/impact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,8 @@ export class ImpactAnalyzer {
// whose entire `__tests__/` suite was invisible: graph confidence COMPLETE, 5 of 5 commits
// SELECTIVE, zero tests. Fails closed to FULL instead.
if (profile.testUniverse?.blindSpot === true) {
const declared = profile.testUniverse.declaredFrameworks.join(", ");
// A language adapter (Go, Maven, pytest, Cargo) declares its runner without a package.json framework.
const declared = [...profile.testUniverse.declaredFrameworks, ...(profile.testUniverse.adapterRunners ?? [])].join(", ");
const message = `Repository declares ${declared} but no test files were discovered; full validation required`;
riskSignals.push({ level: "critical", reason: "TEST_UNIVERSE_EMPTY", message });
if (!fallbackReasons.includes(message)) fallbackReasons.push(message);
Expand Down
2 changes: 2 additions & 0 deletions src/repo/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ export interface RepositoryProfile {
/** How each framework was detected - "dependency:<pkg>" or "script:<name>". */
frameworkEvidence: Record<string, string>;
discoveredTestFiles: number;
/** Runners that language adapters found sources for (`go test`, `Maven`, `pytest`, `cargo test`). */
adapterRunners?: string[];
/** True when the repository declares a test framework and zero test files were discovered - the
* engine does not understand this repository's test layout, and must not propose a selection
* against an empty universe. */
Expand Down
34 changes: 34 additions & 0 deletions tests/repo/test-universe-empty-reason.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-License-Identifier: MIT
import { strict as assert } from "node:assert";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
import { test } from "node:test";
import { buildDependencyGraph } from "../../src/repo/graph.js";
import { ImpactAnalyzer } from "../../src/repo/impact.js";
import type { GitDelta } from "../../src/git/types.js";

// A language adapter's repository has no package.json test framework, so the TEST_UNIVERSE_EMPTY
// reason read "Repository declares but no test files were discovered".
test("an adapter repository with no tests names its runner in the empty-universe reason", async () => {
const root = mkdtempSync(join(tmpdir(), "diffci-empty-universe-"));
const files: Record<string, string> = {
"pom.xml": "<project><groupId>example</groupId><artifactId>tool</artifactId><version>1</version></project>",
"src/main/java/example/Tool.java": "package example; public class Tool {}",
};
for (const [path, content] of Object.entries(files)) {
mkdirSync(dirname(join(root, path)), { recursive: true });
writeFileSync(join(root, path), content);
}
try {
const graph = await buildDependencyGraph({ repoPath: root });
const delta: GitDelta = {
baseSha: "base", headSha: "head", files: [{ path: "src/main/java/example/Tool.java", changeType: "modified" }], directories: [],
summary: { total: 1, added: 0, modified: 1, deleted: 0, renamed: 0, copied: 0, unmerged: 0, unknown: 0 },
analysis: { empty: false, configChanged: false, dependencyManifestChanged: false, lockfileChanged: false, workflowChanged: false, infrastructureChanged: false, databaseChanged: false },
};
const impact = new ImpactAnalyzer().analyze(delta, graph, graph.profile);
assert.equal(impact.fallbackRequired, true);
assert.ok(impact.fallbackReasons.includes("Repository declares Maven but no test files were discovered; full validation required"), impact.fallbackReasons.join("; "));
} finally { rmSync(root, { recursive: true, force: true }); }
});
Loading