test: filter std.prql spans from unrelated snapshots - #6162
Conversation
prql-bot
left a comment
There was a problem hiding this comment.
Verified the intent holds: prepending a comment line to std.prql (shifting every std span) leaves the full cargo test -p prqlc suite green with zero snapshot churn, so these three sites cover all the std-span exposure in this crate.
\b0:\d+-\d+ is sound here specifically because STD_LIB_SOURCE_ID is 0 and SourceTree hands user sources ids starting at 1. That's worth stating in a comment at each site, because the same 0: prefix means the query under test in the prqlc-parser snapshots and in error_messages.rs / bad_error_messages.rs — applying this filter there would silently erase real spans rather than noise. Two inline suggestions add that comment and switch to with_settings!, which is the repo's existing idiom (queries.rs uses it in six places; these two are the only Settings::clone_current() calls in the tree). Both compile and leave the snapshots unchanged.
Non-blocking: the regex literal is now in three places. If a fourth shows up, a pub(super) const next to erase_ids in resolver::test would cover both src sites (transforms.rs already reaches for super::super::test::erase_ids); queries.rs is a separate test crate and would keep its own copy.
Worth landing ahead of #6151 / #6155 / #6104 — they each rewrite these same std spans, and their snapshot diffs mostly disappear once this is in.
Co-authored-by: prql-bot <107324867+prql-bot@users.noreply.github.com>
Resolves #6152.
This is the second part; trivial, really, but applies a filter to certain insta snapshots to replace the pattern
r"\b0:\d+-\d+"with[std]. This has the effect that changes tostd.prqlgenerate much less churn in unrelated snapshots and improves code review overall.Note that this filtering is applied very selectively at this point, since it was determined that this issue is fairly narrowly scoped. If we find that there are additional sources of churn, it'll be worth revisiting this approach and maybe making it more generally applied.
No changelog entry as this only affects the content of test snapshots.