Sitelet https://github.com/nodejs/node/pull/46577/commits/18587281b678e8834bae2763458d88e23d92a304
Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add debug logs
  • Loading branch information
MoLow committed Feb 25, 2023
commit 18587281b678e8834bae2763458d88e23d92a304
5 changes: 5 additions & 0 deletions test/parallel/test-runner-watch-mode.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@ async function testWatch({ files, fileToUpdate }) {
const ran2 = util.createDeferredPromise();
const child = spawn(process.execPath, ['--watch', '--test', '--no-warnings', ...files], { encoding: 'utf8' });
let stdout = '';

console.log(`${child.pid} [running test]`);
Comment thread
MoLow marked this conversation as resolved.
Outdated
child.stdout.on('data', (data) => {
console.log(data.toString().split(/\r?\n/).map((line) => `${child.pid} [stdout] ${line}`).join('\n'));
Comment thread
MoLow marked this conversation as resolved.
Outdated
stdout += data.toString();
const matches = stdout.match(/test has ran/g);
if (matches?.length >= 1) ran1.resolve();
if (matches?.length >= 2) ran2.resolve();
});

await ran1.promise;
console.log(`${child.pid} [restarting]`);
Comment thread
MoLow marked this conversation as resolved.
Outdated
const interval = setInterval(() => writeFileSync(fileToUpdate, readFileSync(fileToUpdate, 'utf8')), 50);
await ran2.promise;
clearInterval(interval);
console.log(`${child.pid} [done]`);
Comment thread
MoLow marked this conversation as resolved.
Outdated
child.kill();
}

Expand Down