Skip to content

testthat 3e - #1165

Merged
jgabry merged 37 commits into
masterfrom
testthat-3e
Apr 2, 2026
Merged

testthat 3e#1165
jgabry merged 37 commits into
masterfrom
testthat-3e

Conversation

@VisruthSK

@VisruthSK VisruthSK commented Mar 24, 2026

Copy link
Copy Markdown
Member

Migrated to latest testthat edition.

Closes #1155.

@jgabry

jgabry commented Mar 24, 2026

Copy link
Copy Markdown
Member

Thanks for working on this!

@codecov-commenter

codecov-commenter commented Mar 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.14%. Comparing base (5809552) to head (e010022).
⚠️ Report is 25 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1165      +/-   ##
==========================================
+ Coverage   90.85%   91.14%   +0.29%     
==========================================
  Files          14       15       +1     
  Lines        5924     6065     +141     
==========================================
+ Hits         5382     5528     +146     
+ Misses        542      537       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@VisruthSK

Copy link
Copy Markdown
Member Author

@jgabry do you know why macos devel would be failing in the R dep setup? Doesn't seem to happen in main--could this be a cache/GHA error? https://github.com/stan-dev/cmdstanr/actions/runs/23573417706/job/68640740296

@VisruthSK
VisruthSK requested a review from jgabry March 26, 2026 22:16
@jgabry

jgabry commented Mar 26, 2026

Copy link
Copy Markdown
Member

Looks like something is broken in R Core or pak which is causing macos devel to fail.

Took a quick glance at the logs, I agree this seems likely. I’ll try to take a look at the actual PR tomorrow.

@VisruthSK

VisruthSK commented Mar 26, 2026

Copy link
Copy Markdown
Member Author

Thanks! Looks like this (new) function in tools is broken, planning on submit a patch.

Got fixed, so should be gtg soon

@jgabry jgabry left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks great, just a few comments/questions.

Comment thread tests/testthat/helper-custom-expectations.R Outdated
Comment thread tests/testthat/test-fit-vb.R Outdated
Comment thread tests/testthat/test-install.R Outdated
@jgabry

jgabry commented Mar 30, 2026

Copy link
Copy Markdown
Member

Got fixed, so should be gtg soon

Still seems broken (hitting the same error in other repos too)

@VisruthSK

Copy link
Copy Markdown
Member Author

I see builds failing, but I think the specific error that I ran into should be fixed. I think the C API changed so some packages aren't building (abind in posterior, lazyeval in bayesplot). I don't think there are any other deps which are problematic on devel for cmdstanr, so hopefully this run will go through

@jgabry

jgabry commented Mar 30, 2026

Copy link
Copy Markdown
Member

I see builds failing, but I think the specific error that I ran into should be fixed. I think the C API changed so some packages aren't building (abind in posterior, lazyeval in bayesplot). I don't think there are any other deps which are problematic on devel for cmdstanr, so hopefully this run will go through

It's still failing in other recent cmdstanr PRs. This one is from today:

https://github.com/stan-dev/cmdstanr/actions/runs/23760099930/job/69225022781?pr=1166

Not a big deal, we can just wait for it to sort itself out I guess?

@VisruthSK

Copy link
Copy Markdown
Member Author

Missed that. Not sure why its still failing since the code is fixed in source--maybe the R install is cached? Waiting it out seems good to me.

@VisruthSK
VisruthSK marked this pull request as draft March 31, 2026 19:30
@VisruthSK

Copy link
Copy Markdown
Member Author

There are still some snapshots since expect_known_output() was deprecated and the suggestion is to use a snapshot.

@VisruthSK
VisruthSK marked this pull request as ready for review April 1, 2026 01:03
Comment thread tests/testthat/helper-custom-expectations.R Outdated
@VisruthSK

Copy link
Copy Markdown
Member Author

I swapped a number of things to use withr functions instead of base R so that tests don't have to manually clean up after themselves with a bunch of on.exit() calls. withr is already a suggested import so I see no reason not to swap.

@VisruthSK
VisruthSK requested a review from jgabry April 1, 2026 14:52

@jgabry jgabry left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. Just a couple of comments/questions/suggestions. Might have more, but maybe not.

Comment thread tests/testthat/test-model-data.R
Comment thread tests/testthat/helper-custom-expectations.R Outdated
Comment thread tests/testthat/helper-models.R Outdated
Comment thread tests/testthat/test-json.R Outdated
Comment thread tests/testthat/helper-custom-expectations.R Outdated

@jgabry jgabry left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two more small cleanups I noticed. Otherwise I think we're in good shape.

Comment thread tests/testthat/test-model-pathfinder.R
Comment on lines +3 to +8
mtime_check_enabled <- FALSE
if(length(mod$exe_file()) > 0 && file.exists(mod$exe_file())) {
original_mtime <- file.mtime(mod$exe_file())
suppressWarnings(Sys.setFileTime(mod$exe_file(), original_mtime - 10))
before_mtime <- file.mtime(mod$exe_file())
mtime_check_enabled <- before_mtime < original_mtime

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple more mtime_check_enabled to cleanup

@jgabry jgabry left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems ready to me if everything passes. @VisruthSK anything else you wanted to change?

@VisruthSK

Copy link
Copy Markdown
Member Author

Nope will start the snapshot PR after this is merged

@jgabry
jgabry merged commit c0e7c35 into master Apr 2, 2026
24 of 25 checks passed
@jgabry
jgabry deleted the testthat-3e branch April 2, 2026 21:00
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.

Swap to testthat 3e

3 participants