Skip to content
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

Make broken expectations catchable by try() #594

Merged
merged 1 commit into from
Oct 1, 2017
Merged

Conversation

jcheng5
Copy link
Member

@jcheng5 jcheng5 commented May 26, 2017

Currently, broken expectations break rmarkdown document rendering
even if knitr chunk option error=TRUE. It also breaks the evaluate
package's ability to capture errors.

This PR is just a starting point for discussion, if you like it I can add
tests.

Currently, broken expectations break rmarkdown document rendering
even if knitr chunk option error=TRUE. It also breaks the evaluate
package's ability to capture errors.
@hadley
Copy link
Member

hadley commented May 27, 2017

This seems right to me,

@hadley
Copy link
Member

hadley commented Oct 1, 2017

Hmmmm, this does break a test:

test_that("multiple failures captured even when looking for errors", {
  f <- function() {
    expect_true(FALSE)
    expect_false(TRUE)
  }

  reporter <- with_reporter("silent", {
    test_that("", expect_error(f(), NA))
  })
  expect_equal(length(reporter$expectations()), 3)
})

Presumably because expect_error() shouldn't terminate.

@hadley
Copy link
Member

hadley commented Oct 1, 2017

Probably because of this tryCatch():

  error <- tryCatch(
    {
      object
      NULL
    },
    error = function(e) {
      e
    }
  )

@hadley
Copy link
Member

hadley commented Oct 1, 2017

So I here I think a condition of class exception (but not error) should resume. I think this means we need some unholy hybrid of withCallingHandlers() and tryCatch() or @lionel-'s rlang::with_handlers()

@hadley
Copy link
Member

hadley commented Oct 1, 2017

Same basic problem in #618

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants