|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +// Refs: https://github.com/nodejs/node/issues/39272 |
| 4 | + |
| 5 | +const common = require('../common'); |
| 6 | + |
| 7 | +const assert = require('assert'); |
| 8 | + |
| 9 | +// When this is moved out of known_issues, this skip can be removed. |
| 10 | +if (common.isOSX) { |
| 11 | + assert.fail('does not fail reliably on macOS in CI'); |
| 12 | +} |
| 13 | + |
| 14 | +// When this is moved out of known_issues, this can be removed and replaced with |
| 15 | +// the commented-out use of common.skipIfInspectorDisabled() below. |
| 16 | +if (!process.features.inspector) { |
| 17 | + assert.fail('Known issues test should fail, so if the inspector is disabled'); |
| 18 | +} |
| 19 | + |
| 20 | +// Will need to uncomment this when moved out of known_issues. |
| 21 | +// common.skipIfInspectorDisabled(); |
| 22 | + |
| 23 | +// This can be reduced to 2 or even 1 (and the loop removed) once the debugger |
| 24 | +// is fixed. It's set higher to make sure that the error is tripped reliably |
| 25 | +// in CI. On most systems, the error will be tripped on the first test, but |
| 26 | +// on a few platforms in CI, it needs to be many times. |
| 27 | +const RESTARTS = 16; |
| 28 | + |
| 29 | +const fixtures = require('../common/fixtures'); |
| 30 | +const startCLI = require('../common/debugger'); |
| 31 | + |
| 32 | +// Using `restart` should result in only one "Connect/For help" message. |
| 33 | +{ |
| 34 | + const script = fixtures.path('debugger', 'three-lines.js'); |
| 35 | + const cli = startCLI([script]); |
| 36 | + |
| 37 | + function onFatal(error) { |
| 38 | + cli.quit(); |
| 39 | + throw error; |
| 40 | + } |
| 41 | + |
| 42 | + const listeningRegExp = /Debugger listening on/g; |
| 43 | + |
| 44 | + cli.waitForInitialBreak() |
| 45 | + .then(() => cli.waitForPrompt()) |
| 46 | + .then(() => { |
| 47 | + assert.strictEqual(cli.output.match(listeningRegExp).length, 1); |
| 48 | + }) |
| 49 | + .then(async () => { |
| 50 | + for (let i = 0; i < RESTARTS; i++) { |
| 51 | + await cli.stepCommand('restart'); |
| 52 | + assert.strictEqual(cli.output.match(listeningRegExp).length, 1); |
| 53 | + } |
| 54 | + }) |
| 55 | + .then(() => cli.quit()) |
| 56 | + .then(null, onFatal); |
| 57 | +} |
0 commit comments