Skip to content

Commit d57c76c

Browse files
committed
Report error when parsing for line number selection
This makes the failure a little less mysterious.
1 parent 3572342 commit d57c76c

File tree

5 files changed

+55
-4
lines changed

5 files changed

+55
-4
lines changed

lib/reporters/default.js

+3
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ export default class Reporter {
220220
this.lineNumberErrors.push(event);
221221

222222
this.write(colors.information(`${figures.warning} Could not parse ${this.relativeFile(event.testFile)} for line number selection`));
223+
this.lineWriter.writeLine();
224+
this.lineWriter.writeLine(colors.errorStack(event.err.stack));
225+
this.lineWriter.writeLine();
223226
break;
224227
}
225228

test-tap/reporters/default.edgecases.v12.log

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11

22
---tty-stream-chunk-separator
33
⚠ Could not parse ast-syntax-error.cjs for line number selection
4-
---tty-stream-chunk-separator
54

5+
SyntaxError: Unexpected token (3:11)
6+
 at Parser.pp$4.raise (~/node_modules/acorn/dist/acorn.js:3462:15)
7+
 at Parser.pp$9.unexpected (~/node_modules/acorn/dist/acorn.js:756:10)
8+
 at Parser.pp$5.parseExprAtom (~/node_modules/acorn/dist/acorn.js:2837:12)
9+
 at Parser.pp$5.parseExprSubscripts (~/node_modules/acorn/dist/acorn.js:2629:21)
10+
 at Parser.pp$5.parseMaybeUnary (~/node_modules/acorn/dist/acorn.js:2595:19)
11+
 at Parser.pp$5.parseExprOps (~/node_modules/acorn/dist/acorn.js:2522:21)
12+
 at Parser.pp$5.parseMaybeConditional (~/node_modules/acorn/dist/acorn.js:2505:21)
13+
 at Parser.pp$5.parseMaybeAssign (~/node_modules/acorn/dist/acorn.js:2472:21)
14+
 at Parser.pp$8.parseVar (~/node_modules/acorn/dist/acorn.js:1299:26)
15+
 at Parser.pp$8.parseVarStatement (~/node_modules/acorn/dist/acorn.js:1163:10)
16+
17+
---tty-stream-chunk-separator
618
Uncaught exception in ast-syntax-error.cjs
719

820
~/test-tap/fixture/report/edgecases/ast-syntax-error.cjs:3

test-tap/reporters/default.edgecases.v14.log

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11

22
---tty-stream-chunk-separator
33
⚠ Could not parse ast-syntax-error.cjs for line number selection
4-
---tty-stream-chunk-separator
54

5+
SyntaxError: Unexpected token (3:11)
6+
 at Parser.pp$4.raise (~/node_modules/acorn/dist/acorn.js:3462:15)
7+
 at Parser.pp$9.unexpected (~/node_modules/acorn/dist/acorn.js:756:10)
8+
 at Parser.pp$5.parseExprAtom (~/node_modules/acorn/dist/acorn.js:2837:12)
9+
 at Parser.pp$5.parseExprSubscripts (~/node_modules/acorn/dist/acorn.js:2629:21)
10+
 at Parser.pp$5.parseMaybeUnary (~/node_modules/acorn/dist/acorn.js:2595:19)
11+
 at Parser.pp$5.parseExprOps (~/node_modules/acorn/dist/acorn.js:2522:21)
12+
 at Parser.pp$5.parseMaybeConditional (~/node_modules/acorn/dist/acorn.js:2505:21)
13+
 at Parser.pp$5.parseMaybeAssign (~/node_modules/acorn/dist/acorn.js:2472:21)
14+
 at Parser.pp$8.parseVar (~/node_modules/acorn/dist/acorn.js:1299:26)
15+
 at Parser.pp$8.parseVarStatement (~/node_modules/acorn/dist/acorn.js:1163:10)
16+
17+
---tty-stream-chunk-separator
618
Uncaught exception in ast-syntax-error.cjs
719

820
SyntaxError: Unexpected token 'do'

test-tap/reporters/default.edgecases.v16.log

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11

22
---tty-stream-chunk-separator
33
⚠ Could not parse ast-syntax-error.cjs for line number selection
4-
---tty-stream-chunk-separator
54

5+
SyntaxError: Unexpected token (3:11)
6+
 at Parser.pp$4.raise (~/node_modules/acorn/dist/acorn.js:3462:15)
7+
 at Parser.pp$9.unexpected (~/node_modules/acorn/dist/acorn.js:756:10)
8+
 at Parser.pp$5.parseExprAtom (~/node_modules/acorn/dist/acorn.js:2837:12)
9+
 at Parser.pp$5.parseExprSubscripts (~/node_modules/acorn/dist/acorn.js:2629:21)
10+
 at Parser.pp$5.parseMaybeUnary (~/node_modules/acorn/dist/acorn.js:2595:19)
11+
 at Parser.pp$5.parseExprOps (~/node_modules/acorn/dist/acorn.js:2522:21)
12+
 at Parser.pp$5.parseMaybeConditional (~/node_modules/acorn/dist/acorn.js:2505:21)
13+
 at Parser.pp$5.parseMaybeAssign (~/node_modules/acorn/dist/acorn.js:2472:21)
14+
 at Parser.pp$8.parseVar (~/node_modules/acorn/dist/acorn.js:1299:26)
15+
 at Parser.pp$8.parseVarStatement (~/node_modules/acorn/dist/acorn.js:1163:10)
16+
17+
---tty-stream-chunk-separator
618
Uncaught exception in ast-syntax-error.cjs
719

820
SyntaxError: Unexpected token 'do'

test-tap/reporters/default.edgecases.v18.log

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11

22
---tty-stream-chunk-separator
33
⚠ Could not parse ast-syntax-error.cjs for line number selection
4-
---tty-stream-chunk-separator
54

5+
SyntaxError: Unexpected token (3:11)
6+
 at pp$4.raise (~/node_modules/acorn/dist/acorn.js:3462:15)
7+
 at pp$9.unexpected (~/node_modules/acorn/dist/acorn.js:756:10)
8+
 at pp$5.parseExprAtom (~/node_modules/acorn/dist/acorn.js:2837:12)
9+
 at pp$5.parseExprSubscripts (~/node_modules/acorn/dist/acorn.js:2629:21)
10+
 at pp$5.parseMaybeUnary (~/node_modules/acorn/dist/acorn.js:2595:19)
11+
 at pp$5.parseExprOps (~/node_modules/acorn/dist/acorn.js:2522:21)
12+
 at pp$5.parseMaybeConditional (~/node_modules/acorn/dist/acorn.js:2505:21)
13+
 at pp$5.parseMaybeAssign (~/node_modules/acorn/dist/acorn.js:2472:21)
14+
 at pp$8.parseVar (~/node_modules/acorn/dist/acorn.js:1299:26)
15+
 at pp$8.parseVarStatement (~/node_modules/acorn/dist/acorn.js:1163:10)
16+
17+
---tty-stream-chunk-separator
618
Uncaught exception in ast-syntax-error.cjs
719

820
SyntaxError: Unexpected token 'do'

0 commit comments

Comments
 (0)