Skip to content

Make str() snapshots stable across R versions - #271

Merged
LittleBeannie merged 2 commits into
mainfrom
fix-snapshot-str-spacing
Nov 5, 2026
Merged

LittleBeannie merged 2 commits into
mainfrom
fix-snapshot-str-spacing

Conversation

@yihui

@yihui yihui commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

Fixes the R-devel failure in https://github.com/Merck/metalite.ae/actions/runs/41533856815 (PR #269): R-devel (wch/r-source@83231b3) now always puts one space after $ name:, @ slot: and attr(*, "x")= in str() output, which older R sometimes omitted ($ n :'data.frame' vs $ n : 'data.frame'). Three expect_snapshot(tbl) snapshots depend on that output.

  • Add a print_str() test helper (tests/testthat/helper.R) that normalizes that separator to exactly one space.
  • Use expect_snapshot(print_str(tbl)) in the three affected tests and update their snapshots (only the spacing and the snapshot code line change).

Tests only; no change to package code, so no NEWS entry. The full testthat suite passes locally on R 4.6.1; R-devel is verified by the CI devel job.

🤖 Generated with Claude Code

yihui and others added 2 commits November 5, 2026 11:04
R-devel (r90805) always puts one space after `$ name:`, `@ slot:` and
`attr(*, "x")=` in str() output, which older R sometimes omitted (e.g.,
`$ n :'data.frame'`), breaking the `expect_snapshot(tbl)` snapshots on
R-devel. Add a `print_str()` test helper that normalizes that separator and
use it for the three affected snapshots.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@yihui
yihui requested a review from LittleBeannie November 5, 2026 16:30
@LittleBeannie
LittleBeannie merged commit 3b1f160 into main Nov 5, 2026
2 checks passed
@LittleBeannie
LittleBeannie deleted the fix-snapshot-str-spacing branch November 5, 2026 19:28
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