From 589992374dab2d24808bf112ab8fe93f337df58e Mon Sep 17 00:00:00 2001 From: Mark Wubben Date: Sun, 10 Jul 2022 14:25:11 +0200 Subject: [PATCH] Report error when parsing for line number selection This makes the failure a little less mysterious. --- lib/reporters/default.js | 3 +++ test-tap/reporters/default.edgecases.v12.log | 14 +++++++++++++- test-tap/reporters/default.edgecases.v14.log | 14 +++++++++++++- test-tap/reporters/default.edgecases.v16.log | 14 +++++++++++++- test-tap/reporters/default.edgecases.v18.log | 14 +++++++++++++- 5 files changed, 55 insertions(+), 4 deletions(-) diff --git a/lib/reporters/default.js b/lib/reporters/default.js index 955a6bc0a..8a612deef 100644 --- a/lib/reporters/default.js +++ b/lib/reporters/default.js @@ -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; } diff --git a/test-tap/reporters/default.edgecases.v12.log b/test-tap/reporters/default.edgecases.v12.log index bbbe457d2..6db3a290b 100644 --- a/test-tap/reporters/default.edgecases.v12.log +++ b/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 diff --git a/test-tap/reporters/default.edgecases.v14.log b/test-tap/reporters/default.edgecases.v14.log index e39930d14..47a58d804 100644 --- a/test-tap/reporters/default.edgecases.v14.log +++ b/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' diff --git a/test-tap/reporters/default.edgecases.v16.log b/test-tap/reporters/default.edgecases.v16.log index e39930d14..47a58d804 100644 --- a/test-tap/reporters/default.edgecases.v16.log +++ b/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' diff --git a/test-tap/reporters/default.edgecases.v18.log b/test-tap/reporters/default.edgecases.v18.log index e39930d14..83bd6a2aa 100644 --- a/test-tap/reporters/default.edgecases.v18.log +++ b/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'