Skip to content

Commit

Permalink
Write the phase2/3 change reason to the phase files
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdz committed Aug 4, 2024
1 parent ad77a9b commit 8e99a9a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tests/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,19 @@ function runTestCase(
},
onAfterPhase(phaseIndex, passIndex, phaseLoopIndex, fdata, changed, options) {
// After each phase (0=normalize), generally 1 is not interesting to print since that's just scanning
// Changed is either falsy, or {action: string (name of plugin), changes: number, next: phase1 | normal}
if (options.logPhases) {
const f = path.join(options.logDir, `preval.pass.${passIndex}.loop.${phaseLoopIndex}.phase${phaseIndex}.log.js`);
const code = tmat(fdata.tenkoOutput.ast, true);
const now = Date.now();
console.log(`--log: Logging state of pass ${passIndex}, loop ${phaseLoopIndex}, ${phaseIndex ? `phase ${phaseIndex}` : 'normal '} to disk:`, f, '(', code.length, 'bytes)', lastWrite ? `, ${now - lastWrite}ms since last write` : '');
console.log(`--log: Logging state of pass ${passIndex}, loop ${phaseLoopIndex}, ${phaseIndex ? `phase ${phaseIndex}` : 'normal '} to disk:`, f, '(', code.length, 'bytes)', lastWrite ? `, ${now - lastWrite}ms since last write` : '', changed ? `Phase 2/3: changed by ${changed.what}` : '');
lastWrite = now;
fs.writeFileSync(f, `// Resulting output at pass ${passIndex}, loop ${phaseLoopIndex}, phase ${phaseIndex} [${fname}]\n// Command: ` + process.argv.join(' ') + '\n' + code);
fs.writeFileSync(f,
`// Resulting output at pass ${passIndex}, loop ${phaseLoopIndex}, phase ${phaseIndex} [${fname}]\n` +
`// Command: ${process.argv.join(' ')}\n` +
`// Last phase2/3 plugin result: ${changed ? JSON.stringify(changed) : '(none)'}\n` +
code
);
}
}
},
Expand Down

0 comments on commit 8e99a9a

Please sign in to comment.