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

Commit

Permalink
test: Accept any kind of "break"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Krems committed Apr 3, 2017
1 parent 41148d7 commit 2c224c5
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 29 deletions.
2 changes: 1 addition & 1 deletion test/cli/backtrace.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test('display and navigate backtrace', (t) => {
throw error;
}

return cli.waitFor(/break/)
return cli.waitForInitialBreak()
.then(() => cli.waitForPrompt())
.then(() => cli.stepCommand('c'))
.then(() => cli.command('bt'))
Expand Down
24 changes: 12 additions & 12 deletions test/cli/break.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ test('stepping through breakpoints', (t) => {
throw error;
}

return cli.waitFor(/break/)
return cli.waitForInitialBreak()
.then(() => cli.waitForPrompt())
.then(() => {
t.match(
cli.output,
`break in ${script}:1`,
` in ${script}:1`,
'pauses in the first line of the script');
t.match(
cli.output,
Expand All @@ -30,7 +30,7 @@ test('stepping through breakpoints', (t) => {
.then(() => {
t.match(
cli.output,
`break in ${script}:2`,
` in ${script}:2`,
'pauses in next line of the script');
t.match(
cli.output,
Expand All @@ -41,7 +41,7 @@ test('stepping through breakpoints', (t) => {
.then(() => {
t.match(
cli.output,
`break in ${script}:3`,
` in ${script}:3`,
'pauses in next line of the script');
t.match(
cli.output,
Expand All @@ -52,7 +52,7 @@ test('stepping through breakpoints', (t) => {
.then(() => {
t.match(
cli.output,
`break in ${script}:10`,
` in ${script}:10`,
'pauses on the next breakpoint');
t.match(
cli.output,
Expand Down Expand Up @@ -94,21 +94,21 @@ test('stepping through breakpoints', (t) => {
.then(() => {
t.match(
cli.output,
'break in timers.js',
' in timers.js',
'entered timers.js');
})
.then(() => cli.stepCommand('cont'))
.then(() => {
t.match(
cli.output,
`break in ${script}:16`,
` in ${script}:16`,
'found breakpoint we set above w/ line number only');
})
.then(() => cli.stepCommand('cont'))
.then(() => {
t.match(
cli.output,
`break in ${script}:6`,
` in ${script}:6`,
'found breakpoint we set above w/ line number & script');
})
.then(() => cli.stepCommand(''))
Expand All @@ -132,7 +132,7 @@ test('sb before loading file', (t) => {
throw error;
}

return cli.waitFor(/break/)
return cli.waitForInitialBreak()
.then(() => cli.waitForPrompt())
.then(() => cli.command('sb("other.js", 3)'))
.then(() => {
Expand All @@ -145,7 +145,7 @@ test('sb before loading file', (t) => {
.then(() => {
t.match(
cli.output,
`break in ${otherScript}:3`,
` in ${otherScript}:3`,
'found breakpoint in file that was not loaded yet');
})
.then(() => cli.quit())
Expand All @@ -161,7 +161,7 @@ test('clearBreakpoint', (t) => {
throw error;
}

return cli.waitFor(/break/)
return cli.waitForInitialBreak()
.then(() => cli.waitForPrompt())
.then(() => cli.command('sb("break.js", 3)'))
.then(() => cli.command('sb("break.js", 9)'))
Expand All @@ -187,7 +187,7 @@ test('clearBreakpoint', (t) => {
.then(() => {
t.match(
cli.output,
`break in ${script}:9`,
` in ${script}:9`,
'hits the 2nd breakpoint because the 1st was cleared');
})
.then(() => cli.quit())
Expand Down
10 changes: 5 additions & 5 deletions test/cli/exceptions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ test('break on (uncaught) exceptions', (t) => {
throw error;
}

return cli.waitFor(/break/)
return cli.waitForInitialBreak()
.then(() => cli.waitForPrompt())
.then(() => {
t.match(cli.output, `break in ${script}:1`);
t.match(cli.output, ` in ${script}:1`);
})
// making sure it will die by default:
.then(() => cli.command('c'))
Expand All @@ -26,7 +26,7 @@ test('break on (uncaught) exceptions', (t) => {
// Next run: With `breakOnException` it pauses in both places
.then(() => cli.stepCommand('r'))
.then(() => {
t.match(cli.output, `break in ${script}:1`);
t.match(cli.output, ` in ${script}:1`);
})
.then(() => cli.command('breakOnException'))
.then(() => cli.stepCommand('c'))
Expand All @@ -42,7 +42,7 @@ test('break on (uncaught) exceptions', (t) => {
.then(() => cli.command('breakOnUncaught'))
.then(() => cli.stepCommand('r')) // also, the setting survives the restart
.then(() => {
t.match(cli.output, `break in ${script}:1`);
t.match(cli.output, ` in ${script}:1`);
})
.then(() => cli.stepCommand('c'))
.then(() => {
Expand All @@ -53,7 +53,7 @@ test('break on (uncaught) exceptions', (t) => {
.then(() => cli.command('breakOnNone'))
.then(() => cli.stepCommand('r'))
.then(() => {
t.match(cli.output, `break in ${script}:1`);
t.match(cli.output, ` in ${script}:1`);
})
.then(() => cli.command('c'))
.then(() => cli.waitFor(/disconnect/))
Expand Down
4 changes: 2 additions & 2 deletions test/cli/exec.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test('examples/alive.js', (t) => {
throw error;
}

return cli.waitFor(/break/)
return cli.waitForInitialBreak()
.then(() => cli.waitForPrompt())
.then(() => cli.command('exec [typeof heartbeat, typeof process.exit]'))
.then(() => {
Expand Down Expand Up @@ -60,7 +60,7 @@ test('exec .scope', (t) => {
throw error;
}

return cli.waitFor(/break/)
return cli.waitForInitialBreak()
.then(() => cli.waitForPrompt())
.then(() => cli.stepCommand('c'))
.then(() => cli.command('exec .scope'))
Expand Down
2 changes: 1 addition & 1 deletion test/cli/help.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test('examples/empty.js', (t) => {
throw error;
}

return cli.waitFor(/break/)
return cli.waitForInitialBreak()
.then(() => cli.waitForPrompt())
.then(() => cli.command('help'))
.then(() => {
Expand Down
4 changes: 2 additions & 2 deletions test/cli/launch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test('examples/empty.js', (t) => {
const script = Path.join('examples', 'empty.js');
const cli = startCLI([script]);

return cli.waitFor(/break/)
return cli.waitForInitialBreak()
.then(() => cli.waitForPrompt())
.then(() => {
t.match(cli.output, 'debug>', 'prints a prompt');
Expand Down Expand Up @@ -45,7 +45,7 @@ test('run after quit / restart', (t) => {
throw error;
}

return cli.waitFor(/break/)
return cli.waitForInitialBreak()
.then(() => cli.waitForPrompt())
.then(() => cli.stepCommand('n'))
.then(() => {
Expand Down
2 changes: 1 addition & 1 deletion test/cli/low-level.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test('Debugger agent direct access', (t) => {
throw error;
}

return cli.waitFor(/break/)
return cli.waitForInitialBreak()
.then(() => cli.waitForPrompt())
.then(() => cli.command('scripts'))
.then(() => {
Expand Down
2 changes: 1 addition & 1 deletion test/cli/preserve-breaks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test('run after quit / restart', (t) => {
throw error;
}

return cli.waitFor(/break/)
return cli.waitForInitialBreak()
.then(() => cli.waitForPrompt())
.then(() => cli.command('breakpoints'))
.then(() => {
Expand Down
2 changes: 1 addition & 1 deletion test/cli/profile.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test('profiles', (t) => {
throw error;
}

return cli.waitFor(/break/)
return cli.waitForInitialBreak()
.then(() => cli.waitForPrompt())
.then(() => cli.command('exec console.profile()'))
.then(() => {
Expand Down
2 changes: 1 addition & 1 deletion test/cli/scripts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test('list scripts', (t) => {
throw error;
}

return cli.waitFor(/break/)
return cli.waitForInitialBreak()
.then(() => cli.waitForPrompt())
.then(() => cli.command('scripts'))
.then(() => {
Expand Down
4 changes: 4 additions & 0 deletions test/cli/start-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ function startCLI(args) {
return this.waitFor(/>\s+$/, timeout);
},

waitForInitialBreak(timeout = 2000) {
return this.waitFor(/break/i, timeout);
},

ctrlC() {
return this.command('.interrupt');
},
Expand Down
2 changes: 1 addition & 1 deletion test/cli/use-strict.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test('for whiles that starts with strict directive', (t) => {
throw error;
}

return cli.waitFor(/break/)
return cli.waitForInitialBreak()
.then(() => cli.waitForPrompt())
.then(() => {
t.match(
Expand Down
2 changes: 1 addition & 1 deletion test/cli/watchers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test('stepping through breakpoints', (t) => {
throw error;
}

return cli.waitFor(/break/)
return cli.waitForInitialBreak()
.then(() => cli.waitForPrompt())
.then(() => cli.command('watch("x")'))
.then(() => cli.command('watch("\\"Hello\\"")'))
Expand Down

0 comments on commit 2c224c5

Please sign in to comment.