Skip to content

Commit 3e7741c

Browse files
BridgeARMylesBorins
authored andcommitted
test: reduce runtime
This refactors some tests to reduce the runtime of those. PR-URL: #20688 Refs: #20128 Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Yang Guo <[email protected]>
1 parent c8c9211 commit 3e7741c

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

test/parallel/test-async-wrap-pop-id-during-load.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@ if (process.argv[2] === 'async') {
77
fn();
88
throw new Error();
99
}
10-
(async function() { await fn(); })();
11-
// While the above should error, just in case it doesn't the script shouldn't
12-
// fork itself indefinitely so return early.
13-
return;
10+
return (async function() { await fn(); })();
1411
}
1512

1613
const assert = require('assert');
1714
const { spawnSync } = require('child_process');
1815

19-
const ret = spawnSync(process.execPath, [__filename, 'async']);
16+
const ret = spawnSync(
17+
process.execPath,
18+
['--stack_size=50', __filename, 'async']
19+
);
2020
assert.strictEqual(ret.status, 0);
21-
assert.ok(!/async.*hook/i.test(ret.stderr.toString('utf8', 0, 1024)));
21+
const stderr = ret.stderr.toString('utf8', 0, 2048);
22+
assert.ok(!/async.*hook/i.test(stderr));
23+
assert.ok(stderr.includes('UnhandledPromiseRejectionWarning: Error'), stderr);

test/parallel/test-child-process-exec-encoding.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
'use strict';
22
const common = require('../common');
3-
const assert = require('assert');
4-
const cp = require('child_process');
53
const stdoutData = 'foo';
64
const stderrData = 'bar';
7-
const expectedStdout = `${stdoutData}\n`;
8-
const expectedStderr = `${stderrData}\n`;
95

106
if (process.argv[2] === 'child') {
117
// The following console calls are part of the test.
128
console.log(stdoutData);
139
console.error(stderrData);
1410
} else {
11+
const assert = require('assert');
12+
const cp = require('child_process');
13+
const expectedStdout = `${stdoutData}\n`;
14+
const expectedStderr = `${stderrData}\n`;
1515
function run(options, callback) {
1616
const cmd = `"${process.execPath}" "${__filename}" child`;
1717

0 commit comments

Comments
 (0)