Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 87ca9a6

Browse filesBrowse files
TrottItalo A. Casas
authored andcommitted
test: fix flaky child-process-exec-kill-throws
This is a fix for test-child-process-exec-kill-throws which is currently flaky on Windows. A bug in the test was causing the child process to fail for reasons other than those intended by the test. Instead of failing for exceeding the `maxBuffer` setting, the test was failing because it was trying to load `internal/child_process` without being passed the `expose-internals` flag. Move that module to where only the parent process (which gets the flag) loads it. Additionally, improve an assertion message to help debug problems like this. PR-URL: #12111 Fixes: #12053 Reviewed-By: Richard Lau <riclau@uk.ibm.com>
1 parent fdf76d5 commit 87ca9a6
Copy full SHA for 87ca9a6

File tree

Expand file treeCollapse file tree

2 files changed

+5
-7
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+5
-7
lines changed
Open diff view settings
Collapse file

‎test/parallel/parallel.status‎

Copy file name to clipboardExpand all lines: test/parallel/parallel.status
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ prefix parallel
77
[true] # This section applies to all platforms
88

99
[$system==win32]
10-
# See https://github.com/nodejs/node/issues/12053, this test may be exposing a
11-
# genuine bug with kill() on Windows.
12-
test-child-process-exec-kill-throws : PASS,FLAKY
1310

1411
[$system==linux]
1512

Collapse file

‎test/parallel/test-child-process-exec-kill-throws.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-child-process-exec-kill-throws.js
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
const common = require('../common');
44
const assert = require('assert');
55
const cp = require('child_process');
6-
const internalCp = require('internal/child_process');
76

87
if (process.argv[2] === 'child') {
9-
// Keep the process alive and printing to stdout.
10-
setInterval(() => { console.log('foo'); }, 1);
8+
// Since maxBuffer is 0, this should trigger an error.
9+
console.log('foo');
1110
} else {
11+
const internalCp = require('internal/child_process');
12+
1213
// Monkey patch ChildProcess#kill() to kill the process and then throw.
1314
const kill = internalCp.ChildProcess.prototype.kill;
1415

@@ -21,7 +22,7 @@ if (process.argv[2] === 'child') {
2122
const options = { maxBuffer: 0 };
2223
const child = cp.exec(cmd, options, common.mustCall((err, stdout, stderr) => {
2324
// Verify that if ChildProcess#kill() throws, the error is reported.
24-
assert(/^Error: mock error$/.test(err));
25+
assert.strictEqual(err.message, 'mock error', err);
2526
assert.strictEqual(stdout, '');
2627
assert.strictEqual(stderr, '');
2728
assert.strictEqual(child.killed, true);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.