GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: deflake watch mode worker test · nodejs/node@2004e25

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/sequential
    • test-watch-mode-worker.mjs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/sequential/test-watch-mode-worker.mjs‎

Copy file name to clipboardExpand all lines: test/sequential/test-watch-mode-worker.mjs
+16-5Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ import path from 'node:path';
55
import { execPath } from 'node:process';
66
import { describe, it } from 'node:test';
77
import { spawn } from 'node:child_process';
8-
import { writeFileSync, readFileSync } from 'node:fs';
8+
import { appendFileSync, mkdirSync, writeFileSync } from 'node:fs';
99
import { inspect } from 'node:util';
1010
import { pathToFileURL } from 'node:url';
1111
import { createInterface } from 'node:readline';
1212

1313
if (common.isIBMi)
1414
common.skip('IBMi does not support `fs.watch()`');
1515

16-
function restart(file, content = readFileSync(file)) {
17-
writeFileSync(file, content);
18-
const timer = setInterval(() => writeFileSync(file, content), common.platformTimeout(250));
16+
function restart(file) {
17+
appendFileSync(file, '\n');
18+
const timer = setInterval(() => appendFileSync(file, '\n'), common.platformTimeout(250));
1919
return () => clearInterval(timer);
2020
}
2121

@@ -26,6 +26,12 @@ function createTmpFile(content = 'console.log(\'running\');', ext = '.js', basen
2626
return file;
2727
}
2828

29+
function createTmpDir() {
30+
const dir = path.join(tmpdir.path, `${tmpFiles++}`);
31+
mkdirSync(dir);
32+
return dir;
33+
}
34+
2935
async function runWriteSucceed({
3036
file,
3137
watchedFile,
@@ -78,10 +84,10 @@ async function runWriteSucceed({
7884
}
7985

8086
tmpdir.refresh();
81-
const dir = tmpdir.path;
8287

8388
describe('watch mode', { concurrency: !process.env.TEST_PARALLEL, timeout: 60_000 }, () => {
8489
it('should watch changes to worker - cjs', async () => {
90+
const dir = createTmpDir();
8591
const worker = path.join(dir, 'worker.js');
8692

8793
writeFileSync(worker, `
@@ -109,6 +115,7 @@ const w = new Worker(${JSON.stringify(worker)});
109115
});
110116

111117
it('should watch changes to worker dependencies - cjs', async () => {
118+
const dir = createTmpDir();
112119
const dep = path.join(dir, 'dep.js');
113120
const worker = path.join(dir, 'worker.js');
114121

@@ -142,6 +149,7 @@ const w = new Worker(${JSON.stringify(worker)});
142149
});
143150

144151
it('should watch changes to nested worker dependencies - cjs', async () => {
152+
const dir = createTmpDir();
145153
const subDep = path.join(dir, 'sub-dep.js');
146154
const dep = path.join(dir, 'dep.js');
147155
const worker = path.join(dir, 'worker.js');
@@ -181,6 +189,7 @@ const w = new Worker(${JSON.stringify(worker)});
181189
});
182190

183191
it('should watch changes to worker - esm', async () => {
192+
const dir = createTmpDir();
184193
const worker = path.join(dir, 'worker.mjs');
185194

186195
writeFileSync(worker, `
@@ -208,6 +217,7 @@ new Worker(new URL(${JSON.stringify(pathToFileURL(worker))}));
208217
});
209218

210219
it('should watch changes to worker dependencies - esm', async () => {
220+
const dir = createTmpDir();
211221
const dep = path.join(dir, 'dep.mjs');
212222
const worker = path.join(dir, 'worker.mjs');
213223

@@ -241,6 +251,7 @@ new Worker(new URL(${JSON.stringify(pathToFileURL(worker))}));
241251
});
242252

243253
it('should watch changes to nested worker dependencies - esm', async () => {
254+
const dir = createTmpDir();
244255
const subDep = path.join(dir, 'sub-dep.mjs');
245256
const dep = path.join(dir, 'dep.mjs');
246257
const worker = path.join(dir, 'worker.mjs');

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.