Skip to content

Commit 68c933c

Browse files
committed
test: fix flakyness with yes.exe
PR-URL: nodejs#12821 Fixes: nodejs#12817 Refs: nodejs#12658 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 4703824 commit 68c933c

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

benchmark/child_process/child-process-read.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
'use strict';
22
const common = require('../common.js');
3+
4+
// This benchmark uses `yes` to a create noisy child_processes with varying
5+
// output message lengths, and tries to read 8GB of output
6+
37
const os = require('os');
8+
const child_process = require('child_process');
49

510
var messagesLength = [64, 256, 1024, 4096];
611
// Windows does not support that long arguments
@@ -12,7 +17,6 @@ const bench = common.createBenchmark(main, {
1217
dur: [5]
1318
});
1419

15-
const spawn = require('child_process').spawn;
1620
function main(conf) {
1721
bench.start();
1822

@@ -21,15 +25,20 @@ function main(conf) {
2125

2226
const msg = `"${'.'.repeat(len)}"`;
2327
const options = { 'stdio': ['ignore', 'pipe', 'ignore'] };
24-
const child = spawn('yes', [msg], options);
28+
const child = child_process.spawn('yes', [msg], options);
2529

2630
var bytes = 0;
2731
child.stdout.on('data', function(msg) {
2832
bytes += msg.length;
2933
});
3034

3135
setTimeout(function() {
32-
child.kill();
36+
if (process.platform === 'win32') {
37+
// Sometimes there's a yes.exe process left hanging around on Windows...
38+
child_process.execSync(`taskkill /f /t /pid ${child.pid}`);
39+
} else {
40+
child.kill();
41+
}
3342
const gbits = (bytes * 8) / (1024 * 1024 * 1024);
3443
bench.end(gbits);
3544
}, dur * 1000);

0 commit comments

Comments
 (0)