From e270e5898a06a0839bbb25414b0925e23ca37e8a Mon Sep 17 00:00:00 2001 From: jakecastelli <959672929@qq.com> Date: Fri, 28 Jun 2024 22:10:28 +0930 Subject: [PATCH] fixup --- lib/internal/test_runner/runner.js | 7 +++---- test/parallel/test-runner-watch-mode-complex.mjs | 7 +++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/internal/test_runner/runner.js b/lib/internal/test_runner/runner.js index 537d80105072b0..76159a237a0bad 100644 --- a/lib/internal/test_runner/runner.js +++ b/lib/internal/test_runner/runner.js @@ -425,19 +425,18 @@ function watchFiles(testFiles, opts) { const newFileName = ArrayPrototypeFind(updatedTestFiles, (x) => !ArrayPrototypeIncludes(testFiles, x)); const previousFileName = ArrayPrototypeFind(testFiles, (x) => !ArrayPrototypeIncludes(updatedTestFiles, x)); + testFiles = updatedTestFiles; + // When file renamed if (newFileName && previousFileName) { owners = new SafeSet().add(newFileName); watcher.filterFile(resolve(newFileName), owners); } - // When file deleted if (!newFileName && previousFileName) { - testFiles = updatedTestFiles; - return; + return; // Avoid rerunning files when file deleted } - testFiles = updatedTestFiles; } watcher.unfilterFilesOwnedBy(owners); diff --git a/test/parallel/test-runner-watch-mode-complex.mjs b/test/parallel/test-runner-watch-mode-complex.mjs index 763e854e86180b..93cf5b401727ef 100644 --- a/test/parallel/test-runner-watch-mode-complex.mjs +++ b/test/parallel/test-runner-watch-mode-complex.mjs @@ -41,8 +41,11 @@ import 'data:text/javascript,'; test('test to delete has ran');`, }; -const fixturePaths = Object.keys(fixtureContent) - .reduce((acc, file) => ({ ...acc, [file]: tmpdir.resolve(file) }), {}); +const fixturePaths = Object.fromEntries(Object.keys(fixtureContent) + .map((file) => [file, tmpdir.resolve(file)])); + + console.log(fixturePaths) + Object.entries(fixtureContent) .forEach(([file, content]) => writeFileSync(fixturePaths[file], content));