From ee4fa77624f17c1958dac47fddbe7d9513b9dee8 Mon Sep 17 00:00:00 2001 From: Raz Luvaton <16746759+rluvaton@users.noreply.github.com> Date: Thu, 11 Apr 2024 13:56:02 +0300 Subject: [PATCH] test: fix watch test with require not testing pid PR-URL: https://github.com/nodejs/node/pull/52353 Reviewed-By: Moshe Atlow Reviewed-By: Antoine du Hamel --- test/sequential/test-watch-mode.mjs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/sequential/test-watch-mode.mjs b/test/sequential/test-watch-mode.mjs index 4f029602a11b6b..cc8c56d67ec77e 100644 --- a/test/sequential/test-watch-mode.mjs +++ b/test/sequential/test-watch-mode.mjs @@ -307,9 +307,9 @@ console.log(values.random); const file = createTmpFile(); const required = createTmpFile('process._rawDebug(\'pid\', process.pid);'); const args = ['--require', required, file]; - const { stdout, pid } = await runWriteSucceed({ file, watchedFile: file, args }); + const { stdout, pid, stderr } = await runWriteSucceed({ file, watchedFile: file, args }); - const importPid = parseInt(stdout[0].split(' ')[1], 10); + const importPid = parseInt(stderr[0].split(' ')[1], 10); assert.notStrictEqual(pid, importPid); assert.deepStrictEqual(stdout, [ 'running', @@ -324,10 +324,13 @@ console.log(values.random); const file = createTmpFile(); const imported = "data:text/javascript,process._rawDebug('pid', process.pid);"; const args = ['--import', imported, file]; - const { stdout, pid } = await runWriteSucceed({ file, watchedFile: file, args }); + const { stdout, pid, stderr } = await runWriteSucceed({ file, watchedFile: file, args }); - const importPid = parseInt(stdout[0].split(' ')[1], 10); + const importPid = parseInt(stderr.split('\n', 1)[0].split(' ', 2)[1], 10); + + assert.notStrictEqual(importPid, NaN); assert.notStrictEqual(pid, importPid); + assert.deepStrictEqual(stdout, [ 'running', `Completed running ${inspect(file)}`,