test,process: run 'abort' suite on Windows
PR-URL: https://github.com/nodejs/node/pull/15056 Fixes: https://github.com/nodejs/node/issues/14012 Refs: https://github.com/nodejs/node/pull/14013 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
parent
98d8db3299
commit
233d1e276a
@ -1,28 +1,33 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const http = require('http');
|
const { createServer, get } = require('http');
|
||||||
const spawn = require('child_process').spawn;
|
const { spawn } = require('child_process');
|
||||||
|
|
||||||
if (process.argv[2] === 'child') {
|
if (process.argv[2] === 'child') {
|
||||||
const server = http.createServer(common.mustCall((req, res) => {
|
// sub-process
|
||||||
res.end('hello');
|
const server = createServer(common.mustCall((_, res) => res.end('h')));
|
||||||
}));
|
|
||||||
|
|
||||||
server.listen(0, common.mustCall((s) => {
|
server.listen(0, common.mustCall((s) => {
|
||||||
const rr = http.get(
|
const rr = get({ port: server.address().port }, common.mustCall(() => {
|
||||||
{ port: server.address().port },
|
|
||||||
common.mustCall((d) => {
|
|
||||||
// This bad input (0) should abort the parser and the process
|
// This bad input (0) should abort the parser and the process
|
||||||
rr.parser.consume(0);
|
rr.parser.consume(0);
|
||||||
server.close();
|
// This line should be unreachanble.
|
||||||
|
assert.fail('this should be unreachable');
|
||||||
}));
|
}));
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
const child = spawn(process.execPath, [__filename, 'child'],
|
// super-proces
|
||||||
{ stdio: 'inherit' });
|
const child = spawn(process.execPath, [__filename, 'child']);
|
||||||
|
child.stdout.on('data', common.mustNotCall());
|
||||||
|
|
||||||
|
let stderr = '';
|
||||||
|
child.stderr.on('data', common.mustCallAtLeast((data) => {
|
||||||
|
assert(Buffer.isBuffer(data));
|
||||||
|
stderr += data.toString('utf8');
|
||||||
|
}, 1));
|
||||||
child.on('exit', common.mustCall((code, signal) => {
|
child.on('exit', common.mustCall((code, signal) => {
|
||||||
assert(common.nodeProcessAborted(code, signal),
|
assert(stderr.includes('failed'), `stderr: ${stderr}`);
|
||||||
'process should have aborted, but did not');
|
const didAbort = common.nodeProcessAborted(code, signal);
|
||||||
|
assert(didAbort, `process did not abort, code:${code} signal:${signal}`);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ if (process.argv[2] === 'child') {
|
|||||||
const child = spawn(process.execPath, [__filename, 'child']);
|
const child = spawn(process.execPath, [__filename, 'child']);
|
||||||
child.on('exit', common.mustCall((code, signal) => {
|
child.on('exit', common.mustCall((code, signal) => {
|
||||||
if (common.isWindows) {
|
if (common.isWindows) {
|
||||||
assert.strictEqual(code, 3);
|
assert.strictEqual(code, 134);
|
||||||
assert.strictEqual(signal, null);
|
assert.strictEqual(signal, null);
|
||||||
} else {
|
} else {
|
||||||
assert.strictEqual(code, null);
|
assert.strictEqual(code, null);
|
||||||
|
@ -44,7 +44,7 @@ set enable_static=
|
|||||||
set build_addons_napi=
|
set build_addons_napi=
|
||||||
set test_node_inspect=
|
set test_node_inspect=
|
||||||
set test_check_deopts=
|
set test_check_deopts=
|
||||||
set js_test_suites=async-hooks inspector known_issues message parallel sequential
|
set js_test_suites=abort async-hooks inspector known_issues message parallel sequential
|
||||||
set v8_test_options=
|
set v8_test_options=
|
||||||
set v8_build_options=
|
set v8_build_options=
|
||||||
set "common_test_suites=%js_test_suites% doctool addons addons-napi&set build_addons=1&set build_addons_napi=1"
|
set "common_test_suites=%js_test_suites% doctool addons addons-napi&set build_addons=1&set build_addons_napi=1"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user