@krlmlr, Since 37cc0d0 it is no longer possible to run code with test_dir that involves withCallingHandlers error handling. This is because the default source action now sets wrap=TRUE, which causes all sourced code to be run within test_code.
Since wrap is not exposed in test_dir there is no way to disable this behavior when using test_dir (or test_check).
A simple example of the problem (here we just use test_file since test_file has the argument so we can show both cases):
f <- tempfile()
cat(
"
withCallingHandlers(
stop('This should be handled'),
error=function(e) cat('handled\n')
)
test_that('truth', {expect_true(TRUE)})
",
file=f
)
test_file(f) # fails
test_file(f, wrap=FALSE) # works
For reference, more details on the running withCallingHandlers inside try block issue.
I'm happy to submit a PR that addresses this if you'd like.
@krlmlr, Since 37cc0d0 it is no longer possible to run code with
test_dirthat involveswithCallingHandlerserror handling. This is because the default source action now setswrap=TRUE, which causes all sourced code to be run withintest_code.Since
wrapis not exposed intest_dirthere is no way to disable this behavior when usingtest_dir(ortest_check).A simple example of the problem (here we just use
test_filesincetest_filehas the argument so we can show both cases):For reference, more details on the running
withCallingHandlersinsidetryblock issue.I'm happy to submit a PR that addresses this if you'd like.