Skip to content

Commit 5c37681

Browse files
authored
Stop R process if AppDriver fails in test-examples (#820)
# Pull Request <!--- Replace `#nnn` with your issue link for reference. --> Fixes insightsengineering/teal.modules.clinical#1302 on `teal.modules.general`
1 parent 1599608 commit 5c37681

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

tests/testthat/test-examples.R

Lines changed: 15 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

@@ -144,6 +151,7 @@ for (i in rd_files()) {
144151
testthat::test_that(
145152
paste0("example-", basename(i)),
146153
{
154+
testthat::skip_on_cran()
147155
skip_if_too_deep(5)
148156
if (basename(i) %in% strict_exceptions) {
149157
op <- options()

0 commit comments

Comments
 (0)