Skip to content
This repository was archived by the owner on Feb 1, 2022. It is now read-only.

Commit 22bf349

Browse files
author
Jan Krems
committed
test: Adjust for v8 5.7
1 parent 2c224c5 commit 22bf349

File tree

6 files changed

+32
-20
lines changed

6 files changed

+32
-20
lines changed

test/cli/exceptions.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ test('break on (uncaught) exceptions', (t) => {
2121
})
2222
// making sure it will die by default:
2323
.then(() => cli.command('c'))
24-
.then(() => cli.waitFor(/disconnect/))
24+
// TODO: Remove FATAL ERROR once node doesn't show a FATAL ERROR anymore
25+
.then(() => cli.waitFor(/disconnect|FATAL ERROR/))
2526

2627
// Next run: With `breakOnException` it pauses in both places
2728
.then(() => cli.stepCommand('r'))
@@ -56,7 +57,8 @@ test('break on (uncaught) exceptions', (t) => {
5657
t.match(cli.output, ` in ${script}:1`);
5758
})
5859
.then(() => cli.command('c'))
59-
.then(() => cli.waitFor(/disconnect/))
60+
// TODO: Remove FATAL ERROR once node doesn't show a FATAL ERROR anymore
61+
.then(() => cli.waitFor(/disconnect|FATAL ERROR/))
6062

6163
.then(() => cli.quit())
6264
.then(null, onFatal);

test/cli/launch.test.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,14 @@ const { test } = require('tap');
55

66
const startCLI = require('./start-cli');
77

8-
test('examples/empty.js', (t) => {
9-
const script = Path.join('examples', 'empty.js');
8+
test('examples/three-lines.js', (t) => {
9+
const script = Path.join('examples', 'three-lines.js');
1010
const cli = startCLI([script]);
1111

1212
return cli.waitForInitialBreak()
1313
.then(() => cli.waitForPrompt())
1414
.then(() => {
1515
t.match(cli.output, 'debug>', 'prints a prompt');
16-
t.match(
17-
cli.output,
18-
'< Debugger listening on port 9229',
19-
'forwards child output');
2016
})
2117
.then(() => cli.command('["hello", "world"].join(" ")'))
2218
.then(() => {
@@ -72,6 +68,7 @@ test('run after quit / restart', (t) => {
7268
t.match(cli.output, 'Use `run` to start the app again');
7369
})
7470
.then(() => cli.stepCommand('run'))
71+
.then(() => cli.waitForInitialBreak())
7572
.then(() => cli.waitForPrompt())
7673
.then(() => {
7774
t.match(
@@ -87,6 +84,7 @@ test('run after quit / restart', (t) => {
8784
'steps to the 2nd line');
8885
})
8986
.then(() => cli.stepCommand('restart'))
87+
.then(() => cli.waitForInitialBreak())
9088
.then(() => {
9189
t.match(
9290
cli.output,
@@ -100,6 +98,7 @@ test('run after quit / restart', (t) => {
10098
t.match(cli.output, 'Use `run` to start the app again');
10199
})
102100
.then(() => cli.stepCommand('run'))
101+
.then(() => cli.waitForInitialBreak())
103102
.then(() => cli.waitForPrompt())
104103
.then(() => {
105104
t.match(

test/cli/low-level.test.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ const { test } = require('tap');
44
const startCLI = require('./start-cli');
55

66
test('Debugger agent direct access', (t) => {
7-
const cli = startCLI(['examples/empty.js']);
8-
const scriptPattern = /^\* (\d+): examples(?:\/|\\)empty.js/;
7+
const cli = startCLI(['examples/three-lines.js']);
8+
const scriptPattern = /^\* (\d+): examples(?:\/|\\)three-lines.js/;
99

1010
function onFatal(error) {
1111
cli.quit();
@@ -24,7 +24,10 @@ test('Debugger agent direct access', (t) => {
2424
.then(() => {
2525
t.match(
2626
cli.output,
27-
/scriptSource: '\(function \([^)]+\) \{ \\n}\);'/);
27+
/scriptSource: '\(function \(/);
28+
t.match(
29+
cli.output,
30+
/let x = 1;/);
2831
})
2932
.then(() => cli.quit())
3033
.then(null, onFatal);

test/cli/preserve-breaks.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ test('run after quit / restart', (t) => {
3333
t.match(cli.output, `break in ${script}:3`);
3434
})
3535
.then(() => cli.command('restart'))
36-
.then(() => cli.waitFor([/break in examples/, /breakpoints restored/]))
37-
.then(() => cli.waitForPrompt())
36+
.then(() => cli.waitForInitialBreak())
3837
.then(() => {
3938
t.match(cli.output, `break in ${script}:1`);
4039
})

test/cli/scripts.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const { test } = require('tap');
66
const startCLI = require('./start-cli');
77

88
test('list scripts', (t) => {
9-
const script = Path.join('examples', 'empty.js');
9+
const script = Path.join('examples', 'three-lines.js');
1010
const cli = startCLI([script]);
1111

1212
function onFatal(error) {
@@ -20,7 +20,7 @@ test('list scripts', (t) => {
2020
.then(() => {
2121
t.match(
2222
cli.output,
23-
/^\* \d+: examples(?:\/|\\)empty\.js/,
23+
/^\* \d+: examples(?:\/|\\)three-lines\.js/,
2424
'lists the user script');
2525
t.notMatch(
2626
cli.output,
@@ -31,7 +31,7 @@ test('list scripts', (t) => {
3131
.then(() => {
3232
t.match(
3333
cli.output,
34-
/\* \d+: examples(?:\/|\\)empty\.js/,
34+
/\* \d+: examples(?:\/|\\)three-lines\.js/,
3535
'lists the user script');
3636
t.match(
3737
cli.output,

test/cli/start-cli.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ const CLI =
1111
'inspect' :
1212
require.resolve('../../cli.js');
1313

14+
const BREAK_MESSAGE = new RegExp('(?:' + [
15+
'assert', 'break', 'break on start', 'debugCommand',
16+
'exception', 'other', 'promiseRejection',
17+
].join('|') + ') in', 'i');
18+
1419
function startCLI(args) {
1520
const child = spawn(process.execPath, [CLI, ...args]);
1621
let isFirstStdoutChunk = true;
@@ -94,7 +99,13 @@ function startCLI(args) {
9499
},
95100

96101
waitForInitialBreak(timeout = 2000) {
97-
return this.waitFor(/break/i, timeout);
102+
return this.waitFor(/break (?:on start )?in/i, timeout)
103+
.then(() => {
104+
if (/Break on start/.test(this.output)) {
105+
return this.command('n')
106+
.then(() => this.waitFor(/break in/, timeout));
107+
}
108+
});
98109
},
99110

100111
ctrlC() {
@@ -128,9 +139,7 @@ function startCLI(args) {
128139
child.stdin.write(input);
129140
child.stdin.write('\n');
130141
return this
131-
.waitFor(
132-
/(?:assert|break|debugCommand|exception|other|promiseRejection) in/
133-
)
142+
.waitFor(BREAK_MESSAGE)
134143
.then(() => this.waitForPrompt());
135144
},
136145

0 commit comments

Comments
 (0)