Skip to content

Commit

Permalink
feat: stop R process after AppDriver fails
Browse files Browse the repository at this point in the history
  • Loading branch information
averissimo committed Dec 16, 2024
1 parent fe3cd7f commit 5319f0c
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions tests/testthat/test-examples.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,21 @@ with_mocked_app_bindings <- function(code) {
args <- list(...)
args[["launch.browser"]] <- FALSE # needed for RStudio

app_driver <- shinytest2::AppDriver$new(
x,
shiny_args = args,
timeout = 20 * 1000,
load_timeout = 30 * 1000,
check_names = FALSE, # explicit check below
options = options() # https://github.com/rstudio/shinytest2/issues/377
app_driver <- tryCatch(
shinytest2::AppDriver$new(
x,
shiny_args = args,
timeout = 20 * 1000,
load_timeout = 30 * 1000,
check_names = FALSE, # explicit check below
options = options() # https://github.com/rstudio/shinytest2/issues/377
),
error = function(e) {
e$app$stop() # Ensure the R instance is stopped
stop(e)
}
)

on.exit(app_driver$stop(), add = TRUE)
app_driver$wait_for_idle()

Expand Down

0 comments on commit 5319f0c

Please sign in to comment.