From 7551943bfaa91e763f40831eb6044a010363e51b Mon Sep 17 00:00:00 2001 From: cjihrig Date: Mon, 19 Feb 2018 14:07:11 -0500 Subject: [PATCH] allow tests using lsof to pass on ENOENT The tests are currently skipped on Windows, but there are no guarantees that lsof exists on the system executing the tests. Refs: https://github.com/nodejs/citgm/pull/436 --- test/core.js | 8 ++++++++ test/transmit.js | 15 +++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/test/core.js b/test/core.js index dfc4c5c1b..76f6bb9d1 100755 --- a/test/core.js +++ b/test/core.js @@ -12,6 +12,7 @@ const Path = require('path'); const TLS = require('tls'); const Boom = require('boom'); +const Bounce = require('bounce'); const Code = require('code'); const Handlebars = require('handlebars'); const Hapi = require('..'); @@ -1489,6 +1490,13 @@ describe('Core', () => { const cmd = ChildProcess.spawn('lsof', ['-p', process.pid]); let lsof = ''; + + cmd.on('error', (err) => { + + // Allow the test to pass on platforms with no lsof + Bounce.ignore(err, { errno: 'ENOENT' }); + }); + cmd.stdout.on('data', (buffer) => { lsof += buffer.toString(); diff --git a/test/transmit.js b/test/transmit.js index cafe21b20..5a8a65030 100755 --- a/test/transmit.js +++ b/test/transmit.js @@ -10,6 +10,7 @@ const Stream = require('stream'); const Zlib = require('zlib'); const Boom = require('boom'); +const Bounce = require('bounce'); const Code = require('code'); const Hapi = require('..'); const Hoek = require('hoek'); @@ -78,6 +79,13 @@ describe('transmission', () => { const cmd = ChildProcess.spawn('lsof', ['-p', process.pid]); let lsof = ''; + + cmd.on('error', (err) => { + + // Allow the test to pass on platforms with no lsof + Bounce.ignore(err, { errno: 'ENOENT' }); + }); + cmd.stdout.on('data', (buffer) => { lsof += buffer.toString(); @@ -112,6 +120,13 @@ describe('transmission', () => { const cmd = ChildProcess.spawn('lsof', ['-p', process.pid]); let lsof = ''; + + cmd.on('error', (err) => { + + // Allow the test to pass on platforms with no lsof + Bounce.ignore(err, { errno: 'ENOENT' }); + }); + cmd.stdout.on('data', (buffer) => { lsof += buffer.toString();