From 6560e85dd46c677460b9879a75ec420c450542e6 Mon Sep 17 00:00:00 2001 From: Felix Cheung Date: Thu, 28 Jun 2018 22:12:32 -0700 Subject: [PATCH 1/5] skip cran check test on windows or java version fail --- R/pkg/R/client.R | 6 ++++++ R/pkg/inst/tests/testthat/test_basic.R | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/R/pkg/R/client.R b/R/pkg/R/client.R index 4c87f64e7f0e1..e9b383f72e58c 100644 --- a/R/pkg/R/client.R +++ b/R/pkg/R/client.R @@ -61,6 +61,11 @@ generateSparkSubmitArgs <- function(args, sparkHome, jars, sparkSubmitOpts, pack } checkJavaVersion <- function() { + if (is_windows()) { + # See SPARK-24535 + return(NULL) + } + javaBin <- "java" javaHome <- Sys.getenv("JAVA_HOME") javaReqs <- utils::packageDescription(utils::packageName(), fields = c("SystemRequirements")) @@ -93,6 +98,7 @@ checkJavaVersion <- function() { stop(paste("Java version", sparkJavaVersion, "is required for this package; found version:", javaVersionStr)) } + return(javaVersionNum) } launchBackend <- function(args, sparkHome, jars, sparkSubmitOpts, packages) { diff --git a/R/pkg/inst/tests/testthat/test_basic.R b/R/pkg/inst/tests/testthat/test_basic.R index 823d26f12feee..91923425aef0b 100644 --- a/R/pkg/inst/tests/testthat/test_basic.R +++ b/R/pkg/inst/tests/testthat/test_basic.R @@ -18,6 +18,10 @@ context("basic tests for CRAN") test_that("create DataFrame from list or data.frame", { + tryCatch( if (is.null(checkJavaVersion())) { skip("Windows") }, + error = function(e) { skip("error on Java check") }, + warning = function(e) { skip("warning on Java check") } }) + sparkR.session(master = sparkRTestMaster, enableHiveSupport = FALSE, sparkConfig = sparkRTestConfig) @@ -50,6 +54,10 @@ test_that("create DataFrame from list or data.frame", { }) test_that("spark.glm and predict", { + tryCatch( if (is.null(checkJavaVersion())) { skip("Windows") }, + error = function(e) { skip("error on Java check") }, + warning = function(e) { skip("warning on Java check") } }) + sparkR.session(master = sparkRTestMaster, enableHiveSupport = FALSE, sparkConfig = sparkRTestConfig) From 35ab8a2359cd51b5daa4207d1067c7846ea6d249 Mon Sep 17 00:00:00 2001 From: Felix Cheung Date: Thu, 28 Jun 2018 22:13:58 -0700 Subject: [PATCH 2/5] fix --- R/pkg/inst/tests/testthat/test_basic.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/pkg/inst/tests/testthat/test_basic.R b/R/pkg/inst/tests/testthat/test_basic.R index 91923425aef0b..f094ba08640ef 100644 --- a/R/pkg/inst/tests/testthat/test_basic.R +++ b/R/pkg/inst/tests/testthat/test_basic.R @@ -20,7 +20,7 @@ context("basic tests for CRAN") test_that("create DataFrame from list or data.frame", { tryCatch( if (is.null(checkJavaVersion())) { skip("Windows") }, error = function(e) { skip("error on Java check") }, - warning = function(e) { skip("warning on Java check") } }) + warning = function(e) { skip("warning on Java check") } ) sparkR.session(master = sparkRTestMaster, enableHiveSupport = FALSE, sparkConfig = sparkRTestConfig) @@ -56,7 +56,7 @@ test_that("create DataFrame from list or data.frame", { test_that("spark.glm and predict", { tryCatch( if (is.null(checkJavaVersion())) { skip("Windows") }, error = function(e) { skip("error on Java check") }, - warning = function(e) { skip("warning on Java check") } }) + warning = function(e) { skip("warning on Java check") } ) sparkR.session(master = sparkRTestMaster, enableHiveSupport = FALSE, sparkConfig = sparkRTestConfig) From a4f9b1ef4531f498383b8addf4ac19773601aaef Mon Sep 17 00:00:00 2001 From: Felix Cheung Date: Thu, 28 Jun 2018 23:19:28 -0700 Subject: [PATCH 3/5] do not show --- R/pkg/R/sparkR.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/pkg/R/sparkR.R b/R/pkg/R/sparkR.R index f7c1663d32c96..d3a9cbae7d808 100644 --- a/R/pkg/R/sparkR.R +++ b/R/pkg/R/sparkR.R @@ -167,7 +167,7 @@ sparkR.sparkContext <- function( submitOps <- getClientModeSparkSubmitOpts( Sys.getenv("SPARKR_SUBMIT_ARGS", "sparkr-shell"), sparkEnvirMap) - checkJavaVersion() + invisible(checkJavaVersion()) launchBackend( args = path, sparkHome = sparkHome, From e1d1a64f5bf38710560c6c83b46d8562bb53dd35 Mon Sep 17 00:00:00 2001 From: Felix Cheung Date: Tue, 3 Jul 2018 00:51:25 -0700 Subject: [PATCH 4/5] fix windows --- R/pkg/R/client.R | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/R/pkg/R/client.R b/R/pkg/R/client.R index e9b383f72e58c..660f0864403e0 100644 --- a/R/pkg/R/client.R +++ b/R/pkg/R/client.R @@ -61,11 +61,6 @@ generateSparkSubmitArgs <- function(args, sparkHome, jars, sparkSubmitOpts, pack } checkJavaVersion <- function() { - if (is_windows()) { - # See SPARK-24535 - return(NULL) - } - javaBin <- "java" javaHome <- Sys.getenv("JAVA_HOME") javaReqs <- utils::packageDescription(utils::packageName(), fields = c("SystemRequirements")) @@ -76,15 +71,20 @@ checkJavaVersion <- function() { # If java is missing from PATH, we get an error in Unix and a warning in Windows javaVersionOut <- tryCatch( - launchScript(javaBin, "-version", wait = TRUE, stdout = TRUE, stderr = TRUE), - error = function(e) { - stop("Java version check failed. Please make sure Java is installed", - " and set JAVA_HOME to point to the installation directory.", e) - }, - warning = function(w) { - stop("Java version check failed. Please make sure Java is installed", - " and set JAVA_HOME to point to the installation directory.", w) - }) + if (is_windows()) { + # See SPARK-24535 + system2(javaBin, "-version", wait = TRUE, stdout = TRUE, stderr = TRUE) + } else { + launchScript(javaBin, "-version", wait = TRUE, stdout = TRUE, stderr = TRUE) + }, + error = function(e) { + stop("Java version check failed. Please make sure Java is installed", + " and set JAVA_HOME to point to the installation directory.", e) + }, + warning = function(w) { + stop("Java version check failed. Please make sure Java is installed", + " and set JAVA_HOME to point to the installation directory.", w) + }) javaVersionFilter <- Filter( function(x) { grepl(" version", x) From 8d9ef83deaecc9a0c0c193b7a56c6c4177cbb952 Mon Sep 17 00:00:00 2001 From: Felix Cheung Date: Tue, 3 Jul 2018 00:55:07 -0700 Subject: [PATCH 5/5] remove null check --- R/pkg/inst/tests/testthat/test_basic.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/pkg/inst/tests/testthat/test_basic.R b/R/pkg/inst/tests/testthat/test_basic.R index f094ba08640ef..243f5f0298284 100644 --- a/R/pkg/inst/tests/testthat/test_basic.R +++ b/R/pkg/inst/tests/testthat/test_basic.R @@ -18,7 +18,7 @@ context("basic tests for CRAN") test_that("create DataFrame from list or data.frame", { - tryCatch( if (is.null(checkJavaVersion())) { skip("Windows") }, + tryCatch( checkJavaVersion(), error = function(e) { skip("error on Java check") }, warning = function(e) { skip("warning on Java check") } ) @@ -54,7 +54,7 @@ test_that("create DataFrame from list or data.frame", { }) test_that("spark.glm and predict", { - tryCatch( if (is.null(checkJavaVersion())) { skip("Windows") }, + tryCatch( checkJavaVersion(), error = function(e) { skip("error on Java check") }, warning = function(e) { skip("warning on Java check") } )