From e60e5c86e7e6be824761e889010fe4b119ae358b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Mon, 16 Dec 2024 17:43:46 +0000 Subject: [PATCH 1/2] feat: stop R process after AppDriver fails --- tests/testthat/test-examples.R | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/testthat/test-examples.R b/tests/testthat/test-examples.R index ac0ed08c2e..fc17b52ac6 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) From 3c2bee36f0fce9656960935626d1103724004a6b 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 10:36:49 +0000 Subject: [PATCH 2/2] fix: adds missing testing depth check --- tests/testthat/test-examples.R | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/testthat/test-examples.R b/tests/testthat/test-examples.R index fc17b52ac6..8adc9f92fb 100644 --- a/tests/testthat/test-examples.R +++ b/tests/testthat/test-examples.R @@ -124,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)