Skip to content

Commit

Permalink
test: reduce runtime
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
BridgeAR committed May 21, 2018
1 parent c041a2e commit 352ae23
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
14 changes: 8 additions & 6 deletions test/parallel/test-async-wrap-pop-id-during-load.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ if (process.argv[2] === 'async') {
fn();
throw new Error();
}
(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;
return (async function() { await fn(); })();
}

const assert = require('assert');
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.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);
8 changes: 4 additions & 4 deletions test/parallel/test-child-process-exec-encoding.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
const stdoutData = 'foo';
const stderrData = 'bar';
const expectedStdout = `${stdoutData}\n`;
const expectedStderr = `${stderrData}\n`;

if (process.argv[2] === 'child') {
// The following console calls are part of the test.
console.log(stdoutData);
console.error(stderrData);
} else {
const assert = require('assert');
const cp = require('child_process');
const expectedStdout = `${stdoutData}\n`;
const expectedStderr = `${stderrData}\n`;
function run(options, callback) {
const cmd = `"${process.execPath}" "${__filename}" child`;

Expand Down

0 comments on commit 352ae23

Please sign in to comment.