Skip to content

Commit

Permalink
test: add fs.watchFile() + worker.terminate() test
Browse files Browse the repository at this point in the history
Refs: #21093 (comment)

PR-URL: #21179
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
addaleax authored and MylesBorins committed May 16, 2019
1 parent eef2deb commit ec02117
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/parallel/test-worker-fs-stat-watcher.js
@@ -0,0 +1,18 @@
// Flags: --experimental-worker
'use strict';
const common = require('../common');
const { Worker, parentPort } = require('worker_threads');
const fs = require('fs');

// Checks that terminating Workers does not crash the process if fs.watchFile()
// has active handles.

// Do not use isMainThread so that this test itself can be run inside a Worker.
if (!process.env.HAS_STARTED_WORKER) {
process.env.HAS_STARTED_WORKER = 1;
const worker = new Worker(__filename);
worker.on('message', common.mustCall(() => worker.terminate()));
} else {
fs.watchFile(__filename, () => {});
parentPort.postMessage('running');
}

0 comments on commit ec02117

Please sign in to comment.