Skip to content

test(frontend-metricsql): clearer failures in the external corpus test - #1502

Merged
milindsrivastava1997 merged 1 commit into
mainfrom
external-corpus-review-fixes
Nov 25, 2026
Merged

milindsrivastava1997 merged 1 commit into
mainfrom
external-corpus-review-fixes

Conversation

@milindsrivastava1997

Copy link
Copy Markdown
Collaborator

Follow-up to #1501 (#1497).

Summary

A late review of #1501 found seven minor problems in crates/frontend-metricsql/tests/lowering_corpora/external_corpus/external_corpus.rs. This PR fixes all seven. Six change behavior or docs as suggested; for #5 the doc comment is narrowed rather than the code, for the reason given below.

Review comments and replies

# Review comment Reply / change
1 Panic doesn't name the query (:76). If lowering crashes on one query, the failure doesn't say which query or file. Fix: catch the panic and report the file and query. Agreed; this is the most useful fix, since catching panics is the test's main purpose. tally wraps each lowering in catch_unwind, prints <file>: lowering panicked on "<query>", then resume_unwinds, so the original panic message and location are kept.
2 Malformed floor line reported as missing (:34). # floor: ~40 fails with "no # floor: N line". Agreed. floor returns Result<usize, String>: "no # floor: N line" vs "# floor: ~40: not a whole number".
3 Read errors don't name the file (:107). entry.unwrap() and read_to_string(..).unwrap() panic without the path. Agreed. Both now panic with the directory or file path, e.g. <path>: stream did not contain valid UTF-8.
4 Empty env var fails instead of skipping (:127). Agreed. An empty ASAP_EXTERNAL_CORPUS_DIR is treated as unset.
5 normalize doesn't match its doc comment (:48). It only replaces all-digit words, so 5m and 10m stay different. Replace numbers inside words too, or narrow the comment. Narrowed the comment and kept the code. Replacing digits inside words would merge different unsupported functions, e.g. log2 and log10 into logN, and the cause histogram exists to show which features block queries. Keeping 5m/10m apart costs less. The comment now says so, and floor_line pins it.
6 floor_line test has no description (:156), and covers queries and normalize, which its name doesn't suggest. Agreed. Added a statement naming all three helpers; also covers the malformed-floor case and the normalize behavior from #5.
7 Fixed temp path in floor_is_enforced_per_file (:141). Concurrent runs share the directory. Agreed. The directory name includes the process id.

Review guide

One file. tally (panic naming), floor (now a Result), check_dir (paths in read errors), corpus_lowers (empty var), and the two tests.

Behavior: before → after

# a file with `# floor: ~40`
before: panicked: a: no `# floor: N` line
after:  panicked: a: `# floor: ~40`: not a whole number

# a query that panics in lowering
before: panicked at <lowering code>: <message>          (no file or query)
after:  a: lowering panicked on "<query>"
        panicked at <lowering code>: <message>

Interfaces

None (test-only).

Algorithm changes

None.

Decisions and open questions

Verification

  • cargo test -p asap-frontend-metricsql --test external_corpus: 3 passed; cargo clippy -D warnings, cargo fmt --check clean; pre-commit cargo test passed.
  • Exercised each path by hand with ASAP_EXTERNAL_CORPUS_DIR:
    • empty value → "unset or empty; skipping", passes;
    • # floor: ~40 → a: \# floor: ~40`: not a whole number`;
    • a non-UTF-8 file → <path>: stream did not contain valid UTF-8;
    • a temporarily injected panic on one query → a: lowering panicked on "PANIC_ME" (edit reverted);
    • a private corpus → passes, unchanged counts.

🤖 Generated with Claude Code

Follow-up to #1501's late review:
- a lowering panic names the file and query;
- a malformed `# floor:` line says so instead of "missing";
- read errors name the file;
- an empty ASAP_EXTERNAL_CORPUS_DIR skips like an unset one;
- normalize's doc matches what it does (all-digit words only, and why);
- floor_line states what it checks;
- the sample directory is per process.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@milindsrivastava1997
milindsrivastava1997 merged commit 6a84164 into main Nov 25, 2026
3 checks passed
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