mirror of
https://github.com/nodejs/node.git
synced 2025-05-09 07:27:32 +00:00

This is first in a hoped-for series of moves away from a monolithic common.js that is loaded for every test and towards a more modular approach. (In the end, common.js will hopefully contain checks for variables leaking into the global space and perhaps some of the more ubiquitous functions like common.mustCall().) Move the WPT testing code to its own module. PR-URL: https://github.com/nodejs/node/pull/12736 Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
43 lines
898 B
JavaScript
43 lines
898 B
JavaScript
'use strict';
|
|
|
|
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() {
|
|
server.close();
|
|
});
|