1'use strict';
2
3const common = require('../common');
4
5common.skipIfInspectorDisabled();
6
7const assert = require('assert');
8
9const RESTARTS = 10;
10
11const fixtures = require('../common/fixtures');
12const startCLI = require('../common/debugger');
13
14// Using `restart` should result in only one "Connect/For help" message.
15{
16  const script = fixtures.path('debugger', 'three-lines.js');
17  const cli = startCLI(['--port=0', script]);
18
19  const listeningRegExp = /Debugger listening on/g;
20
21  async function onWaitForInitialBreak() {
22    try {
23      await cli.waitForInitialBreak();
24      await cli.waitForPrompt();
25      assert.strictEqual(cli.output.match(listeningRegExp).length, 1);
26
27      for (let i = 0; i < RESTARTS; i++) {
28        await cli.stepCommand('restart');
29        assert.strictEqual(cli.output.match(listeningRegExp).length, 1);
30      }
31    } finally {
32      await cli.quit();
33    }
34  }
35
36  onWaitForInitialBreak();
37}
38