ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 16748] New: - BuildFileTest does not capture output and error streams properly.
Date Tue, 04 Feb 2003 06:41:19 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16748>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16748

BuildFileTest does not capture output and error streams properly.

           Summary: BuildFileTest does not capture output and error streams
                    properly.
           Product: Ant
           Version: 1.5.1
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Other
        AssignedTo: ant-dev@jakarta.apache.org
        ReportedBy: JPMcGrath@JPMcGrath.net


The BuildFileTest class stores output captured from System.err to outBuffer
rather than to errBuffer.  As a result, getError() always returns an empty
string and getOutput() includes the test written to System.err.

This patch will fix the problem:

--- source/org/apache/tools/ant/BuildFileTest.java  4 Feb 2003 05:25:13 -0000   1.1
+++ source/org/apache/tools/ant/BuildFileTest.java  4 Feb 2003 05:41:47 -0000   1.2
@@ -243,10 +243,10 @@
             sysOut.flush();
             sysErr.flush();
             outBuffer = new StringBuffer();
-            PrintStream out = new PrintStream(new AntOutputStream());
+            PrintStream out = new PrintStream(new AntOutputStream(outBuffer));
             System.setOut(out);
             errBuffer = new StringBuffer();
-            PrintStream err = new PrintStream(new AntOutputStream());
+            PrintStream err = new PrintStream(new AntOutputStream(errBuffer));
             System.setErr(err);
             logBuffer = new StringBuffer();
             fullLogBuffer = new StringBuffer();
@@ -383,8 +383,12 @@
      * an output stream which saves stuff to our buffer.
      */
     private class AntOutputStream extends java.io.OutputStream {
+        private StringBuffer buffer;
+        public AntOutputStream( StringBuffer buffer ) {
+            this.buffer = buffer;
+        }
         public void write(int b) { 
-            outBuffer.append((char)b);
+            buffer.append((char)b);
         }
     }

Mime
View raw message