test: add check for wrk to test-keep-alive

test/pummel/test-keep-alive.js requires `wrk` to be installed. Check if
it is, and skip the test if it isn't.

This is yet another step in preparation for running pummel tests in CI
daily.

PR-URL: https://github.com/nodejs/node/pull/25516
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Rich Trott 2019-01-15 07:27:55 -08:00
parent 098c2cc348
commit 5fdd554730

View File

@ -23,11 +23,13 @@
// This test requires the program 'wrk'.
const common = require('../common');
if (common.isWindows)
common.skip('no `wrk` on windows');
const child_process = require('child_process');
const result = child_process.spawnSync('wrk', ['-h']);
if (result.error && result.error.code === 'ENOENT')
common.skip('test requires `wrk` to be installed first');
const assert = require('assert');
const spawn = require('child_process').spawn;
const http = require('http');
const url = require('url');
@ -60,7 +62,7 @@ const runAb = (opts, callback) => {
args.push(url.format({ hostname: '127.0.0.1',
port: opts.port, protocol: 'http' }));
const child = spawn('wrk', args);
const child = child_process.spawn('wrk', args);
child.stderr.pipe(process.stderr);
child.stdout.setEncoding('utf8');