From eb860e922856b43b4f75b5dda72ebd4b2b179a97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Tue, 17 Dec 2024 11:56:23 +0000 Subject: [PATCH] Stop R process if AppDriver fails in `test-examples` (#1303) # Pull Request Fixes #1302 --- tests/testthat/test-examples.R | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tests/testthat/test-examples.R b/tests/testthat/test-examples.R index ac0ed08c2e..8adc9f92fb 100644 --- a/tests/testthat/test-examples.R +++ b/tests/testthat/test-examples.R @@ -49,11 +49,17 @@ with_mocked_app_bindings <- function(code) { args <- list(...) args[["launch.browser"]] <- FALSE # needed for RStudio - app_driver <- shinytest2::AppDriver$new( - x, - shiny_args = args, - 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, + 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(timeout = 20000) @@ -118,6 +124,7 @@ for (i in rd_files()) { paste0("example-", basename(i)), { testthat::skip_on_cran() + skip_if_too_deep(5) if (basename(i) %in% strict_exceptions) { op <- options() withr::local_options(opts_partial_match_old)