Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRefael Ackermann <refack@gmail.com>2017-07-11 17:03:19 +0300
committerJeremiah Senkpiel <fishrock123@rocketmail.com>2017-07-19 22:02:41 +0300
commit7163e4033737cefbe75b5ad5d46e34af9e842258 (patch)
tree1222d77bda3e5391c1e66be39fa9653e8c3d1560 /benchmark
parent05707a9e012c595a00192c2831366e66dfd3236a (diff)
test: make common.PIPE process unique
* includes a tiny bit of refactoring in adjacent lines. * fixes 1 test and 1 benchmark that depended on PIPE being constant. PR-URL: https://github.com/nodejs/node/pull/14168 Fixes: https://github.com/nodejs/node/issues/14128 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/http/_chunky_http_client.js3
-rw-r--r--benchmark/http/http_server_for_chunky_client.js20
2 files changed, 11 insertions, 12 deletions
diff --git a/benchmark/http/_chunky_http_client.js b/benchmark/http/_chunky_http_client.js
index e9ba435f11c..d7c4e193c8c 100644
--- a/benchmark/http/_chunky_http_client.js
+++ b/benchmark/http/_chunky_http_client.js
@@ -3,7 +3,6 @@
// test HTTP throughput in fragmented header case
var common = require('../common.js');
var net = require('net');
-var test = require('../../test/common');
var bench = common.createBenchmark(main, {
len: [1, 4, 8, 16, 32, 64, 128],
@@ -56,7 +55,7 @@ function main(conf) {
var mult = 17;
var add = 11;
var count = 0;
- var PIPE = test.PIPE;
+ var PIPE = process.env.PIPE_NAME;
var socket = net.connect(PIPE, function() {
bench.start();
WriteHTTPHeaders(socket, 1, len);
diff --git a/benchmark/http/http_server_for_chunky_client.js b/benchmark/http/http_server_for_chunky_client.js
index 04d5a2c4a02..cc632c02ec4 100644
--- a/benchmark/http/http_server_for_chunky_client.js
+++ b/benchmark/http/http_server_for_chunky_client.js
@@ -1,24 +1,22 @@
'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 { fork } = require('child_process');
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;
+const { PIPE, tmpDir } = require('../../test/common');
+process.env.PIPE_NAME = PIPE;
try {
- fs.accessSync(test.tmpDir, fs.F_OK);
+ fs.accessSync(tmpDir, fs.F_OK);
} catch (e) {
- fs.mkdirSync(test.tmpDir);
+ fs.mkdirSync(tmpDir);
}
var server;
try {
- fs.unlinkSync(PIPE);
+ fs.unlinkSync(process.env.PIPE_NAME);
} catch (e) { /* ignore */ }
server = http.createServer(function(req, res) {
@@ -33,10 +31,12 @@ server = http.createServer(function(req, res) {
server.on('error', function(err) {
throw new Error(`server error: ${err}`);
});
-
server.listen(PIPE);
-var child = fork(pep, process.argv.slice(2));
+const child = fork(
+ `${__dirname}/_chunky_http_client.js`,
+ process.argv.slice(2)
+);
child.on('message', common.sendResult);
child.on('close', function(code) {
server.close();