Просмотр исходного кода

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

tags/v0.3.4
Garrick Aden-Buie 5 лет назад
Родитель
Сommit
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 Просмотреть файл

dir.create(empty_wd) dir.create(empty_wd)
owd <- setwd(empty_wd) owd <- setwd(empty_wd)
on.exit({setwd(owd); unlink(empty_wd, TRUE)}) 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 Просмотреть файл

options(warn = 2) options(warn = 2)
xaringanthemer::style_xaringan(text_color = "rgb(100, 100, 100)", background_color = "white", outfile = NULL) 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"
) )
}) })

Загрузка…
Отмена
Сохранить