summaryrefslogtreecommitdiff
path: root/deps/node-inspect/test/cli/start-cli.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/node-inspect/test/cli/start-cli.js')
-rw-r--r--deps/node-inspect/test/cli/start-cli.js31
1 files changed, 26 insertions, 5 deletions
diff --git a/deps/node-inspect/test/cli/start-cli.js b/deps/node-inspect/test/cli/start-cli.js
index b086dcd8ba..e2fa5fe47c 100644
--- a/deps/node-inspect/test/cli/start-cli.js
+++ b/deps/node-inspect/test/cli/start-cli.js
@@ -16,6 +16,10 @@ const BREAK_MESSAGE = new RegExp('(?:' + [
'exception', 'other', 'promiseRejection',
].join('|') + ') in', 'i');
+function isPreBreak(output) {
+ return /Break on start/.test(output) && /1 \(function \(exports/.test(output);
+}
+
function startCLI(args, flags = []) {
const child = spawn(process.execPath, [...flags, CLI, ...args]);
let isFirstStdoutChunk = true;
@@ -101,13 +105,25 @@ function startCLI(args, flags = []) {
waitForInitialBreak(timeout = 2000) {
return this.waitFor(/break (?:on start )?in/i, timeout)
.then(() => {
- if (/Break on start/.test(this.output)) {
+ if (isPreBreak(this.output)) {
return this.command('next', false)
.then(() => this.waitFor(/break in/, timeout));
}
});
},
+ get breakInfo() {
+ const output = this.output;
+ const breakMatch =
+ output.match(/break (?:on start )?in ([^\n]+):(\d+)\n/i);
+
+ if (breakMatch === null) {
+ throw new Error(
+ `Could not find breakpoint info in ${JSON.stringify(output)}`);
+ }
+ return { filename: breakMatch[1], line: +breakMatch[2] };
+ },
+
ctrlC() {
return this.command('.interrupt');
},
@@ -127,19 +143,24 @@ function startCLI(args, flags = []) {
.map((match) => +match[1]);
},
- command(input, flush = true) {
+ writeLine(input, flush = true) {
if (flush) {
this.flushOutput();
}
+ if (process.env.VERBOSE === '1') {
+ process.stderr.write(`< ${input}\n`);
+ }
child.stdin.write(input);
child.stdin.write('\n');
+ },
+
+ command(input, flush = true) {
+ this.writeLine(input, flush);
return this.waitForPrompt();
},
stepCommand(input) {
- this.flushOutput();
- child.stdin.write(input);
- child.stdin.write('\n');
+ this.writeLine(input, true);
return this
.waitFor(BREAK_MESSAGE)
.then(() => this.waitForPrompt());