Skip to content
Permalink
Browse files

test: add fs.watchFile() + worker.terminate() test

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 BethGriggs committed Jun 6, 2018
1 parent 83c2a14 commit 6a5d42ef9ceb430cfcf0cfe991033c579bd17383
Showing with 18 additions and 0 deletions.
  1. +18 −0 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 6a5d42e

Please sign in to comment.
You can’t perform that action at this time.