test: reduce runtime
This refactors some tests to reduce the runtime of those. PR-URL: https://github.com/nodejs/node/pull/20688 Refs: https://github.com/nodejs/node/issues/20128 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Yang Guo <yangguo@chromium.org>
This commit is contained in:
parent
c041a2ee5b
commit
352ae23974
@ -7,15 +7,17 @@ if (process.argv[2] === 'async') {
|
|||||||
fn();
|
fn();
|
||||||
throw new Error();
|
throw new Error();
|
||||||
}
|
}
|
||||||
(async function() { await fn(); })();
|
return (async function() { await fn(); })();
|
||||||
// While the above should error, just in case it doesn't the script shouldn't
|
|
||||||
// fork itself indefinitely so return early.
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { spawnSync } = require('child_process');
|
const { spawnSync } = require('child_process');
|
||||||
|
|
||||||
const ret = spawnSync(process.execPath, [__filename, 'async']);
|
const ret = spawnSync(
|
||||||
|
process.execPath,
|
||||||
|
['--stack_size=50', __filename, 'async']
|
||||||
|
);
|
||||||
assert.strictEqual(ret.status, 0);
|
assert.strictEqual(ret.status, 0);
|
||||||
assert.ok(!/async.*hook/i.test(ret.stderr.toString('utf8', 0, 1024)));
|
const stderr = ret.stderr.toString('utf8', 0, 2048);
|
||||||
|
assert.ok(!/async.*hook/i.test(stderr));
|
||||||
|
assert.ok(stderr.includes('UnhandledPromiseRejectionWarning: Error'), stderr);
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
|
||||||
const cp = require('child_process');
|
|
||||||
const stdoutData = 'foo';
|
const stdoutData = 'foo';
|
||||||
const stderrData = 'bar';
|
const stderrData = 'bar';
|
||||||
const expectedStdout = `${stdoutData}\n`;
|
|
||||||
const expectedStderr = `${stderrData}\n`;
|
|
||||||
|
|
||||||
if (process.argv[2] === 'child') {
|
if (process.argv[2] === 'child') {
|
||||||
// The following console calls are part of the test.
|
// The following console calls are part of the test.
|
||||||
console.log(stdoutData);
|
console.log(stdoutData);
|
||||||
console.error(stderrData);
|
console.error(stderrData);
|
||||||
} else {
|
} else {
|
||||||
|
const assert = require('assert');
|
||||||
|
const cp = require('child_process');
|
||||||
|
const expectedStdout = `${stdoutData}\n`;
|
||||||
|
const expectedStderr = `${stderrData}\n`;
|
||||||
function run(options, callback) {
|
function run(options, callback) {
|
||||||
const cmd = `"${process.execPath}" "${__filename}" child`;
|
const cmd = `"${process.execPath}" "${__filename}" child`;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user