-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade to testthat 3e #949
Conversation
Closes #783
This is how benchmark results would change (along with a 95% confidence interval in relative change) if 2af428b is merged into main:
Further explanation regarding interpretation and methodology can be found in the documentation. |
You are on a roll today 🥳. All checks green so far. Also, some checks in |
Also note that some utf8 related tests give a different Output for me locally, but it passes CI and CRAN, so I suggest to not touch them. |
Yes, I am now using snapshots for the relevant tests. Let's see if the tests pass now. If I understand the previous testing infrastructure correctly, with a switch to snapshots, the binary files here should be deleted, right? |
Codecov Report
@@ Coverage Diff @@
## main #949 +/- ##
=======================================
Coverage 89.81% 89.81%
=======================================
Files 47 47
Lines 2611 2611
=======================================
Hits 2345 2345
Misses 266 266 Continue to review full report at Codecov.
|
@lorenzwalthert The following code: cache_info[, c("n", "size", "last_modified", "activated")] produces the following output on R versions > 3.6 # A tibble: 1 x 4
n size last_modified activated
<int> <dbl> <dttm> <lgl>
1 0 0 -Inf -Inf FALSE and otherwise # A tibble: 1 x 4
n size last_modified activated
<int> <dbl> <dttm> <lgl>
1 0 0 NA NA FALSE Should this test be skipped on older versions? |
Yes. That one can be skipped on old R versions. And the binary (but not the R files). can be deleted in that dir. |
This is how benchmark results would change (along with a 95% confidence interval in relative change) if c963258 is merged into main:
Further explanation regarding interpretation and methodology can be found in the documentation. |
@lorenzwalthert Can you please check if this is what you want? More specifically, do you want to include snaphots of entire error messages or are you happy with the current approach of using regexps to check error messages?
@IndrajeetPatil about the errors: I am not sure we want to catch exact errors that are defined outside {styler}. In the past, R core changed the parser and I had to release a new styler version just to fix these. I am happy snapshotting our own errors but probably it's better to rely on regex for f1d87bd and the like. Is there a way to do that with the third edition? |
This is how benchmark results would change (along with a 95% confidence interval in relative change) if a241065 is merged into main:
Further explanation regarding interpretation and methodology can be found in the documentation. |
You might also consider generating the base error message yourself and comparing to that -- should be even more stable than regexes. |
This reverts commit f1d87bd.
Thanks @MichaelChirico. But what's the advantage over |
Yeah, the third edition has no issues with using regex for testing error messages. So basically nothing needs to be changed with these tests. In this case, there is nothing more that needs to be done for this PR. |
@lorenzwalthert I am not sure why pre-commit GHA is failing now. Seems to do with end of files, but not sure how to fix this: |
This is how benchmark results would change (along with a 95% confidence interval in relative change) if 06241bd is merged into main:
Further explanation regarding interpretation and methodology can be found in the documentation. |
Well there is some important definition / convention that a file should end with one and exactly one line break. That's enforced with that hook, so here are the options to fix it:
|
The easiest and quickest solution here is to remove the extra line break manually. |
This reverts commit 7c2db48.
But then whenever you run testthat, it will add it, no? In that case, maybe we should exclude the snaps from pre-commit... |
Indeed, that seems like the best way to go. Sorry, not too familiar with the precommit framework. How can I exclude the |
Adapt - id: end-of-file-fixer
exclude: >
(?x)^(
\.Rd|
tests/testthat/exception_handling/empty_file\.R|
tests/testthat/parse_comments/eol_eof_spaces-.*|
tests/testthat/reference-objects/.*|
tests/testthat/_snaps/.*|
)$ |
This is how benchmark results would change (along with a 95% confidence interval in relative change) if b38acf5 is merged into main:
Further explanation regarding interpretation and methodology can be found in the documentation. |
Perfect @IndrajeetPatil. Thanks a lot. I also added a NEWS entry. |
This is how benchmark results would change (along with a 95% confidence interval in relative change) if 19c5099 is merged into main:
Further explanation regarding interpretation and methodology can be found in the documentation. |
Thanks, Lorenz! Btw, precommit is really awesome, so thanks for that as well. Included it here: |
Closes #783
TODO:
context()
statements using-expect_equivalent()
->expect_equal()
expect_known_value()
withexpect_snapshot_value()
Useexpect_snapshot_error(...)
instead ofexpect_error(..., regexp)
Useexpect_snapshot_warning(...)
instead ofexpect_warning(..., regexp)
Useexpect_snapshot_message(...)
instead ofexpect_message(..., regexp)