This is an automated email from the ASF dual-hosted git repository. markd pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/systemds.git
commit 981b1e5b6832a9680effb88900550025f2221acf Author: Mark Dokter <[email protected]> AuthorDate: Tue Nov 17 00:41:38 2020 +0100 [MINOR] Fix R execution on Windows when using R version 4.0 --- .../java/org/apache/sysds/test/AutomatedTestBase.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/test/java/org/apache/sysds/test/AutomatedTestBase.java b/src/test/java/org/apache/sysds/test/AutomatedTestBase.java index 1e62975..3ae6eea 100644 --- a/src/test/java/org/apache/sysds/test/AutomatedTestBase.java +++ b/src/test/java/org/apache/sysds/test/AutomatedTestBase.java @@ -1040,11 +1040,7 @@ public abstract class AutomatedTestBase { "Rscript --default-packages=methods,datasets,graphics,grDevices,stats,utils"); // *** END HACK *** } - - if(System.getProperty("os.name").contains("Windows")) { - cmd = cmd.replace('/', '\\'); - executionFile = executionFile.replace('/', '\\'); - } + if(DEBUG) { if(!newWay) { // not sure why have this condition TestUtils.printRScript(executionFile); @@ -1075,6 +1071,16 @@ public abstract class AutomatedTestBase { String outputR; String errorString; try { + // if R < 4.0 on Windows is used, the file separator needs to be Windows style + if(System.getProperty("os.name").contains("Windows")) { + Process r_ver_cmd = Runtime.getRuntime().exec("RScript --version"); + String r_ver = IOUtils.toString(r_ver_cmd.getErrorStream()); + if(!r_ver.contains("4.0")) { + cmd = cmd.replace('/', '\\'); + executionFile = executionFile.replace('/', '\\'); + } + } + long t0 = System.nanoTime(); if(LOG.isInfoEnabled()) { LOG.info("starting R script");
