Skip to content

Commit

Permalink
Stop R process if AppDriver fails in test-examples (#820)
Browse files Browse the repository at this point in the history
# Pull Request

<!--- Replace `#nnn` with your issue link for reference. -->

Fixes
insightsengineering/teal.modules.clinical#1302
on `teal.modules.general`
  • Loading branch information
averissimo authored Dec 17, 2024
1 parent 1599608 commit 5c37681
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 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 Expand Up @@ -144,6 +151,7 @@ for (i in rd_files()) {
testthat::test_that(
paste0("example-", basename(i)),
{
testthat::skip_on_cran()
skip_if_too_deep(5)
if (basename(i) %in% strict_exceptions) {
op <- options()
Expand Down

0 comments on commit 5c37681

Please sign in to comment.