-
Notifications
You must be signed in to change notification settings - Fork 340
Closed
Description
I have some code that works like this:
check <- function(...) {
writeLines(c(...))
stop(...)
}The idea is that because the stop() buffer is pretty limited, I opt to dump a potentially large amount of information with writeLines(), then follow up by signalling an error like "Failed; see above".
I expected {testthat} code like the following to work:
expect_error(
expect_output(
check(...),
"outputMatch"
),
"errorMatch"
)And I thought all was well, however, now I'm noticing this isn't working like I'd intended at all. Basically, I'm not sure if expect_output() is being run at all. Observe:
expect_error(
expect_output(
{ cat("foo\n"); stop("bar") },
"xxx" # not a match
),
"bar" # a match
)
# passes, no error from `expect_output()` failing!Somewhat more insidiously, we don't even get notified if we've totally botched the input to expect_output():
expect_error(
expect_output(
{ cat("foo\n"); stop("bar") },
oopsidaisy() # not defined!
),
"bar" # a match
)
# passes, no error from `expect_output()` failing!(In some sense, that's the same issue as above, since abstractly both are errors from the expect_output() expression, albeit with different condition classes)
Metadata
Metadata
Assignees
Labels
No labels