Skip to content
Permalink
Browse files

test,worker: refactor test-worker-cleanup-handles

* alphabetize require() statements for built-in modules by module name
* remove unused function argument `code` in callback
* replace common.expectsError() with assert.throws()
* remove unneeded line-wrap

PR-URL: #25401
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information...
Trott authored and addaleax committed Jan 8, 2019
1 parent 82fc9a8 commit a6df7278d89b3f10aa3bbb101523566a70f7f866
Showing with 5 additions and 5 deletions.
  1. +5 −5 test/parallel/test-worker-cleanup-handles.js
@@ -1,9 +1,10 @@
'use strict';
const common = require('../common');

const assert = require('assert');
const { Worker, isMainThread, parentPort } = require('worker_threads');
const { Server } = require('net');
const fs = require('fs');
const { Server } = require('net');
const { Worker, isMainThread, parentPort } = require('worker_threads');

if (isMainThread) {
const w = new Worker(__filename);
@@ -12,14 +13,13 @@ if (isMainThread) {
assert.strictEqual(typeof fd_, 'number');
fd = fd_;
}));
w.on('exit', common.mustCall((code) => {
w.on('exit', common.mustCall(() => {
if (fd === -1) {
// This happens when server sockets don’t have file descriptors,
// i.e. on Windows.
return;
}
common.expectsError(() => fs.fstatSync(fd),
{ code: 'EBADF' });
assert.throws(() => fs.fstatSync(fd), { code: 'EBADF' });
}));
} else {
const server = new Server();

0 comments on commit a6df727

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