Merge pull request #3982 from mastertyko/fix/3965-pre-exec-existing-file-ordering
fix(gsd): ignore pre-existing files in task ordering
This commit is contained in:
commit
f76c282bad
2 changed files with 36 additions and 2 deletions
|
|
@ -387,7 +387,7 @@ export function checkFilePathConsistency(
|
|||
*/
|
||||
export function checkTaskOrdering(
|
||||
tasks: TaskRow[],
|
||||
_basePath: string
|
||||
basePath: string
|
||||
): PreExecutionCheckJSON[] {
|
||||
const results: PreExecutionCheckJSON[] = [];
|
||||
|
||||
|
|
@ -415,7 +415,9 @@ export function checkTaskOrdering(
|
|||
|
||||
const normalizedFile = normalizeFilePath(file);
|
||||
const creator = fileCreators.get(normalizedFile);
|
||||
if (creator && creator.index > i) {
|
||||
const absolutePath = resolve(basePath, normalizedFile);
|
||||
const existsOnDisk = existsSync(absolutePath);
|
||||
if (creator && creator.index > i && !existsOnDisk) {
|
||||
// Task reads file that is created later — impossible ordering
|
||||
results.push({
|
||||
category: "file",
|
||||
|
|
|
|||
|
|
@ -1107,6 +1107,38 @@ describe("checkTaskOrdering false positive regression (#3677)", () => {
|
|||
assert.equal(results[0].target, "`later.ts` — needed first");
|
||||
assert.ok(results[0].message.includes("sequence violation"));
|
||||
});
|
||||
|
||||
test("existing on-disk files do not trigger ordering violations just because a later task modifies them", () => {
|
||||
const tempDir = join(tmpdir(), `pre-exec-ordering-existing-file-${Date.now()}`);
|
||||
const existingFile = "frontend/src/__tests__/ProcurementPage29.test.tsx";
|
||||
|
||||
mkdirSync(join(tempDir, "frontend", "src", "__tests__"), { recursive: true });
|
||||
writeFileSync(join(tempDir, existingFile), "// existing file");
|
||||
|
||||
try {
|
||||
const tasks = [
|
||||
createTask({
|
||||
id: "T01",
|
||||
sequence: 0,
|
||||
files: [],
|
||||
inputs: ["`frontend/src/__tests__/ProcurementPage29.test.tsx` — contains matchMedia stub to remove"],
|
||||
expected_output: [],
|
||||
}),
|
||||
createTask({
|
||||
id: "T03",
|
||||
sequence: 2,
|
||||
files: [],
|
||||
inputs: [],
|
||||
expected_output: ["frontend/src/__tests__/ProcurementPage29.test.tsx"],
|
||||
}),
|
||||
];
|
||||
|
||||
const results = checkTaskOrdering(tasks, tempDir);
|
||||
assert.equal(results.length, 0, "Pre-existing files should not be treated as created by later tasks");
|
||||
} finally {
|
||||
rmSync(tempDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// ─── checkFilePathConsistency additional edge cases ──────────────────────────
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue