node/test/async-hooks/test-force-checks-flag.js
Andreas Madsen 7c079d1261
async_hooks: skip runtime checks when disabled
PR-URL: https://github.com/nodejs/node/pull/15454
Ref: https://github.com/nodejs/node/pull/14387
Ref: https://github.com/nodejs/node/pull/14722
Ref: https://github.com/nodejs/node/issues/14717
Ref: https://github.com/nodejs/node/issues/15448
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2017-10-19 12:45:21 +02:00

26 lines
789 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const async_hooks = require('async_hooks');
const spawnSync = require('child_process').spawnSync;
// disabling this way will just decrement the kCheck counter. It won't actually
// disable the checks, because they were enabled with the flag.
common.revert_force_async_hooks_checks();
switch (process.argv[2]) {
case 'test_invalid_async_id':
async_hooks.emitInit();
return;
}
assert.ok(!process.argv[2]);
const c1 = spawnSync(process.execPath, [
'--force-async-hooks-checks', __filename, 'test_invalid_async_id'
]);
assert.strictEqual(
c1.stderr.toString().split(/[\r\n]+/g)[0],
'RangeError [ERR_INVALID_ASYNC_ID]: Invalid asyncId value: undefined');
assert.strictEqual(c1.status, 1);