Return-Path: Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 8995 invoked from network); 4 Feb 2003 06:39:41 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 4 Feb 2003 06:39:41 -0000 Received: (qmail 17752 invoked by uid 50); 4 Feb 2003 06:41:19 -0000 Date: 4 Feb 2003 06:41:19 -0000 Message-ID: <20030204064119.17751.qmail@nagoya.betaversion.org> From: bugzilla@apache.org To: ant-dev@jakarta.apache.org Cc: Subject: DO NOT REPLY [Bug 16748] New: - BuildFileTest does not capture output and error streams properly. X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT . 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); } }