Skip to content

Commit ea5ecbf

Browse files
committed
test_runner: fix unix failures
1 parent e1850fb commit ea5ecbf

3 files changed

Lines changed: 22 additions & 15 deletions

File tree

lib/internal/test_runner/runner.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,8 @@ function watchFiles(testFiles, opts) {
482482
// When file renamed (created / deleted) we need to update the watcher
483483
if (newFileName) {
484484
owners = new SafeSet().add(newFileName);
485-
watcher.filterFile(resolve(newFileName), owners);
485+
const resolveFileName = isAbsolute(newFileName) ? newFileName : resolve(opts.cwd, newFileName);
486+
watcher.filterFile(resolveFileName, owners);
486487
}
487488

488489
if (!newFileName && previousFileName) {

test/parallel/test-runner-run-watch.mjs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ async function testWatch(
5959
if (runnerCwd) args.push('--cwd', runnerCwd);
6060
if (isolation) args.push('--isolation', isolation);
6161
const child = spawn(process.execPath,
62-
args,
63-
{ encoding: 'utf8', stdio: 'pipe', cwd });
62+
args,
63+
{ encoding: 'utf8', stdio: 'pipe', cwd });
6464
let stdout = '';
6565
let currentRun = '';
6666
const runs = [];
@@ -103,10 +103,12 @@ async function testWatch(
103103
currentRun = '';
104104
const fileToRenamePath = tmpdir.resolve(fileToUpdate);
105105
const newFileNamePath = tmpdir.resolve(`test-renamed-${fileToUpdate}`);
106-
const interval = setInterval(() => renameSync(fileToRenamePath, newFileNamePath), common.platformTimeout(1000));
106+
const interval = setInterval(() => {
107+
renameSync(fileToRenamePath, newFileNamePath), common.platformTimeout(1000)
108+
clearInterval(interval);
109+
});
107110
await ran2.promise;
108111
runs.push(currentRun);
109-
clearInterval(interval);
110112
child.kill();
111113
await once(child, 'exit');
112114

@@ -141,11 +143,11 @@ async function testWatch(
141143
unlinkSync(fileToDeletePath);
142144
} else {
143145
ran2.resolve();
146+
clearInterval(interval);
144147
}
145148
}, common.platformTimeout(1000));
146149
await ran2.promise;
147150
runs.push(currentRun);
148-
clearInterval(interval);
149151
child.kill();
150152
await once(child, 'exit');
151153

@@ -162,15 +164,17 @@ async function testWatch(
162164
currentRun = '';
163165
const newFilePath = tmpdir.resolve(fileToCreate);
164166
const interval = setInterval(
165-
() => writeFileSync(
166-
newFilePath,
167-
'module.exports = {};'
168-
),
167+
() => {
168+
writeFileSync(
169+
newFilePath,
170+
'module.exports = {};'
171+
);
172+
clearInterval(interval);
173+
},
169174
common.platformTimeout(1000)
170175
);
171176
await ran2.promise;
172177
runs.push(currentRun);
173-
clearInterval(interval);
174178
child.kill();
175179
await once(child, 'exit');
176180

test/parallel/test-runner-watch-mode.mjs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,12 @@ async function testWatch({
9292
currentRun = '';
9393
const fileToRenamePath = tmpdir.resolve(fileToUpdate);
9494
const newFileNamePath = tmpdir.resolve(`test-renamed-${fileToUpdate}`);
95-
const interval = setInterval(() => renameSync(fileToRenamePath, newFileNamePath), common.platformTimeout(1000));
95+
const interval = setInterval(() => {
96+
renameSync(fileToRenamePath, newFileNamePath)
97+
clearInterval(interval);
98+
}, common.platformTimeout(1000));
9699
await ran2.promise;
97100
runs.push(currentRun);
98-
clearInterval(interval);
99101
child.kill();
100102
await once(child, 'exit');
101103

@@ -119,11 +121,11 @@ async function testWatch({
119121
unlinkSync(fileToDeletePath);
120122
} else {
121123
ran2.resolve();
124+
clearInterval(interval);
122125
}
123-
}, common.platformTimeout(1000));
126+
}, common.platformTimeout(2000));
124127
await ran2.promise;
125128
runs.push(currentRun);
126-
clearInterval(interval);
127129
child.kill();
128130
await once(child, 'exit');
129131

0 commit comments

Comments
 (0)