From 294ce991d2e1c8d7a38b526ccf4f35a7ac41fbc1 Mon Sep 17 00:00:00 2001 From: Felix Cheung Date: Sat, 21 Jan 2017 18:14:06 -0800 Subject: [PATCH 1/2] do not drop stdout --- R/pkg/R/utils.R | 6 +++--- R/pkg/inst/tests/testthat/test_Windows.R | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/pkg/R/utils.R b/R/pkg/R/utils.R index 74b3e502eb7ca..839763186d52a 100644 --- a/R/pkg/R/utils.R +++ b/R/pkg/R/utils.R @@ -756,12 +756,12 @@ varargsToJProperties <- function(...) { props } -launchScript <- function(script, combinedArgs, capture = FALSE) { +launchScript <- function(script, combinedArgs, wait = FALSE) { if (.Platform$OS.type == "windows") { scriptWithArgs <- paste(script, combinedArgs, sep = " ") - shell(scriptWithArgs, translate = TRUE, wait = capture, intern = capture) # nolint + shell(scriptWithArgs, translate = TRUE, wait = wait, intern = wait) # nolint } else { - system2(script, combinedArgs, wait = capture, stdout = capture) + system2(script, combinedArgs, wait = wait) } } diff --git a/R/pkg/inst/tests/testthat/test_Windows.R b/R/pkg/inst/tests/testthat/test_Windows.R index 8813e18a1fa4d..e8d983426a676 100644 --- a/R/pkg/inst/tests/testthat/test_Windows.R +++ b/R/pkg/inst/tests/testthat/test_Windows.R @@ -20,7 +20,7 @@ test_that("sparkJars tag in SparkContext", { if (.Platform$OS.type != "windows") { skip("This test is only for Windows, skipped") } - testOutput <- launchScript("ECHO", "a/b/c", capture = TRUE) + testOutput <- launchScript("ECHO", "a/b/c", wait = TRUE) abcPath <- testOutput[1] expect_equal(abcPath, "a\\b\\c") }) From 322b7600838f20ea48a7108e6e00ffcb51e1818e Mon Sep 17 00:00:00 2001 From: Felix Cheung Date: Fri, 27 Jan 2017 11:50:09 -0800 Subject: [PATCH 2/2] add default, comment --- R/pkg/R/utils.R | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/R/pkg/R/utils.R b/R/pkg/R/utils.R index 839763186d52a..1f7848f2b413f 100644 --- a/R/pkg/R/utils.R +++ b/R/pkg/R/utils.R @@ -759,9 +759,14 @@ varargsToJProperties <- function(...) { launchScript <- function(script, combinedArgs, wait = FALSE) { if (.Platform$OS.type == "windows") { scriptWithArgs <- paste(script, combinedArgs, sep = " ") + # on Windows, intern = F seems to mean output to the console. (documentation on this is missing) shell(scriptWithArgs, translate = TRUE, wait = wait, intern = wait) # nolint } else { - system2(script, combinedArgs, wait = wait) + # http://stat.ethz.ch/R-manual/R-devel/library/base/html/system2.html + # stdout = F means discard output + # stdout = "" means to its console (default) + # Note that the console of this child process might not be the same as the running R process. + system2(script, combinedArgs, stdout = "", wait = wait) } }