| @@ -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 | |||
| } | |||
| } | |||
| @@ -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" | |||
| ) | |||
| }) | |||