• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3
4common.skipIfInspectorDisabled();
5
6const fixtures = require('../common/fixtures');
7const startCLI = require('../common/debugger');
8
9const assert = require('assert');
10const { spawn } = require('child_process');
11
12
13function 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    }
32    assert.ifError(error);
33  }
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   \+\+x;/,
48        'marks the 3rd line');
49    })
50    .then(() => cleanup())
51    .then(null, cleanup);
52}
53