Skip to content

test: assert on the lexer's recovery entry point instead of printing it - #6279

Open
prql-bot wants to merge 1 commit into
mainfrom
test/lexer-recovery-assertions
Open

test: assert on the lexer's recovery entry point instead of printing it#6279
prql-bot wants to merge 1 commit into
mainfrom
test/lexer-recovery-assertions

Conversation

@prql-bot

@prql-bot prql-bot commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

prqlc-parser's lexer tests carried 21 eprintln! calls left over from debugging — every one of the crate's eprintln!s lives in that file — and two of them printed lex_source_recovery's output without asserting on it, so the function prqlc's parser actually calls had no test coverage at all. This drops the printing and replaces it with one test that pins both halves of its return.

Found during the nightly survey of prqlc/prqlc-parser/src/lexer/test.rs.

The new test also records something the old printing hid: despite the name, lex_source_recovery doesn't resume after an error — it returns (None, errors), not the prefix it had already lexed. Its doc comment said it returns "both the LR and any errors encountered", which is never the case; that's corrected to describe what it does. parse_source already handles the None correctly, so this is a doc fix, not a behavior change. The test is also the only coverage for the source_id parameter, the one thing that distinguishes it from lex_source — hence the 1: prefix on the asserted span, where lex_source hard-codes 0:.

The rest of the cleanup
  • Six tests re-imported insta::assert_debug_snapshot inside the function body, shadowing the file-level import on line 2.
  • Three call sites used super::lex_source while the rest of the file used the imported lex_source.
  • test_issue_triple_quoted_with_double_quote referred to "the specific test case from ISSUE.md". No ISSUE.md exists in the tree, and git log --all -- ISSUE.md finds no commit that ever added one, so the comment now describes the case itself: a triple-quoted body containing both quote characters, where the lone " is content.
  • The comments on test_single_curly_quote and test_interpolation_empty said what the test was for at the time it was written ("Test what error we get", "the case that's showing a changed error position") rather than what it pins; they now name the asserted behavior — a character-, not byte-, indexed span, and an unterminated f-string reporting at end of input.

No assertion was changed or removed: the two tests that lost their lex_source_recovery calls keep their lex_source snapshots exactly as they were.

Verification
cargo insta test -p prqlc-parser --lib   # 102 passed, no snapshots to review
task prqlc:test                          # 707 passed, 6 skipped; doc-tests pass; clippy --fix left no changes
cargo clippy -p prqlc-parser --all-targets -- -D warnings   # exit 0
cargo fmt --all --check                  # clean

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