Skip to content

Commit

Permalink
test_runner: fix unix failures
Browse files Browse the repository at this point in the history
  • Loading branch information
pmarchini committed Sep 17, 2024
1 parent 6dd0915 commit a3bea98
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
3 changes: 2 additions & 1 deletion lib/internal/test_runner/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,8 @@ function watchFiles(testFiles, opts) {
// When file renamed (created / deleted) we need to update the watcher
if (newFileName) {
owners = new SafeSet().add(newFileName);
watcher.filterFile(resolve(newFileName), owners);
const resolveFileName = isAbsolute(newFileName) ? newFileName : resolve(opts.cwd, newFileName);
watcher.filterFile(resolveFileName, owners);
}

if (!newFileName && previousFileName) {
Expand Down
24 changes: 14 additions & 10 deletions test/parallel/test-runner-run-watch.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ async function testWatch(
if (runnerCwd) args.push('--cwd', runnerCwd);
if (isolation) args.push('--isolation', isolation);
const child = spawn(process.execPath,
args,
{ encoding: 'utf8', stdio: 'pipe', cwd });
args,

Check failure on line 62 in test/parallel/test-runner-run-watch.mjs

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Expected indentation of 22 spaces but found 4
{ encoding: 'utf8', stdio: 'pipe', cwd });

Check failure on line 63 in test/parallel/test-runner-run-watch.mjs

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Expected indentation of 22 spaces but found 4
let stdout = '';
let currentRun = '';
const runs = [];
Expand Down Expand Up @@ -103,10 +103,12 @@ async function testWatch(
currentRun = '';
const fileToRenamePath = tmpdir.resolve(fileToUpdate);
const newFileNamePath = tmpdir.resolve(`test-renamed-${fileToUpdate}`);
const interval = setInterval(() => renameSync(fileToRenamePath, newFileNamePath), common.platformTimeout(1000));
const interval = setInterval(() => {

Check failure on line 106 in test/parallel/test-runner-run-watch.mjs

View workflow job for this annotation

GitHub Actions / lint-js-and-md

`setInterval()` must be invoked with at least two arguments
renameSync(fileToRenamePath, newFileNamePath), common.platformTimeout(1000)

Check failure on line 107 in test/parallel/test-runner-run-watch.mjs

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Expected an assignment or function call and instead saw an expression

Check failure on line 107 in test/parallel/test-runner-run-watch.mjs

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Missing semicolon
clearInterval(interval);
});
await ran2.promise;
runs.push(currentRun);
clearInterval(interval);
child.kill();
await once(child, 'exit');

Expand Down Expand Up @@ -141,11 +143,11 @@ async function testWatch(
unlinkSync(fileToDeletePath);
} else {
ran2.resolve();
clearInterval(interval);
}
}, common.platformTimeout(1000));
await ran2.promise;
runs.push(currentRun);
clearInterval(interval);
child.kill();
await once(child, 'exit');

Expand All @@ -162,15 +164,17 @@ async function testWatch(
currentRun = '';
const newFilePath = tmpdir.resolve(fileToCreate);
const interval = setInterval(
() => writeFileSync(
newFilePath,
'module.exports = {};'
),
() => {
writeFileSync(
newFilePath,
'module.exports = {};'
);
clearInterval(interval);
},
common.platformTimeout(1000)
);
await ran2.promise;
runs.push(currentRun);
clearInterval(interval);
child.kill();
await once(child, 'exit');

Expand Down
10 changes: 6 additions & 4 deletions test/parallel/test-runner-watch-mode.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,12 @@ async function testWatch({
currentRun = '';
const fileToRenamePath = tmpdir.resolve(fileToUpdate);
const newFileNamePath = tmpdir.resolve(`test-renamed-${fileToUpdate}`);
const interval = setInterval(() => renameSync(fileToRenamePath, newFileNamePath), common.platformTimeout(1000));
const interval = setInterval(() => {
renameSync(fileToRenamePath, newFileNamePath)

Check failure on line 94 in test/parallel/test-runner-watch-mode.mjs

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Missing semicolon
clearInterval(interval);
}, common.platformTimeout(1000));
await ran2.promise;
runs.push(currentRun);
clearInterval(interval);
child.kill();
await once(child, 'exit');

Expand All @@ -117,11 +119,11 @@ async function testWatch({
unlinkSync(fileToDeletePath);
} else {
ran2.resolve();
clearInterval(interval);
}
}, common.platformTimeout(1000));
}, common.platformTimeout(2000));
await ran2.promise;
runs.push(currentRun);
clearInterval(interval);
child.kill();
await once(child, 'exit');

Expand Down

0 comments on commit a3bea98

Please sign in to comment.