Skip to content

Commit

Permalink
Fix snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborcsardi committed Mar 22, 2023
1 parent 35d1027 commit c923764
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 43 deletions.
10 changes: 0 additions & 10 deletions tests/testthat/_snaps/1.0.6/rlang-errors.md

This file was deleted.

54 changes: 54 additions & 0 deletions tests/testthat/_snaps/rlang-1.1.0/rlang-errors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# cli_abort() captures correct call and backtrace

Code
print(expect_error(f()))
Output
<error/rlang_error>
Error in `h()`:
! foo
---
Backtrace:
x
1. +-base::print(expect_error(f()))
2. +-testthat::expect_error(f())
3. | \-testthat:::expect_condition_matching(...)
4. | \-testthat:::quasi_capture(...)
5. | +-testthat (local) .capture(...)
6. | | \-base::withCallingHandlers(...)
7. | \-rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
8. \-cli (local) f()
9. \-cli (local) g()
10. \-cli (local) h()

---

Code
print(expect_error(f(list())))
Output
<error/cli_my_class>
Error in `h()`:
! `x` can't be empty.
---
Backtrace:
x
1. +-base::print(expect_error(f(list())))
2. +-testthat::expect_error(f(list()))
3. | \-testthat:::expect_condition_matching(...)
4. | \-testthat:::quasi_capture(...)
5. | +-testthat (local) .capture(...)
6. | | \-base::withCallingHandlers(...)
7. | \-rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
8. \-cli (local) f(list())
9. \-cli (local) g(x)
10. \-cli (local) h(x)

# cli_abort(.internal = TRUE) reports the correct function (r-lib/rlang#1386)

Code
(expect_error(fn()))
Output
<error/rlang_error>
Error in `fn()`:
! Message.
i This is an internal error that was detected in the base package.

30 changes: 0 additions & 30 deletions tests/testthat/_snaps/rlang-errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,33 +369,3 @@
Output
color me interested

# cli_abort() captures correct call and backtrace

Code
print(expect_error(f()))
Output
<error/rlang_error>
Error in `h()`:
! foo
---
Backtrace:
1. base::print(expect_error(f()))
8. cli (local) f()
9. cli (local) g()
10. cli (local) h()

---

Code
print(expect_error(f(list())))
Output
<error/cli_my_class>
Error in `h()`:
! `x` can't be empty.
---
Backtrace:
1. base::print(expect_error(f(list())))
8. cli (local) f(list())
9. cli (local) g(x)
10. cli (local) h(x)

8 changes: 5 additions & 3 deletions tests/testthat/test-rlang-errors.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ test_that_cli(config = "ansi", "update_rstudio_color", {
})

test_that("cli_abort() captures correct call and backtrace", {
skip_on_cran()
rlang::local_options(
rlang_trace_top_env = environment(),
rlang_trace_format_srcrefs = FALSE
Expand All @@ -144,7 +145,7 @@ test_that("cli_abort() captures correct call and backtrace", {

expect_snapshot({
print(expect_error(f()))
})
}, variant = paste0("rlang-", packageVersion("rlang")))

classed_stop <- function(message, env = parent.frame()) {
cli::cli_abort(
Expand All @@ -164,10 +165,11 @@ test_that("cli_abort() captures correct call and backtrace", {

expect_snapshot({
print(expect_error(f(list())))
})
}, variant = paste0("rlang-", packageVersion("rlang")))
})

test_that("cli_abort(.internal = TRUE) reports the correct function (r-lib/rlang#1386)", {
skip_on_cran()
fn <- function() {
cli::cli_abort("Message.", .internal = TRUE)
}
Expand All @@ -176,5 +178,5 @@ test_that("cli_abort(.internal = TRUE) reports the correct function (r-lib/rlang
# Should mention an internal error in the `base` package
expect_snapshot({
(expect_error(fn()))
}, variant = as.character(packageVersion("rlang")))
}, variant = paste0("rlang-", packageVersion("rlang")))
})

0 comments on commit c923764

Please sign in to comment.