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
Keep "new" snapshots even when terminating early #1402
Comments
Reprex: for (i in 1:20) {
time <- Sys.time()
test_that(paste0("many snapshot failures ", i), {
expect_snapshot(time)
})
} |
Not sure how to fix this. if (self$is_full()) {
self$local_user_output()
self$end_context()
stop_reporter(paste0(
"Maximum number of failures exceeded; quitting early.\n",
"You can increase this number by setting `options(testthat.progress.max_fails)`"
))
} which invokes the |
Actually this is pretty easy because withRestarts(
testthat_abort_reporter = function() {
reporter$end_file()
reporter$end_context()
NULL
},
force(code)
) (And to remove the |
Hmmmm, that doesn't quite work because it doesn't preserve the snapshot that never get run. |
Yeah, in general this is going to need something special so we can distinguish between a file being terminated early because of too many failures vs (e.g.) deleting the last snapshot test in a file. |
Maybe progress reporter could call |
Another idea: what if we always finished out the complete file, even if it meant introducing a few extra failures? |
One more point of clarification that I'm just remembering. If:
Then we keep the "new" snapshot file for File A, but we lose it for File B. i.e. we only lose the snapshot updates for the file that testthat hit the limit in. In light of that, I think what you are suggesting makes sense. Maybe this error could be slightly tweaked to suggest that you have finished out the file: Maximum number of failures exceeded; quitting early.
You can increase this number by setting `options(testthat.progress.max_fails)` Maybe something like: Quitting early due to exceeding the maximum number of allowed failures.
* 10 failures were allowed
* 14 failures have been detected after finishing `test-bind.R`
* You can increase the maximum allowed failures by setting `options(testthat.progress.max_fails)` |
This is less a testthat bug, and more of a pain point that a few of us have experienced.
Sometimes I change package code that I know is going to change some snapshot tests. I normally just test the file and then
snapshot_accept/review()
immediately after. However, if it changes more than 10 tests then testthat fails early and I lose all the changed snapshots.I know I can change
options(testthat.progress.max_fails)
, but is there any other way that testthat could keep around the “new” snapshots even if it fails early? Or ignore the snapshot failures in the total failure count for determining when to terminate early?The text was updated successfully, but these errors were encountered: