Commit 381b962d217 for nodejs

commit 381b962d2174beff0f8e42347994f43c64990e56
Author: Filip Skokan <panva.ip@gmail.com>
Date:   Wed Sep 23 18:01:27 2026 +0200

    test: deflake watch mode tests

    Use isolated directories for the NODE_OPTIONS watch paths to avoid
    recursively watching the repository's source and test trees. Allow a
    platform-scaled 10 seconds for startup and restarts.

    Remove the flaky markers for test-watch-mode and
    test-watch-mode-inspect. The inspector restart race was already fixed
    in f2aaf638465.

    Signed-off-by: Filip Skokan <panva.ip@gmail.com>
    Assisted-by: Codex
    PR-URL: https://github.com/nodejs/node/pull/66232
    Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
    Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
    Reviewed-By: Matteo Collina <matteo.collina@gmail.com>

diff --git a/test/sequential/sequential.status b/test/sequential/sequential.status
index 6b5714500b2..4111eb2b8ec 100644
--- a/test/sequential/sequential.status
+++ b/test/sequential/sequential.status
@@ -7,9 +7,6 @@ prefix sequential
 [true] # This section applies to all platforms
 # https://github.com/nodejs/node/issues/27611#issuecomment-613100468
 test-cpu-prof-dir-worker: PASS, FLAKY
-# https://github.com/nodejs/node/issues/44898
-test-watch-mode: PASS, FLAKY
-test-watch-mode-inspect: PASS, FLAKY
 # https://github.com/nodejs/node/issues/47409
 test-http2-large-file: PASS, FLAKY

diff --git a/test/sequential/test-watch-mode.mjs b/test/sequential/test-watch-mode.mjs
index d14493192a0..0c28adec017 100644
--- a/test/sequential/test-watch-mode.mjs
+++ b/test/sequential/test-watch-mode.mjs
@@ -87,7 +87,7 @@ function runInBackground({ args = [], options = {}, completed = 'Completed runni
       future.resolve();
       return { stdout, stderr };
     },
-    restart(timeout = 1000) {
+    restart(timeout = common.platformTimeout(10_000)) {
       if (!child) {
         run();
       }
@@ -996,6 +996,10 @@ process.on('message', (message) => {
   });

   it('should strip all watch flags from NODE_OPTIONS in child process', async () => {
+    // Avoid recursively watching the repository's source and test trees.
+    const cwd = tmpdir.resolve('node-options');
+    mkdirSync(path.join(cwd, 'src'), { recursive: true });
+    mkdirSync(path.join(cwd, 'test'));
     const file = createTmpFile('console.log(process.env.NODE_OPTIONS);');
     const nodeOptions = [
       '--watch',
@@ -1012,6 +1016,7 @@ process.on('message', (message) => {
     const { done, restart } = runInBackground({
       args: ['--watch', file],
       options: {
+        cwd,
         env: { ...process.env, NODE_OPTIONS: nodeOptions },
       },
     });
@@ -1040,7 +1045,8 @@ process.on('message', (message) => {
     writeFileSync(reqFile, 'globalThis.requiredOk = true;');

     const file = createTmpFile('console.log("required:" + !!globalThis.requiredOk);');
-    const nodeOptions = `--watch --require "${reqFile}"`;
+    // Backslashes inside quoted NODE_OPTIONS values are escape characters.
+    const nodeOptions = `--watch --require "${reqFile.replaceAll(path.sep, '/')}"`;
     const { done, restart } = runInBackground({
       args: ['--watch', file],
       options: {