fix(test): harden planner artifact cleanup and profile env fallback

This commit is contained in:
Peter Steinberger
2026-03-29 00:19:57 +00:00
parent c3a0304f63
commit 03826b8075
4 changed files with 107 additions and 20 deletions

View File

@@ -166,6 +166,14 @@ export function createExecutionArtifacts(env = process.env) {
return { ensureTempArtifactDir, writeTempJsonArtifact, cleanupTempArtifacts };
}
export function createTempArtifactWriteStream(filePath) {
const fd = fs.openSync(filePath, "w");
return fs.createWriteStream(filePath, {
fd,
autoClose: true,
});
}
const ensureNodeOptionFlag = (nodeOptions, flagPrefix, nextValue) =>
nodeOptions.includes(flagPrefix) ? nodeOptions : `${nodeOptions} ${nextValue}`.trim();
@@ -420,7 +428,7 @@ export async function executePlan(plan, options = {}) {
.filter(Boolean)
.join("-");
const laneLogPath = path.join(artifacts.ensureTempArtifactDir(), `${artifactStem}.log`);
const laneLogStream = fs.createWriteStream(laneLogPath, { flags: "w" });
const laneLogStream = createTempArtifactWriteStream(laneLogPath);
laneLogStream.write(`[test-parallel] entry=${unit.id}\n`);
laneLogStream.write(`[test-parallel] cwd=${process.cwd()}\n`);
laneLogStream.write(