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

Commit 0fba6a0

Browse files
author
Jan Krems
committed
fix: Address regressions due to changes in node
1 parent 1d94012 commit 0fba6a0

File tree

6 files changed

+25
-9
lines changed

6 files changed

+25
-9
lines changed

lib/internal/inspect_repl.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const Path = require('path');
2525
const Repl = require('repl');
2626
const util = require('util');
2727
const vm = require('vm');
28+
const fileURLToPath = require('url').fileURLToPath;
2829

2930
const debuglog = util.debuglog('inspect');
3031

@@ -89,9 +90,12 @@ function isNativeUrl(url) {
8990
return url.replace('.js', '') in NATIVES || url === 'bootstrap_node.js';
9091
}
9192

92-
function getRelativePath(filename) {
93+
function getRelativePath(filenameOrURL) {
9394
const dir = Path.join(Path.resolve(), 'x').slice(0, -1);
9495

96+
const filename = filenameOrURL.startsWith('file://') ?
97+
fileURLToPath(filenameOrURL) : filenameOrURL;
98+
9599
// Change path to relative, if possible
96100
if (filename.indexOf(dir) === 0) {
97101
return filename.slice(dir.length);

test/cli/break.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ test('stepping through breakpoints', (t) => {
1818
.then(() => cli.waitForPrompt())
1919
.then(() => {
2020
t.match(
21-
cli.output,
22-
`break in ${script}:1`,
21+
cli.breakInfo,
22+
{ filename: script, line: 1 },
2323
'pauses in the first line of the script');
2424
t.match(
2525
cli.output,
26-
/> 1 \(function \([^)]+\) \{ const x = 10;/,
26+
/> 1 (?:\(function \([^)]+\) \{ )?const x = 10;/,
2727
'shows the source and marks the current line');
2828
})
2929
.then(() => cli.stepCommand('n'))

test/cli/low-level.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ test('Debugger agent direct access', (t) => {
2424
.then(() => {
2525
t.match(
2626
cli.output,
27-
/scriptSource: '\(function \(/);
27+
/scriptSource:[ \n]*'\(function \(/);
2828
t.match(
2929
cli.output,
3030
/let x = 1;/);

test/cli/scripts.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ test('list scripts', (t) => {
2424
'lists the user script');
2525
t.notMatch(
2626
cli.output,
27-
/\d+: module\.js <native>/,
27+
/\d+: buffer\.js <native>/,
2828
'omits node-internal scripts');
2929
})
3030
.then(() => cli.command('scripts(true)'))
@@ -35,7 +35,7 @@ test('list scripts', (t) => {
3535
'lists the user script');
3636
t.match(
3737
cli.output,
38-
/\d+: module\.js <native>/,
38+
/\d+: buffer\.js <native>/,
3939
'includes node-internal scripts');
4040
})
4141
.then(() => cli.quit())

test/cli/start-cli.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,17 @@ function startCLI(args, flags = []) {
108108
});
109109
},
110110

111+
get breakInfo() {
112+
const output = this.output;
113+
const breakMatch =
114+
output.match(/break (?:on start )in ([^\n]+):(\d+)\n/i);
115+
116+
if (breakMatch === null) {
117+
throw new Error(`Could not find breakpoint info in ${output}`);
118+
}
119+
return { filename: breakMatch[1], line: +breakMatch[2] };
120+
},
121+
111122
ctrlC() {
112123
return this.command('.interrupt');
113124
},

test/cli/use-strict.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ test('for whiles that starts with strict directive', (t) => {
1717
return cli.waitForInitialBreak()
1818
.then(() => cli.waitForPrompt())
1919
.then(() => {
20+
const brk = cli.breakInfo;
2021
t.match(
21-
cli.output,
22-
/break in [^:]+:(?:1|2)[^\d]/,
22+
`${brk.line}`,
23+
/^(1|2)$/,
2324
'pauses either on strict directive or first "real" line');
2425
})
2526
.then(() => cli.quit())

0 commit comments

Comments
 (0)