From 50717b9d56fdba683f1a0190b47202ba3bb047ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20V=C3=B6lkle?= Date: Wed, 11 Oct 2023 13:19:17 +0200 Subject: [PATCH 1/2] fix java_check if runtime missing --- R/selenium.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/R/selenium.R b/R/selenium.R index e20c5f7..bcfbb43 100644 --- a/R/selenium.R +++ b/R/selenium.R @@ -142,6 +142,10 @@ java_check <- function() { if (identical(unname(javapath), "")) { stop("PATH to JAVA not found. Please check JAVA is installed.") } + java_version <- suppressWarnings(system2(Sys.which("java"), "-version", stdout = TRUE, stderr = TRUE)) + if (!is.null(attr(java_version, "status"))) { + stop(paste(java_version, collapse = "\n")) + } javapath } From 8b5489bfb768a6ad9d4063a4e2a74d0097201345 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20V=C3=B6lkle?= Date: Wed, 11 Oct 2023 13:47:58 +0200 Subject: [PATCH 2/2] fix mock of java_check --- R/selenium.R | 2 +- tests/testthat/test-selenium.R | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/R/selenium.R b/R/selenium.R index 027c050..687b755 100644 --- a/R/selenium.R +++ b/R/selenium.R @@ -142,7 +142,7 @@ java_check <- function() { if (identical(unname(javapath), "")) { stop("PATH to JAVA not found. Please check JAVA is installed.") } - java_version <- suppressWarnings(system2(Sys.which("java"), "-version", stdout = TRUE, stderr = TRUE)) + java_version <- suppressWarnings(system2(javapath, "-version", stdout = TRUE, stderr = TRUE)) if (!is.null(attr(java_version, "status"))) { stop(paste(java_version, collapse = "\n")) } diff --git a/tests/testthat/test-selenium.R b/tests/testthat/test-selenium.R index b7aab50..ce2b7d9 100644 --- a/tests/testthat/test-selenium.R +++ b/tests/testthat/test-selenium.R @@ -78,10 +78,9 @@ test_that("errorIfVersionNotFound", { list_versions = mock_binman_list_versions_selenium, ) local_mocked_bindings( - Sys.which = function(...) { + java_check = function(...) { "im here" }, - .package = "base" ) expect_error(