-
Notifications
You must be signed in to change notification settings - Fork 321
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
Error not recorded if it happens in expect_message() #380
Conversation
84f0b89
to
5f14798
Compare
The error is recorded, it's just not printed, because it's handled when sink() is still active. This also affects expect_warning() and expect_output(). I've added the resulting differences to this PR. Please advise. |
Seems tricky. Best idea so far: Use a new |
Works for me now, PTAL. I'm not inheriting from SilentReporter because I need to forward context and test, too. |
2: g() at reporters/tests.R:32 | ||
3: h() at reporters/tests.R:33 | ||
4: stop("!") at reporters/tests.R:34 | ||
1: expect_message(f(), NA) at reporters/tests.R:36 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll also need to tweak the constants in test_code()
to avoid the extra stuff here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, requires #387 (already included in here).
53f3714
to
6cce66e
Compare
Can you please rebase/merge and I'll give a detailed review |
6cce66e
to
afd51c0
Compare
@@ -18,7 +18,7 @@ stop | |||
|
|||
6. Error: Error:3 (@tests.R#36) ------------------------------------------------ | |||
! | |||
1: f() at reporters/tests.R:36 | |||
1: f() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebased. I wonder if we can do anything about this srcref loss here.
I think I need a bit more info on this problem. Your test: reporter <- with_reporter("silent", {
test_that("", expect_warning(stop()))
})
expect_equal(length(reporter$expectations()), 1)
expect_true(expectation_error(reporter$expectations()[[1L]])) Currently works for me, and that makes sense - the error causes a premature exit from It's not clear your patch preserves the desirable behaviour of suppressing warnings when called from Can you have a go at creating a simple test case that illustrates the current problem? |
afd51c0
to
724d192
Compare
with update of golden files to show the problem
so that reporter output doesn't interfere with testing
724d192
to
27536b7
Compare
…ssage Includes an update of the test results.
I don't like this anymore either: My new DebugReporter (internal WIP) doesn't work here. Perhaps we can teach evaluate_promise() to temporarily close its sink when a reporter is activated. |
I think the way forward is to break |
Adapted reporter test, currently failing.
Closes #387 (=includes it).