diff --git a/tests/testthat/_snaps/1.0.6/rlang-errors.md b/tests/testthat/_snaps/1.0.6/rlang-errors.md deleted file mode 100644 index 801363b89..000000000 --- a/tests/testthat/_snaps/1.0.6/rlang-errors.md +++ /dev/null @@ -1,10 +0,0 @@ -# cli_abort(.internal = TRUE) reports the correct function (r-lib/rlang#1386) - - Code - (expect_error(fn())) - Output - - Error in `fn()`: - ! Message. - i This is an internal error that was detected in the base package. - diff --git a/tests/testthat/_snaps/rlang-1.1.0/rlang-errors.md b/tests/testthat/_snaps/rlang-1.1.0/rlang-errors.md new file mode 100644 index 000000000..5251a8637 --- /dev/null +++ b/tests/testthat/_snaps/rlang-1.1.0/rlang-errors.md @@ -0,0 +1,54 @@ +# cli_abort() captures correct call and backtrace + + Code + print(expect_error(f())) + Output + + 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 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 in `fn()`: + ! Message. + i This is an internal error that was detected in the base package. + diff --git a/tests/testthat/_snaps/rlang-errors.md b/tests/testthat/_snaps/rlang-errors.md index ab4b368db..30e40e77e 100644 --- a/tests/testthat/_snaps/rlang-errors.md +++ b/tests/testthat/_snaps/rlang-errors.md @@ -369,33 +369,3 @@ Output color me interested -# cli_abort() captures correct call and backtrace - - Code - print(expect_error(f())) - Output - - 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 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) - diff --git a/tests/testthat/test-rlang-errors.R b/tests/testthat/test-rlang-errors.R index 80686a002..d92c436ef 100644 --- a/tests/testthat/test-rlang-errors.R +++ b/tests/testthat/test-rlang-errors.R @@ -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 @@ -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( @@ -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) } @@ -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"))) })