Skip to content

Commit e014983

Browse files
refackjasnell
authored andcommitted
test,process: run 'abort' suite on Windows
PR-URL: #15056 Fixes: #14012 Refs: #14013 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 535f8d5 commit e014983

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed

test/abort/test-abort-uncaught-exception.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function run(flags, signals) {
2121
child.on('exit', common.mustCall(function(code, sig) {
2222
if (common.isWindows) {
2323
if (signals)
24-
assert.strictEqual(code, 3);
24+
assert.strictEqual(code, 0xC0000005);
2525
else
2626
assert.strictEqual(code, 1);
2727
} else {
+22-17
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,33 @@
11
'use strict';
22
const common = require('../common');
33
const assert = require('assert');
4-
const http = require('http');
5-
const spawn = require('child_process').spawn;
4+
const { createServer, get } = require('http');
5+
const { spawn } = require('child_process');
66

77
if (process.argv[2] === 'child') {
8-
const server = http.createServer(common.mustCall((req, res) => {
9-
res.end('hello');
10-
}));
11-
8+
// sub-process
9+
const server = createServer(common.mustCall((_, res) => res.end('h')));
1210
server.listen(0, common.mustCall((s) => {
13-
const rr = http.get(
14-
{ port: server.address().port },
15-
common.mustCall((d) => {
16-
// This bad input (0) should abort the parser and the process
17-
rr.parser.consume(0);
18-
server.close();
19-
}));
11+
const rr = get({ port: server.address().port }, common.mustCall(() => {
12+
// This bad input (0) should abort the parser and the process
13+
rr.parser.consume(0);
14+
// This line should be unreachanble.
15+
assert.fail('this should be unreachable');
16+
}));
2017
}));
2118
} else {
22-
const child = spawn(process.execPath, [__filename, 'child'],
23-
{ stdio: 'inherit' });
19+
// super-proces
20+
const child = spawn(process.execPath, [__filename, 'child']);
21+
child.stdout.on('data', common.mustNotCall());
22+
23+
let stderr = '';
24+
child.stderr.on('data', common.mustCallAtLeast((data) => {
25+
assert(Buffer.isBuffer(data));
26+
stderr += data.toString('utf8');
27+
}, 1));
2428
child.on('exit', common.mustCall((code, signal) => {
25-
assert(common.nodeProcessAborted(code, signal),
26-
'process should have aborted, but did not');
29+
assert(stderr.includes('failed'), `stderr: ${stderr}`);
30+
const didAbort = common.nodeProcessAborted(code, signal);
31+
assert(didAbort, `process did not abort, code:${code} signal:${signal}`);
2732
}));
2833
}

vcbuild.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ set enable_static=
4444
set build_addons_napi=
4545
set test_node_inspect=
4646
set test_check_deopts=
47-
set js_test_suites=async-hooks inspector known_issues message parallel sequential
47+
set js_test_suites=abort async-hooks inspector known_issues message parallel sequential
4848
set v8_test_options=
4949
set v8_build_options=
5050
set "common_test_suites=%js_test_suites% doctool addons addons-napi&set build_addons=1&set build_addons_napi=1"

0 commit comments

Comments
 (0)