Skip to content

Commit

Permalink
add rlang min requirement and update snapshot (#236)
Browse files Browse the repository at this point in the history
* add rlang min requirement and update snapshot

* Ensure reproducible output for the snapshot
  • Loading branch information
cderv authored Jan 22, 2025
1 parent c048f40 commit 094f832
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Suggests:
lattice,
methods,
pkgload,
rlang,
rlang (>= 1.1.5),
knitr,
testthat (>= 3.0.0),
withr
Expand Down
9 changes: 6 additions & 3 deletions tests/testthat/_snaps/conditions/rmd-abort-error.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions tests/testthat/test-conditions.R
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,15 @@ 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)
callr::rscript(rscript, fail_on_status = FALSE, show = FALSE, stderr = out)
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)
Expand Down

0 comments on commit 094f832

Please sign in to comment.