diff --git a/tests/testthat/_snaps/reprex.md b/tests/testthat/_snaps/reprex.md index f5e38a8..87c0798 100644 --- a/tests/testthat/_snaps/reprex.md +++ b/tests/testthat/_snaps/reprex.md @@ -10,9 +10,26 @@ # reprex() errors for an R crash, by default Code - code <- "utils::getFromNamespace(\"crash\", \"callr\")()\n" + code <- "rlang::node_car(0)\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. +# reprex() copes with an R crash, when `std_out_err = TRUE` + + Code + cli::cat_line(out[seq_len(min(grep("Traceback", out)))]) + Output + This reprex appears to crash R. + See standard output and standard error for more details. + + #### Standard output and error + + ``` sh + + *** caught segfault *** + address 0x1, cause 'invalid permissions' + + Traceback: + diff --git a/tests/testthat/test-reprex.R b/tests/testthat/test-reprex.R index dd44fc1..717878d 100644 --- a/tests/testthat/test-reprex.R +++ b/tests/testthat/test-reprex.R @@ -61,19 +61,25 @@ test_that("reprex() works even if user uses fancy quotes", { }) test_that("reprex() errors for an R crash, by default", { + skip_on_cran() expect_snapshot(error = TRUE, { - code <- 'utils::getFromNamespace("crash", "callr")()\n' + code <- 'rlang::node_car(0)\n' reprex(input = code) }) }) test_that("reprex() copes with an R crash, when `std_out_err = TRUE`", { - code <- 'utils::getFromNamespace("crash", "callr")()\n' + skip_on_cran() + code <- 'rlang::node_car(0)\n' expect_no_error( out <- reprex(input = code, std_out_err = TRUE) ) + skip_on_os("windows") - expect_match(out, "crash", all = FALSE) - expect_match(out, "segfault", all = FALSE) - expect_match(out, "Traceback", all = FALSE) + + # I don't want to snapshot the whole traceback, but everything above + # the traceback should be stable I think/hope + expect_snapshot(cli::cat_line( + out[seq_len(min(grep("Traceback", out)))] + )) })