From 094f832ff6e68d981a37e18708de7d0433b3dba0 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Wed, 22 Jan 2025 16:58:58 +0100 Subject: [PATCH] add rlang min requirement and update snapshot (#236) * add rlang min requirement and update snapshot * Ensure reproducible output for the snapshot --- DESCRIPTION | 2 +- tests/testthat/_snaps/conditions/rmd-abort-error.txt | 9 ++++++--- .../_snaps/conditions/rmd-stop-error-auto-entrace.txt | 8 +++++--- tests/testthat/test-conditions.R | 2 ++ 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 58b81075..3c218b5a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -31,7 +31,7 @@ Suggests: lattice, methods, pkgload, - rlang, + rlang (>= 1.1.5), knitr, testthat (>= 3.0.0), withr diff --git a/tests/testthat/_snaps/conditions/rmd-abort-error.txt b/tests/testthat/_snaps/conditions/rmd-abort-error.txt index 114acb66..74a0714c 100644 --- a/tests/testthat/_snaps/conditions/rmd-abort-error.txt +++ b/tests/testthat/_snaps/conditions/rmd-abort-error.txt @@ -4,9 +4,12 @@ processing file: ressources/with-abort-error.Rmd Error in `h()`: ! ! Backtrace: - 1. global f() - 2. global g() - 3. global h() + x + 1. \-global f() + 2. \-global g() + 3. \-global h() + 4. \-rlang::abort("!") Quitting from lines 6-10 [unnamed-chunk-1] (ressources/with-abort-error.Rmd) Execution halted +Ran 8/8 deferred expressions diff --git a/tests/testthat/_snaps/conditions/rmd-stop-error-auto-entrace.txt b/tests/testthat/_snaps/conditions/rmd-stop-error-auto-entrace.txt index c2ea7b05..417592b3 100644 --- a/tests/testthat/_snaps/conditions/rmd-stop-error-auto-entrace.txt +++ b/tests/testthat/_snaps/conditions/rmd-stop-error-auto-entrace.txt @@ -4,9 +4,11 @@ processing file: ressources/with-stop-error-auto-entrace.Rmd Error in `h()`: ! ! Backtrace: - 1. global f() - 2. global g() - 3. global h() + x + 1. \-global f() + 2. \-global g() + 3. \-global h() Quitting from lines 6-10 [unnamed-chunk-1] (ressources/with-stop-error-auto-entrace.Rmd) Execution halted +Ran 8/8 deferred expressions diff --git a/tests/testthat/test-conditions.R b/tests/testthat/test-conditions.R index 8a79e7ae..ead11dd2 100644 --- a/tests/testthat/test-conditions.R +++ b/tests/testthat/test-conditions.R @@ -174,6 +174,7 @@ test_that("Error can be entraced and correctly handled in outputs", { rscript <- withr::local_tempfile(fileext = ".R") out2 <- normalizePath(withr::local_tempfile(fileext = ".md"), winslash = "/", mustWork = FALSE) writeLines(c( + "testthat::local_reproducible_output()", "options(knitr.chunk.error = FALSE)", sprintf('knitr::knit("%s", output = "%s")', test_path("ressources/with-stop-error-auto-entrace.Rmd"), out2) ), con = rscript) @@ -181,6 +182,7 @@ test_that("Error can be entraced and correctly handled in outputs", { expect_snapshot_file(out, name = 'rmd-stop-error-auto-entrace.txt') writeLines(c( + "testthat::local_reproducible_output()", "options(knitr.chunk.error = FALSE)", sprintf('res <- knitr::knit("%s", output = "%s")', test_path("ressources/with-abort-error.Rmd"), out2) ), con = rscript)