This is an automated email from the ASF dual-hosted git repository.

baunsgaard pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/systemds.git


The following commit(s) were added to refs/heads/master by this push:
     new b7ddd57  [SYSTEMDS-2786] outputBuffering correctly for R Scripts in 
Tests
b7ddd57 is described below

commit b7ddd5764854def8a84d093312f5a895b07eaa6e
Author: baunsgaard <[email protected]>
AuthorDate: Mon Jan 4 22:12:46 2021 +0100

    [SYSTEMDS-2786] outputBuffering correctly for R Scripts in Tests
    
    This commit change the outputBuffering to also effect the R scripts
    correctly. Such that when the outputBuffering is enabled then no
    output is printed from R except in cases where the test fail because of
    the R script. If the outputBuffering is disabled then all output from R
    is printed after the R execution is done.
---
 .../org/apache/sysds/test/AutomatedTestBase.java   | 23 +++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/src/test/java/org/apache/sysds/test/AutomatedTestBase.java 
b/src/test/java/org/apache/sysds/test/AutomatedTestBase.java
index 98c6b79..0143fed 100644
--- a/src/test/java/org/apache/sysds/test/AutomatedTestBase.java
+++ b/src/test/java/org/apache/sysds/test/AutomatedTestBase.java
@@ -1182,22 +1182,17 @@ public abstract class AutomatedTestBase {
 
                        outputR = IOUtils.toString(child.getInputStream());
                        errorString = IOUtils.toString(child.getErrorStream());
-                       if(LOG.isTraceEnabled()) {
-                               LOG.trace("Standard Output from R:" + outputR);
-                               LOG.trace("Standard Error from R:" + 
errorString);
-                       }
-
+                       
                        //
                        // To give any stream enough time to print all data, 
otherwise there
                        // are situations where the test case fails, even 
before everything
                        // has been printed
                        //
                        child.waitFor();
-
                        try {
                                if(child.exitValue() != 0) {
                                        throw new Exception(
-                                               "ERROR: R has ended 
irregularly\n" + outputR + "\nscript file: " + executionFile);
+                                               "ERROR: R has ended 
irregularly\n" + buildOutputStringR(outputR, errorString) + "\nscript file: " + 
executionFile);
                                }
                        }
                        catch(IllegalThreadStateException ie) {
@@ -1207,6 +1202,10 @@ public abstract class AutomatedTestBase {
                                child.destroy();
                        }
 
+                       if(!outputBuffering) {
+                               System.out.println(buildOutputStringR(outputR, 
errorString));
+                       }
+
                        long t1 = System.nanoTime();
 
                        LOG.info("R is finished (in " + ((double) t1 - t0) / 
1000000000 + " sec)");
@@ -1232,6 +1231,16 @@ public abstract class AutomatedTestBase {
                }
        }
 
+       private static String buildOutputStringR(String standardOut, String 
standardError){
+               StringBuilder sb = new StringBuilder();
+               sb.append("R Standard output :\n");
+               sb.append(standardOut);
+               sb.append("\nR Standard Error  :\n");
+               sb.append(standardError);
+               sb.append("\n");
+               return sb.toString();
+       }
+
        /**
         * <p>
         * Runs a test for which no exception is expected.

Reply via email to