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

Commit

Permalink
test: Adjust for v8 5.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Krems committed Apr 3, 2017
1 parent 2c224c5 commit 22bf349
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 20 deletions.
6 changes: 4 additions & 2 deletions test/cli/exceptions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ test('break on (uncaught) exceptions', (t) => {
})
// making sure it will die by default:
.then(() => cli.command('c'))
.then(() => cli.waitFor(/disconnect/))
// TODO: Remove FATAL ERROR once node doesn't show a FATAL ERROR anymore
.then(() => cli.waitFor(/disconnect|FATAL ERROR/))

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

.then(() => cli.quit())
.then(null, onFatal);
Expand Down
11 changes: 5 additions & 6 deletions test/cli/launch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,14 @@ const { test } = require('tap');

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

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

return cli.waitForInitialBreak()
.then(() => cli.waitForPrompt())
.then(() => {
t.match(cli.output, 'debug>', 'prints a prompt');
t.match(
cli.output,
'< Debugger listening on port 9229',
'forwards child output');
})
.then(() => cli.command('["hello", "world"].join(" ")'))
.then(() => {
Expand Down Expand Up @@ -72,6 +68,7 @@ test('run after quit / restart', (t) => {
t.match(cli.output, 'Use `run` to start the app again');
})
.then(() => cli.stepCommand('run'))
.then(() => cli.waitForInitialBreak())
.then(() => cli.waitForPrompt())
.then(() => {
t.match(
Expand All @@ -87,6 +84,7 @@ test('run after quit / restart', (t) => {
'steps to the 2nd line');
})
.then(() => cli.stepCommand('restart'))
.then(() => cli.waitForInitialBreak())
.then(() => {
t.match(
cli.output,
Expand All @@ -100,6 +98,7 @@ test('run after quit / restart', (t) => {
t.match(cli.output, 'Use `run` to start the app again');
})
.then(() => cli.stepCommand('run'))
.then(() => cli.waitForInitialBreak())
.then(() => cli.waitForPrompt())
.then(() => {
t.match(
Expand Down
9 changes: 6 additions & 3 deletions test/cli/low-level.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const { test } = require('tap');
const startCLI = require('./start-cli');

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

function onFatal(error) {
cli.quit();
Expand All @@ -24,7 +24,10 @@ test('Debugger agent direct access', (t) => {
.then(() => {
t.match(
cli.output,
/scriptSource: '\(function \([^)]+\) \{ \\n}\);'/);
/scriptSource: '\(function \(/);
t.match(
cli.output,
/let x = 1;/);
})
.then(() => cli.quit())
.then(null, onFatal);
Expand Down
3 changes: 1 addition & 2 deletions test/cli/preserve-breaks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ test('run after quit / restart', (t) => {
t.match(cli.output, `break in ${script}:3`);
})
.then(() => cli.command('restart'))
.then(() => cli.waitFor([/break in examples/, /breakpoints restored/]))
.then(() => cli.waitForPrompt())
.then(() => cli.waitForInitialBreak())
.then(() => {
t.match(cli.output, `break in ${script}:1`);
})
Expand Down
6 changes: 3 additions & 3 deletions test/cli/scripts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { test } = require('tap');
const startCLI = require('./start-cli');

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

function onFatal(error) {
Expand All @@ -20,7 +20,7 @@ test('list scripts', (t) => {
.then(() => {
t.match(
cli.output,
/^\* \d+: examples(?:\/|\\)empty\.js/,
/^\* \d+: examples(?:\/|\\)three-lines\.js/,
'lists the user script');
t.notMatch(
cli.output,
Expand All @@ -31,7 +31,7 @@ test('list scripts', (t) => {
.then(() => {
t.match(
cli.output,
/\* \d+: examples(?:\/|\\)empty\.js/,
/\* \d+: examples(?:\/|\\)three-lines\.js/,
'lists the user script');
t.match(
cli.output,
Expand Down
17 changes: 13 additions & 4 deletions test/cli/start-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ const CLI =
'inspect' :
require.resolve('../../cli.js');

const BREAK_MESSAGE = new RegExp('(?:' + [
'assert', 'break', 'break on start', 'debugCommand',
'exception', 'other', 'promiseRejection',
].join('|') + ') in', 'i');

function startCLI(args) {
const child = spawn(process.execPath, [CLI, ...args]);
let isFirstStdoutChunk = true;
Expand Down Expand Up @@ -94,7 +99,13 @@ function startCLI(args) {
},

waitForInitialBreak(timeout = 2000) {
return this.waitFor(/break/i, timeout);
return this.waitFor(/break (?:on start )?in/i, timeout)
.then(() => {
if (/Break on start/.test(this.output)) {
return this.command('n')
.then(() => this.waitFor(/break in/, timeout));
}
});
},

ctrlC() {
Expand Down Expand Up @@ -128,9 +139,7 @@ function startCLI(args) {
child.stdin.write(input);
child.stdin.write('\n');
return this
.waitFor(
/(?:assert|break|debugCommand|exception|other|promiseRejection) in/
)
.waitFor(BREAK_MESSAGE)
.then(() => this.waitForPrompt());
},

Expand Down

0 comments on commit 22bf349

Please sign in to comment.