From b5eb24c86a454548633cf9990cde56e9cf5445cb Mon Sep 17 00:00:00 2001 From: Colin Ihrig Date: Mon, 26 Aug 2024 08:39:36 -0400 Subject: [PATCH] test: force spec reporter in test-runner-watch-mode.mjs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: https://github.com/nodejs/node/issues/54535 PR-URL: https://github.com/nodejs/node/pull/54538 Reviewed-By: Luigi Pinca Reviewed-By: Michaƫl Zasso Reviewed-By: Matteo Collina Reviewed-By: Benjamin Gruenbaum Reviewed-By: James M Snell --- test/parallel/test-runner-watch-mode.mjs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/test/parallel/test-runner-watch-mode.mjs b/test/parallel/test-runner-watch-mode.mjs index ee124493575103..fd7b47fb45149a 100644 --- a/test/parallel/test-runner-watch-mode.mjs +++ b/test/parallel/test-runner-watch-mode.mjs @@ -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 = ''; @@ -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(); }); @@ -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/); } }; @@ -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/); } };