Skip to content

Add regression tests for backtrace source mapping#12

Merged
JPDuchesne merged 1 commit into
mainfrom
jpd/backtrace-mapping-tests
Jul 24, 2026
Merged

Add regression tests for backtrace source mapping#12
JPDuchesne merged 1 commit into
mainfrom
jpd/backtrace-mapping-tests

Conversation

@JPDuchesne

Copy link
Copy Markdown
Contributor

Summary

  • Answers "is the Minitest plugin backtrace filter still necessary after this year's source-mapping fixes?" — yes. ast-transform's e65a92c (compile ISeq with the original source path) made backtrace file paths correct without the filter, but line numbers still come from the transformed source; only RSpock::BacktraceFilter + the SourceMap maps them back. None of this was covered by tests.
  • test/rspock/backtrace_filter_test.rb: unit tests for filter_string (line mapping, transformed-path mapping, ? for unmappable lines, pass-through without a SourceMap), filter_exception, and the RSpock::Minitest::BacktraceFilter wrapper — all against a real SourceMap registered by running a fixture through the actual transform pipeline in a tmpdir (no filesystem mocks).
  • test/rspock/backtrace_source_mapping_test.rb: subprocess integration test running a genuinely failing RSpock test file end to end, asserting failure output cites source line numbers (computed from the fixture, not hardcoded). A second test runs the same fixture with the plugin filter left uninstalled and asserts the cited lines differ — this is the canary that fails if the plugin ever genuinely becomes redundant, so future cleanup can be evidence-based.

Notes for review

  • Fixture sources deliberately use blank lines and multi-line expressions so source and transformed line numbers diverge — a broken mapping cannot pass by coincidence.
  • The child process runs with MT_NO_PLUGINS=1 (minitest's gem-scan plugin discovery activates the Ruby default-gem minitest over the -I one and breaks the run); the enabled variant calls Minitest.plugin_rspock_init({}) explicitly — the same call plugin discovery would make.
  • macOS detail: tmpdir paths are realpath'd because backtrace_locations resolves /var symlinks to /private/var, and SourceMap registration is keyed by exact path string.

Test plan

  • bundle exec rake test — 236 tests, 0 failures (was 228)
  • Both new files individually green

Made with Cursor

Failing tests must report line numbers from the source the developer
wrote, not the transformed code that executes. Unit tests cover
RSpock::BacktraceFilter and the Minitest wrapper against a real
registered SourceMap; a subprocess integration test pins the end-to-end
behavior, including one test documenting that the Minitest plugin
filter is still required — ast-transform's compile-with-source-path fix
corrected file paths but line mapping still needs the filter.

Co-authored-by: Cursor <cursoragent@cursor.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@JPDuchesne
JPDuchesne merged commit 67ffcba into main Jul 24, 2026
3 checks passed
@JPDuchesne
JPDuchesne deleted the jpd/backtrace-mapping-tests branch July 24, 2026 20:23
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.

2 participants