Skip to content

Commit eb860e9

Browse files
authored
Stop R process if AppDriver fails in test-examples (#1303)
# Pull Request <!--- Replace `#nnn` with your issue link for reference. --> Fixes #1302
1 parent f62391b commit eb860e9

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

tests/testthat/test-examples.R

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,17 @@ with_mocked_app_bindings <- function(code) {
4949
args <- list(...)
5050
args[["launch.browser"]] <- FALSE # needed for RStudio
5151

52-
app_driver <- shinytest2::AppDriver$new(
53-
x,
54-
shiny_args = args,
55-
check_names = FALSE, # explicit check below
56-
options = options() # https://github.com/rstudio/shinytest2/issues/377
52+
app_driver <- tryCatch(
53+
shinytest2::AppDriver$new(
54+
x,
55+
shiny_args = args,
56+
check_names = FALSE, # explicit check below
57+
options = options() # https://github.com/rstudio/shinytest2/issues/377
58+
),
59+
error = function(e) {
60+
e$app$stop() # Ensure the R instance is stopped
61+
stop(e)
62+
}
5763
)
5864
on.exit(app_driver$stop(), add = TRUE)
5965
app_driver$wait_for_idle(timeout = 20000)
@@ -118,6 +124,7 @@ for (i in rd_files()) {
118124
paste0("example-", basename(i)),
119125
{
120126
testthat::skip_on_cran()
127+
skip_if_too_deep(5)
121128
if (basename(i) %in% strict_exceptions) {
122129
op <- options()
123130
withr::local_options(opts_partial_match_old)

0 commit comments

Comments
 (0)