From ec6b4c8e103750c0eca3d43461c5e917a0cf8384 Mon Sep 17 00:00:00 2001 From: olivroy Date: Thu, 11 Jan 2024 19:37:04 -0500 Subject: [PATCH] Address comments --- DESCRIPTION | 2 +- tests/testthat/_snaps/reprex.md | 9 +++++++++ tests/testthat/test-reprex.R | 8 ++++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1f1add2c..14bc6340 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -50,7 +50,7 @@ Suggests: shiny, spelling, styler (>= 1.2.0), - testthat (>= 3.2.0) + testthat (>= 3.2.1) VignetteBuilder: knitr Config/Needs/website: diff --git a/tests/testthat/_snaps/reprex.md b/tests/testthat/_snaps/reprex.md index 7ce5f690..f5e38a84 100644 --- a/tests/testthat/_snaps/reprex.md +++ b/tests/testthat/_snaps/reprex.md @@ -7,3 +7,12 @@ [5] "#> 3 1 1 1 1 3 0 expr FALSE" [6] "```" +# reprex() errors for an R crash, by default + + Code + code <- "utils::getFromNamespace(\"crash\", \"callr\")()\n" + reprex(input = code) + Condition + Error in `reprex_render()`: + ! This reprex appears to crash R. Call `reprex()` again with `std_out_err = TRUE` to get more info. + diff --git a/tests/testthat/test-reprex.R b/tests/testthat/test-reprex.R index 4c24f8bb..dd44fc10 100644 --- a/tests/testthat/test-reprex.R +++ b/tests/testthat/test-reprex.R @@ -61,13 +61,13 @@ test_that("reprex() works even if user uses fancy quotes", { }) test_that("reprex() errors for an R crash, by default", { - # TODO: consider switching to expect_snapshot() - code <- 'utils::getFromNamespace("crash", "callr")()\n' - expect_error(reprex(input = code), "crash") + expect_snapshot(error = TRUE, { + code <- 'utils::getFromNamespace("crash", "callr")()\n' + reprex(input = code) + }) }) test_that("reprex() copes with an R crash, when `std_out_err = TRUE`", { - # TODO: consider switching to expect_snapshot() code <- 'utils::getFromNamespace("crash", "callr")()\n' expect_no_error( out <- reprex(input = code, std_out_err = TRUE)