Skip to content

Normalise the test suite conventions - #281

Merged
EmilHvitfeldt merged 5 commits into
mainfrom
style-sweep
Aug 5, 2026
Merged

Normalise the test suite conventions#281
EmilHvitfeldt merged 5 commits into
mainfrom
style-sweep

Conversation

@EmilHvitfeldt

Copy link
Copy Markdown
Member

Phase 3 item 3.8, the style sweep. Five mechanical commits, no production code touched.

The substantive one is the third: 61 tests wrapped tidypredict_test() in expect_snapshot(), which turns a numeric regression into a snapshot diff rather than a failure. They now assert on $alert, as CONTRIBUTING.md asks. That also revealed two warnings the snapshots had been swallowing, from deliberately degenerate glm and rq fits; both are suppressed explicitly at the call site with a note, so the suite's warning count is unchanged rather than quietly higher.

The rest: withr::local_tempfile() in the 20 files that leaked temp files, skip_if_not_installed() in the four files that had no installed-check for their own suggested package, and the drifted test descriptions.

Two things in the plan's list are deliberately not here:

  • The round_print() sweep. It would rewrite snapshot content across 22 files, and the plan asks for every snapshot diff to be reviewed by hand rather than blanket-accepted. Twenty-two files of numeric churn cannot be meaningfully hand-verified, so the sweep would mean accepting on faith in exactly the place a real change could hide. The fragility it guards against is also still hypothetical: no snapshot has actually broken on precision. test-model-glm.R's two different ad hoc roundings fall under the same heading and are likewise untouched.
  • The 27 copies of "returns the right output". Uninformative rather than inconsistent. Naming each one meaningfully is a judgment call per test, not a sweep.

No snapshot keys moved, incidentally: none of the renamed tests take snapshots, because the save-and-reload tests assert on predictions and the agreement tests were converted in the preceding commit.

Suite is 1770 passing, unchanged, and R CMD check is clean.

Twenty files created temp files with bare `tempfile()` and never removed
them.
The earth, glmnet, ranger and rpart test files had no installed-check for
their own package, despite all four being in Suggests, so a machine missing
one would see failures rather than skips. ranger's existing skip_on_os()
calls are left alone: those guard platform numeric differences, not
availability.
Sixty-one tests wrapped `tidypredict_test()` in `expect_snapshot()`, which
turns a numeric regression into a snapshot diff rather than a failure. Assert
on `$alert` instead, as CONTRIBUTING.md now asks.

Snapshotting was also swallowing two warnings that the modelling packages
raise for deliberately degenerate fits, in glm and rq. Both are now
suppressed explicitly at the call site with a note, so the suite's warning
count is unchanged rather than quietly higher.
Two spellings of the save and reload test, a third phrasing for the same
thing in the GBM files, and a grammatical slip in ten copies of "formulas
produces correct predictions".

No snapshot keys moved: none of the renamed tests take snapshots, since the
save and reload tests assert on predictions and the agreement tests were
converted in the previous commit. "returns the right output" is left alone
in all 27 places; it is uninformative rather than inconsistent, and giving
each a meaningful name is a judgment call per test rather than a sweep.
They cover two model files and need a live cluster, so the name is
deliberate rather than an oversight.
@EmilHvitfeldt
EmilHvitfeldt merged commit e1932d3 into main Aug 5, 2026
9 checks passed
@EmilHvitfeldt
EmilHvitfeldt deleted the style-sweep branch August 5, 2026 20:56
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