mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
3fa5d80eda
Previously when there is an error in the chunky client of the http benchmark, the server would not check the exit code and thus produce invalid results. PR-URL: https://github.com/nodejs/node/pull/12916 Fixes: https://github.com/nodejs/node/issues/12903 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
45 lines
965 B
JavaScript
45 lines
965 B
JavaScript
'use strict';
|
|
|
|
var assert = require('assert');
|
|
var path = require('path');
|
|
var http = require('http');
|
|
var fs = require('fs');
|
|
var fork = require('child_process').fork;
|
|
var common = require('../common.js');
|
|
var test = require('../../test/common');
|
|
var pep = `${path.dirname(process.argv[1])}/_chunky_http_client.js`;
|
|
var PIPE = test.PIPE;
|
|
|
|
try {
|
|
fs.accessSync(test.tmpDir, fs.F_OK);
|
|
} catch (e) {
|
|
fs.mkdirSync(test.tmpDir);
|
|
}
|
|
|
|
var server;
|
|
try {
|
|
fs.unlinkSync(PIPE);
|
|
} catch (e) { /* ignore */ }
|
|
|
|
server = http.createServer(function(req, res) {
|
|
var headers = {
|
|
'content-type': 'text/plain',
|
|
'content-length': '2'
|
|
};
|
|
res.writeHead(200, headers);
|
|
res.end('ok');
|
|
});
|
|
|
|
server.on('error', function(err) {
|
|
throw new Error(`server error: ${err}`);
|
|
});
|
|
|
|
server.listen(PIPE);
|
|
|
|
var child = fork(pep, process.argv.slice(2));
|
|
child.on('message', common.sendResult);
|
|
child.on('close', function(code) {
|
|
server.close();
|
|
assert.strictEqual(code, 0);
|
|
});
|