Address PR review feedback (#1785)
- P2 (greptile): anchor the changed-test existence check at the git repo root (repoRootForExistence via `git rev-parse --show-toplevel`) instead of rootDir, so a script run from a package subdir without FUSION_PROJECT_DIR no longer forms a doubled path and silently drops live tests into the delegate path. +1 regression test (default root resolves to repo root). - coderabbit: fix stale "1-worker lane" wording in the delegation log (now "heavy memory-envelope lane") and the "single-worker envelope" test title, both stale after the 1->4 worker change. test-changed 118/118, eslint clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -370,7 +370,7 @@ test("@fusion/core is a wide-fan-out memory-envelope package but is NOT gate-cov
|
||||
);
|
||||
});
|
||||
|
||||
test("core scoped-affected env applies the bounded heap and single-worker envelope", () => {
|
||||
test("core scoped-affected env applies the bounded heap and worker envelope", () => {
|
||||
const env = createScopedAffectedMemoryEnvelopeEnv(CORE_SCOPED_AFFECTED_PACKAGE, {
|
||||
NODE_OPTIONS: "--trace-warnings",
|
||||
HOME: "/tmp/fusion-home",
|
||||
@@ -1976,6 +1976,14 @@ test("existingChangedTestFilesInPackage: excludes non-test and out-of-package pa
|
||||
}
|
||||
});
|
||||
|
||||
// FNXC:TestInfrastructure 2026-06-26-13:40: regression for the doubled-path subdir
|
||||
// bug — with NO projectRoot passed, the existence root must resolve to the git repo
|
||||
// root (not cwd), so a real repo-relative test path is found from any cwd.
|
||||
test("existingChangedTestFilesInPackage: default existence root anchors at the git repo root", () => {
|
||||
const selfRel = "scripts/__tests__/test-changed.test.mjs"; // this very file — guaranteed on disk
|
||||
assert.deepEqual(existingChangedTestFilesInPackage([selfRel], "scripts"), [selfRel]);
|
||||
});
|
||||
|
||||
// FNXC:TestInfrastructure 2026-06-26-09:15: the merge gate re-covers a delegated
|
||||
// engine lane (curated engine-core subset) but runs NO dashboard tests. Lock that
|
||||
// asymmetry so the delegation messaging never overclaims dashboard gate coverage.
|
||||
|
||||
@@ -1469,7 +1469,26 @@ handing Vitest an empty/garbage positional set.
|
||||
* @param {{ projectRoot?: string }} [opts]
|
||||
* @returns {string[]}
|
||||
*/
|
||||
export function existingChangedTestFilesInPackage(changedFiles, pkgDir, { projectRoot = rootDir } = {}) {
|
||||
/*
|
||||
FNXC:TestInfrastructure 2026-06-26-13:40:
|
||||
Existence checks for changed test files must anchor at the GIT REPO ROOT, not
|
||||
`rootDir` (which falls back to `process.cwd()`). `git diff --name-only` returns
|
||||
repo-root-relative paths regardless of the cwd it runs from, so joining them
|
||||
against a `rootDir` that is a package SUBDIR (script run from a package without
|
||||
FUSION_PROJECT_DIR) would form a doubled path (packages/x/packages/x/...), make
|
||||
`existsSync` false, and silently DROP live changed tests into the delegate path.
|
||||
Resolve the toplevel once via git so the check is correct from any cwd inside the
|
||||
repo; fall back to rootDir if git can't report a toplevel.
|
||||
*/
|
||||
let _repoToplevelCache;
|
||||
function repoRootForExistence() {
|
||||
if (_repoToplevelCache !== undefined) return _repoToplevelCache;
|
||||
const top = gitOutput(["rev-parse", "--show-toplevel"]);
|
||||
_repoToplevelCache = top && top.trim() ? top.trim() : rootDir;
|
||||
return _repoToplevelCache;
|
||||
}
|
||||
|
||||
export function existingChangedTestFilesInPackage(changedFiles, pkgDir, { projectRoot = repoRootForExistence() } = {}) {
|
||||
return (changedFiles ?? []).filter(
|
||||
(file) =>
|
||||
isTestFilePath(file) &&
|
||||
@@ -1794,7 +1813,7 @@ export async function main(argv = process.argv.slice(2)) {
|
||||
const log = gateCovered ? console.log : console.warn;
|
||||
log(
|
||||
`[test-changed] ${pkg}: a changed non-test source file (${wideSourceDesc}) ` +
|
||||
"would fan `vitest --changed` out to ~the full suite at this heavy 1-worker lane; " +
|
||||
"would fan `vitest --changed` out to ~the full suite at this heavy memory-envelope lane; " +
|
||||
`no directly-changed ${pkg} test file to run, so ${delegationNote}`,
|
||||
);
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user