Skip to content

Commit

Permalink
test: force spec reporter in test-runner-watch-mode.mjs
Browse files Browse the repository at this point in the history
In the CI this test generates TAP output that can confuse the
Python test runner. Avoid the problem by not outputting TAP at
from the spawned child process.

Fixes: #54535
PR-URL: #54538
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
cjihrig authored and RafaelGSS committed Aug 30, 2024
1 parent 7d9e994 commit b5eb24c
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions test/parallel/test-runner-watch-mode.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ async function testWatch({ fileToUpdate, file, action = 'update' }) {
const ran1 = util.createDeferredPromise();
const ran2 = util.createDeferredPromise();
const child = spawn(process.execPath,
['--watch', '--test', file ? fixturePaths[file] : undefined].filter(Boolean),
['--watch', '--test', '--test-reporter=spec',
file ? fixturePaths[file] : undefined].filter(Boolean),
{ encoding: 'utf8', stdio: 'pipe', cwd: tmpdir.path });
let stdout = '';
let currentRun = '';
Expand All @@ -50,7 +51,7 @@ async function testWatch({ fileToUpdate, file, action = 'update' }) {
child.stdout.on('data', (data) => {
stdout += data.toString();
currentRun += data.toString();
const testRuns = stdout.match(/# duration_ms\s\d+/g);
const testRuns = stdout.match(/duration_ms\s\d+/g);
if (testRuns?.length >= 1) ran1.resolve();
if (testRuns?.length >= 2) ran2.resolve();
});
Expand All @@ -71,10 +72,10 @@ async function testWatch({ fileToUpdate, file, action = 'update' }) {
assert.strictEqual(runs.length, 2);

for (const run of runs) {
assert.match(run, /# tests 1/);
assert.match(run, /# pass 1/);
assert.match(run, /# fail 0/);
assert.match(run, /# cancelled 0/);
assert.match(run, /tests 1/);
assert.match(run, /pass 1/);
assert.match(run, /fail 0/);
assert.match(run, /cancelled 0/);
}
};

Expand All @@ -94,10 +95,10 @@ async function testWatch({ fileToUpdate, file, action = 'update' }) {
assert.strictEqual(runs.length, 2);

for (const run of runs) {
assert.match(run, /# tests 1/);
assert.match(run, /# pass 1/);
assert.match(run, /# fail 0/);
assert.match(run, /# cancelled 0/);
assert.match(run, /tests 1/);
assert.match(run, /pass 1/);
assert.match(run, /fail 0/);
assert.match(run, /cancelled 0/);
}
};

Expand Down

0 comments on commit b5eb24c

Please sign in to comment.