Skip to content

Commit 5319f0c

Browse files
committed
feat: stop R process after AppDriver fails
1 parent fe3cd7f commit 5319f0c

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

tests/testthat/test-examples.R

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,21 @@ with_mocked_app_bindings <- function(code) {
4747
args <- list(...)
4848
args[["launch.browser"]] <- FALSE # needed for RStudio
4949

50-
app_driver <- shinytest2::AppDriver$new(
51-
x,
52-
shiny_args = args,
53-
timeout = 20 * 1000,
54-
load_timeout = 30 * 1000,
55-
check_names = FALSE, # explicit check below
56-
options = options() # https://github.com/rstudio/shinytest2/issues/377
50+
app_driver <- tryCatch(
51+
shinytest2::AppDriver$new(
52+
x,
53+
shiny_args = args,
54+
timeout = 20 * 1000,
55+
load_timeout = 30 * 1000,
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
)
64+
5865
on.exit(app_driver$stop(), add = TRUE)
5966
app_driver$wait_for_idle()
6067

0 commit comments

Comments
 (0)