| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,44 +9,27 @@ const startCLI = require('../common/debugger'); | |||
| 9 | 9 | const assert = require('assert'); | |
| 10 | 10 | const { spawn } = require('child_process'); | |
| 11 | 11 | ||
| 12 | - | ||
| 13 | - function launchTarget(...args) { | ||
| 14 | - const childProc = spawn(process.execPath, args); | ||
| 15 | - return Promise.resolve(childProc); | ||
| 16 | - } | ||
| 17 | - | ||
| 18 | - { | ||
| 19 | - const script = fixtures.path('debugger', 'alive.js'); | ||
| 20 | - let cli = null; | ||
| 21 | - let target = null; | ||
| 22 | - | ||
| 23 | - function cleanup(error) { | ||
| 24 | - if (cli) { | ||
| 25 | - cli.quit(); | ||
| 26 | - cli = null; | ||
| 27 | - } | ||
| 28 | - if (target) { | ||
| 29 | - target.kill(); | ||
| 30 | - target = null; | ||
| 31 | - } | ||
| 12 | + const script = fixtures.path('debugger', 'alive.js'); | ||
| 13 | + | ||
| 14 | + const runTest = async () => { | ||
| 15 | + const target = spawn(process.execPath, [script]); | ||
| 16 | + const cli = startCLI(['-p', `${target.pid}`]); | ||
| 17 | + | ||
| 18 | + try { | ||
| 19 | + await cli.waitForPrompt(); | ||
| 20 | + await cli.command('sb("alive.js", 3)'); | ||
| 21 | + await cli.waitFor(/break/); | ||
| 22 | + await cli.waitForPrompt(); | ||
| 23 | + assert.match( | ||
| 24 | + cli.output, | ||
| 25 | + /> 3 {3}\+\+x;/, | ||
| 26 | + 'marks the 3rd line'); | ||
| 27 | + } catch (error) { | ||
| 32 | 28 | assert.ifError(error); | |
| 29 | + } finally { | ||
| 30 | + await cli.quit(); | ||
| 31 | + target.kill(); | ||
| 33 | 32 | } | |
| 33 | + }; | ||
| 34 | 34 | ||
| 35 | - return launchTarget(script) | ||
| 36 | - .then((childProc) => { | ||
| 37 | - target = childProc; | ||
| 38 | - cli = startCLI(['-p', `${target.pid}`]); | ||
| 39 | - return cli.waitForPrompt(); | ||
| 40 | - }) | ||
| 41 | - .then(() => cli.command('sb("alive.js", 3)')) | ||
| 42 | - .then(() => cli.waitFor(/break/)) | ||
| 43 | - .then(() => cli.waitForPrompt()) | ||
| 44 | - .then(() => { | ||
| 45 | - assert.match( | ||
| 46 | - cli.output, | ||
| 47 | - /> 3 {3}\+\+x;/, | ||
| 48 | - 'marks the 3rd line'); | ||
| 49 | - }) | ||
| 50 | - .then(() => cleanup()) | ||
| 51 | - .then(null, cleanup); | ||
| 52 | - } | ||
| 35 | + runTest().then(common.mustCall()); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments