Skip to content

Commit

Permalink
Report error when parsing for line number selection
Browse files Browse the repository at this point in the history
This makes the failure a little less mysterious.
  • Loading branch information
novemberborn committed Jul 10, 2022
1 parent ac0d75d commit 5899923
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 4 deletions.
3 changes: 3 additions & 0 deletions lib/reporters/default.js
Expand Up @@ -220,6 +220,9 @@ export default class Reporter {
this.lineNumberErrors.push(event);

this.write(colors.information(`${figures.warning} Could not parse ${this.relativeFile(event.testFile)} for line number selection`));
this.lineWriter.writeLine();
this.lineWriter.writeLine(colors.errorStack(event.err.stack));
this.lineWriter.writeLine();
break;
}

Expand Down
14 changes: 13 additions & 1 deletion test-tap/reporters/default.edgecases.v12.log
@@ -1,8 +1,20 @@

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

SyntaxError: Unexpected token (3:11)
 at Parser.pp$4.raise (~/node_modules/acorn/dist/acorn.js:3462:15)
 at Parser.pp$9.unexpected (~/node_modules/acorn/dist/acorn.js:756:10)
 at Parser.pp$5.parseExprAtom (~/node_modules/acorn/dist/acorn.js:2837:12)
 at Parser.pp$5.parseExprSubscripts (~/node_modules/acorn/dist/acorn.js:2629:21)
 at Parser.pp$5.parseMaybeUnary (~/node_modules/acorn/dist/acorn.js:2595:19)
 at Parser.pp$5.parseExprOps (~/node_modules/acorn/dist/acorn.js:2522:21)
 at Parser.pp$5.parseMaybeConditional (~/node_modules/acorn/dist/acorn.js:2505:21)
 at Parser.pp$5.parseMaybeAssign (~/node_modules/acorn/dist/acorn.js:2472:21)
 at Parser.pp$8.parseVar (~/node_modules/acorn/dist/acorn.js:1299:26)
 at Parser.pp$8.parseVarStatement (~/node_modules/acorn/dist/acorn.js:1163:10)

---tty-stream-chunk-separator
Uncaught exception in ast-syntax-error.cjs

~/test-tap/fixture/report/edgecases/ast-syntax-error.cjs:3
Expand Down
14 changes: 13 additions & 1 deletion test-tap/reporters/default.edgecases.v14.log
@@ -1,8 +1,20 @@

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

SyntaxError: Unexpected token (3:11)
 at Parser.pp$4.raise (~/node_modules/acorn/dist/acorn.js:3462:15)
 at Parser.pp$9.unexpected (~/node_modules/acorn/dist/acorn.js:756:10)
 at Parser.pp$5.parseExprAtom (~/node_modules/acorn/dist/acorn.js:2837:12)
 at Parser.pp$5.parseExprSubscripts (~/node_modules/acorn/dist/acorn.js:2629:21)
 at Parser.pp$5.parseMaybeUnary (~/node_modules/acorn/dist/acorn.js:2595:19)
 at Parser.pp$5.parseExprOps (~/node_modules/acorn/dist/acorn.js:2522:21)
 at Parser.pp$5.parseMaybeConditional (~/node_modules/acorn/dist/acorn.js:2505:21)
 at Parser.pp$5.parseMaybeAssign (~/node_modules/acorn/dist/acorn.js:2472:21)
 at Parser.pp$8.parseVar (~/node_modules/acorn/dist/acorn.js:1299:26)
 at Parser.pp$8.parseVarStatement (~/node_modules/acorn/dist/acorn.js:1163:10)

---tty-stream-chunk-separator
Uncaught exception in ast-syntax-error.cjs

SyntaxError: Unexpected token 'do'
Expand Down
14 changes: 13 additions & 1 deletion test-tap/reporters/default.edgecases.v16.log
@@ -1,8 +1,20 @@

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

SyntaxError: Unexpected token (3:11)
 at Parser.pp$4.raise (~/node_modules/acorn/dist/acorn.js:3462:15)
 at Parser.pp$9.unexpected (~/node_modules/acorn/dist/acorn.js:756:10)
 at Parser.pp$5.parseExprAtom (~/node_modules/acorn/dist/acorn.js:2837:12)
 at Parser.pp$5.parseExprSubscripts (~/node_modules/acorn/dist/acorn.js:2629:21)
 at Parser.pp$5.parseMaybeUnary (~/node_modules/acorn/dist/acorn.js:2595:19)
 at Parser.pp$5.parseExprOps (~/node_modules/acorn/dist/acorn.js:2522:21)
 at Parser.pp$5.parseMaybeConditional (~/node_modules/acorn/dist/acorn.js:2505:21)
 at Parser.pp$5.parseMaybeAssign (~/node_modules/acorn/dist/acorn.js:2472:21)
 at Parser.pp$8.parseVar (~/node_modules/acorn/dist/acorn.js:1299:26)
 at Parser.pp$8.parseVarStatement (~/node_modules/acorn/dist/acorn.js:1163:10)

---tty-stream-chunk-separator
Uncaught exception in ast-syntax-error.cjs

SyntaxError: Unexpected token 'do'
Expand Down
14 changes: 13 additions & 1 deletion test-tap/reporters/default.edgecases.v18.log
@@ -1,8 +1,20 @@

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

SyntaxError: Unexpected token (3:11)
 at pp$4.raise (~/node_modules/acorn/dist/acorn.js:3462:15)
 at pp$9.unexpected (~/node_modules/acorn/dist/acorn.js:756:10)
 at pp$5.parseExprAtom (~/node_modules/acorn/dist/acorn.js:2837:12)
 at pp$5.parseExprSubscripts (~/node_modules/acorn/dist/acorn.js:2629:21)
 at pp$5.parseMaybeUnary (~/node_modules/acorn/dist/acorn.js:2595:19)
 at pp$5.parseExprOps (~/node_modules/acorn/dist/acorn.js:2522:21)
 at pp$5.parseMaybeConditional (~/node_modules/acorn/dist/acorn.js:2505:21)
 at pp$5.parseMaybeAssign (~/node_modules/acorn/dist/acorn.js:2472:21)
 at pp$8.parseVar (~/node_modules/acorn/dist/acorn.js:1299:26)
 at pp$8.parseVarStatement (~/node_modules/acorn/dist/acorn.js:1163:10)

---tty-stream-chunk-separator
Uncaught exception in ast-syntax-error.cjs

SyntaxError: Unexpected token 'do'
Expand Down

0 comments on commit 5899923

Please sign in to comment.