Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: run 'abort' suite on Windows #15056

Merged
merged 1 commit into from
Sep 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 22 additions & 17 deletions test/abort/test-http-parser-consume.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const http = require('http');
const spawn = require('child_process').spawn;
const { createServer, get } = require('http');
const { spawn } = require('child_process');

if (process.argv[2] === 'child') {
const server = http.createServer(common.mustCall((req, res) => {
res.end('hello');
}));

// sub-process
const server = createServer(common.mustCall((_, res) => res.end('h')));
server.listen(0, common.mustCall((s) => {
const rr = http.get(
{ port: server.address().port },
common.mustCall((d) => {
// This bad input (0) should abort the parser and the process
rr.parser.consume(0);
server.close();
}));
const rr = get({ port: server.address().port }, common.mustCall(() => {
// This bad input (0) should abort the parser and the process
rr.parser.consume(0);
// This line should be unreachanble.
assert.fail('this should be unreachable');
}));
}));
} else {
const child = spawn(process.execPath, [__filename, 'child'],
{ stdio: 'inherit' });
// super-proces
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: process

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) => {
assert(common.nodeProcessAborted(code, signal),
'process should have aborted, but did not');
assert(stderr.includes('failed'), `stderr: ${stderr}`);
const didAbort = common.nodeProcessAborted(code, signal);
assert(didAbort, `process did not abort, code:${code} signal:${signal}`);
}));
}
2 changes: 1 addition & 1 deletion test/abort/test-process-abort-exitcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if (process.argv[2] === 'child') {
const child = spawn(process.execPath, [__filename, 'child']);
child.on('exit', common.mustCall((code, signal) => {
if (common.isWindows) {
assert.strictEqual(code, 3);
assert.strictEqual(code, 134);
assert.strictEqual(signal, null);
} else {
assert.strictEqual(code, null);
Expand Down
2 changes: 1 addition & 1 deletion vcbuild.bat
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ set enable_static=
set build_addons_napi=
set test_node_inspect=
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_build_options=
set "common_test_suites=%js_test_suites% doctool addons addons-napi&set build_addons=1&set build_addons_napi=1"
Expand Down