diff options
author | Rich Trott <rtrott@gmail.com> | 2017-10-17 21:50:25 -0700 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2017-10-17 23:10:20 -0700 |
commit | 9be3d99b2b94d8a08b5a36efb06f3a6fd196805a (patch) | |
tree | 77a6cd98b9fc4e72134ddde0fbfd2606af39f91c /test/sequential/test-inspector-async-stack-traces-promise-then.js | |
parent | 978629ca1240b9f2038390c7e960f3d226daa4e8 (diff) | |
download | android-node-v8-9be3d99b2b94d8a08b5a36efb06f3a6fd196805a.tar.gz android-node-v8-9be3d99b2b94d8a08b5a36efb06f3a6fd196805a.tar.bz2 android-node-v8-9be3d99b2b94d8a08b5a36efb06f3a6fd196805a.zip |
test: fix inspector tests
The inspector tests should not be in the parallel directory as they
likely all (or certainly almost all) use static ports, so port
collisions will happen.
This moves them all to sequential. We can move them back on a
case-by-case basis. They were run sequentially when they were in the
inspector directory which they were only moved from very recently.
PR-URL: https://github.com/nodejs/node/pull/16281
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Bryan English <bryan@bryanenglish.com>
Diffstat (limited to 'test/sequential/test-inspector-async-stack-traces-promise-then.js')
-rw-r--r-- | test/sequential/test-inspector-async-stack-traces-promise-then.js | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/test/sequential/test-inspector-async-stack-traces-promise-then.js b/test/sequential/test-inspector-async-stack-traces-promise-then.js new file mode 100644 index 0000000000..a321855b5e --- /dev/null +++ b/test/sequential/test-inspector-async-stack-traces-promise-then.js @@ -0,0 +1,72 @@ +'use strict'; +const common = require('../common'); +common.skipIfInspectorDisabled(); +common.skipIf32Bits(); +common.crashOnUnhandledRejection(); +const { NodeInstance } = require('../common/inspector-helper'); +const assert = require('assert'); + +const script = `runTest(); +function runTest() { + const p = Promise.resolve(); + p.then(function break1() { // lineNumber 3 + debugger; + }); + p.then(function break2() { // lineNumber 6 + debugger; + }); +} +`; + +async function runTests() { + const instance = new NodeInstance(undefined, script); + const session = await instance.connectInspectorSession(); + await session.send([ + { 'method': 'Runtime.enable' }, + { 'method': 'Debugger.enable' }, + { 'method': 'Debugger.setAsyncCallStackDepth', + 'params': { 'maxDepth': 10 } }, + { 'method': 'Debugger.setBlackboxPatterns', + 'params': { 'patterns': [] } }, + { 'method': 'Runtime.runIfWaitingForDebugger' } + ]); + + await session.waitForBreakOnLine(0, '[eval]'); + await session.send({ 'method': 'Debugger.resume' }); + + console.error('[test] Waiting for break1'); + debuggerPausedAt(await session.waitForBreakOnLine(6, '[eval]'), + 'break1', 'runTest:5'); + + await session.send({ 'method': 'Debugger.resume' }); + + console.error('[test] Waiting for break2'); + debuggerPausedAt(await session.waitForBreakOnLine(9, '[eval]'), + 'break2', 'runTest:8'); + + await session.runToCompletion(); + assert.strictEqual(0, (await instance.expectShutdown()).exitCode); +} + +function debuggerPausedAt(msg, functionName, previousTickLocation) { + assert( + !!msg.params.asyncStackTrace, + `${Object.keys(msg.params)} contains "asyncStackTrace" property`); + + assert.strictEqual(msg.params.callFrames[0].functionName, functionName); + assert.strictEqual(msg.params.asyncStackTrace.description, 'PROMISE'); + + const frameLocations = msg.params.asyncStackTrace.callFrames.map( + (frame) => `${frame.functionName}:${frame.lineNumber}`); + assertArrayIncludes(frameLocations, previousTickLocation); +} + +function assertArrayIncludes(actual, expected) { + const expectedString = JSON.stringify(expected); + const actualString = JSON.stringify(actual); + assert( + actual.includes(expected), + `Expected ${actualString} to contain ${expectedString}.`); +} + +runTests(); |