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

rlang error with `... %>% expect_warning() #1994

Closed
krlmlr opened this issue Oct 9, 2024 · 0 comments · Fixed by #2012
Closed

rlang error with `... %>% expect_warning() #1994

krlmlr opened this issue Oct 9, 2024 · 0 comments · Fixed by #2012
Labels
bug an unexpected problem or unintended behavior conditions

Comments

@krlmlr
Copy link
Member

krlmlr commented Oct 9, 2024

  • Can't run in reprex, have to create a file with the contents and source it
  • expect_warning(expect_error(...)) doesn't seem to exhibit this behavior

Perhaps related: #1646

library(testthat)
test_that("boo", {
  expect_error(stop("oops")) %>%
    expect_warning()
})
> library(testthat)

> test_that("boo", {
+   expect_error(stop("oops")) %>%
+     expect_warning()
+ })
-- Error: boo ------------------------------------------------------------------
Error in `trace_back(top = getOption("testthat_topenv"), bottom = trace_env)`: Can't find `bottom` on the call tree.
Backtrace:
    x
 1. +-expect_error(stop("oops")) %>% expect_warning() at ~/.active-rstudio-document:3:3
 2. \-testthat::expect_warning(.)
 3.   \-testthat:::expect_condition_matching(...)
 4.     \-testthat::expect(...)
 5.       \-rlang::trace_back(top = getOption("testthat_topenv"), bottom = trace_env)
 6.         \-rlang:::trace_find_bottom(bottom, frames)
 7.           \-rlang::abort(msg, call = call)

Error:
! Test failed
Backtrace:
 1. base::source("~/.active-rstudio-document", echo = TRUE)
 7. reporter$stop_if_needed()
@hadley hadley added bug an unexpected problem or unintended behavior conditions labels Oct 22, 2024
hadley added a commit that referenced this issue Nov 5, 2024
And create more helpers for testing various more complicated success and failure modes.

Fixes #1994
hadley added a commit that referenced this issue Nov 6, 2024
And create more helpers for testing various more complicated success and failure modes.

Fixes #1994

---------

Co-authored-by: Davis Vaughan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior conditions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants