From 5319f0cee0cd78420adcee515377a2a29eb643d3 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:51:53 +0000 Subject: [PATCH 1/2] feat: stop R process after AppDriver fails --- tests/testthat/test-examples.R | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tests/testthat/test-examples.R b/tests/testthat/test-examples.R index 7acbd0a6d..239be4919 100644 --- a/tests/testthat/test-examples.R +++ b/tests/testthat/test-examples.R @@ -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() From 4e9a0b229deece88bf8ba464aae9aad4c355bfc6 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:17 +0000 Subject: [PATCH 2/2] chore: add missing skip_on_cran call for completeness --- 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 239be4919..89251573d 100644 --- a/tests/testthat/test-examples.R +++ b/tests/testthat/test-examples.R @@ -151,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()