Skip to content

Enhancement: add more readable parser error snapshots - #130

Open
wasd243 wants to merge 3 commits into
scpwiki:mainfrom
wasd243:feat/position-in-error-output
Open

Enhancement: add more readable parser error snapshots#130
wasd243 wants to merge 3 commits into
scpwiki:mainfrom
wasd243:feat/position-in-error-output

Conversation

@wasd243

@wasd243 wasd243 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds an optional errors.stderr snapshot for parser tests, providing compiler-style diagnostics with precise source locations.

Developers can optionally add an errors.stderr file to failing test cases to verify human-readable parser diagnostics.

errors.json is still required for parser-error tests. errors.stderr is only intended to improve readability for long test inputs (e.g. full articles used for dogfooding, Unicode tests).

errors.stderr is not generated automatically. To enable it for a test, create an empty errors.stderr file first.

Example output:

error: RuleFailed  
  ┌─ input.ftml:1:12  
  │    
1 │   ##not color  
  │ ╭───────────^  
2 │ │   
3 │ │ ##|no spec##  
  │ ╰^ color  
  
error: NoRulesMatch  
  ┌─ input.ftml:1:1  
  │  
1 │ ##not color  
  │ ^^ fallback  
  
error: EndOfInput  
  ┌─ input.ftml:5:14  
  │  
5 │ ##only color|  
  │              ^ color  
  
error: NoRulesMatch  
  ┌─ input.ftml:5:1  
  │  
5 │ ##only color|  
  │ ^^ fallback

Dependency

This PR adds codespan-reporting as a dev-dependency to render compiler-style diagnostics for errors.stderr.

@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.25%. Comparing base (782ce11) to head (4de347e).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #130      +/-   ##
==========================================
+ Coverage   71.17%   71.25%   +0.08%     
==========================================
  Files         220      220              
  Lines        6234     6224      -10     
==========================================
- Hits         4437     4435       -2     
+ Misses       1797     1789       -8     
Flag Coverage Δ *Carryforward flag
ftml 64.39% <ø> (ø) Carriedforward from b7747c7

*This pull request uses carry forward flags. Click here to find out more.
see 10 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wasd243
wasd243 force-pushed the feat/position-in-error-output branch from 4fc002f to 4de347e Compare July 29, 2026 22:10
@wasd243

wasd243 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

I noticed this when testing parser errors with longer .ftml documents.

When the input is large, locating errors from errors.json alone might be difficult, such as:

{  
    "token": "right-block",  
    "rule": "fallback",  
    "span": [  
        // very large number
        // very large number
    ],  
    "kind": "no-rules-match"  
}

The compiler-style errors.stderr output makes the source location immediately visible and makes parser failures easier to debug.

@wasd243
wasd243 marked this pull request as ready for review July 29, 2026 22:33
@wasd243
wasd243 requested a review from emmiegit as a code owner July 29, 2026 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant