Преглед изворни кода

Use alternative method to surface errors from callr::r_safe()

tags/v0.3.4
Garrick Aden-Buie пре 5 година
родитељ
комит
6c0df7868a
2 измењених фајлова са 13 додато и 3 уклоњено
  1. +12
    -1
      tests/testthat/helper-session.R
  2. +1
    -2
      tests/testthat/test-themes.R

+ 12
- 1
tests/testthat/helper-session.R Прегледај датотеку

@@ -3,5 +3,16 @@ with_clean_session <- function(.f, args = list()) {
dir.create(empty_wd)
owd <- setwd(empty_wd)
on.exit({setwd(owd); unlink(empty_wd, TRUE)})
callr::r_safe(.f, args)
args$.f <- .f
res <- callr::r_safe(function(.f, ...) {
tryCatch(
list(result = .f(...), error = NULL),
error = function(e) list(result = NULL, error = e$message)
)
}, args)
if (!is.null(res$error)) {
stop(res$error)
} else {
res$result
}
}

+ 1
- 2
tests/testthat/test-themes.R Прегледај датотеку

@@ -106,7 +106,6 @@ test_that("style_xaringan() warns about non-hex colors used by theme_xaringan()"
options(warn = 2)
xaringanthemer::style_xaringan(text_color = "rgb(100, 100, 100)", background_color = "white", outfile = NULL)
}),
regexp = "Colors.+used by.+theme_xaringan",
class = "callr_status_error"
regexp = "Colors.+used by.+theme_xaringan"
)
})

Loading…
Откажи
Сачувај