Bug 56470 - AntUnits logcontent task returns a one line log string
Summary: AntUnits logcontent task returns a one line log string
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: AntUnit (show other bugs)
Version: 1.2
Hardware: PC All
: P2 normal (vote)
Target Milestone: 1.3
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-29 10:19 UTC by Chris Holman
Modified: 2014-05-07 04:07 UTC (History)
0 users



Attachments
Patch file for LogCapturer.java (1.50 KB, text/plain)
2014-04-29 10:19 UTC, Chris Holman
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Holman 2014-04-29 10:19:35 UTC
Created attachment 31569 [details]
Patch file for LogCapturer.java

The logcontent task outputs the log on one single line.

Using the following in the AntUnit test:

<project> 
...
	<target name="tearDown">
		<echo>This line has no EOL character appended...</echo>
		<echo>So this is on the same line in the log file</echo>
		<!-- Write to logfile -->
		<concat destfile="${logfile}" fixlastline="yes">
			<au:logcontent/>
		</concat>		
	</target>
</project>

This can be easily fixed in: org.apache.ant.antunit.LogCapturer

There is a SVN patch attached that adds a LINE_SEPARATOR to the end of each log entry in the LogCapturer.messageLogged method.
Comment 1 Stefan Bodewig 2014-05-02 16:54:35 UTC
changes similar to your patch have been committed as svn revision 1591972

I'd like to wait for the Gump run to determine whether an option to insert line breaks is needed.
Comment 2 Stefan Bodewig 2014-05-04 04:57:11 UTC
One test inside Ant's own testsuite fails, this is because it tests the order of two adjacent log messages - something you cannot do with separate assertLogContains assertions. [1]

I'd add an attribute to assertLogContains and the logcontent resource - mergeLines with default true? - and modify LogCapturer to provide logs with and without merged lines.

[1] testRedirector14 in src/tests/antunit/taskdefs/exec/apply-test.xml
Comment 3 Stefan Bodewig 2014-05-07 04:07:36 UTC
added mergeLines in several places and retained backwards compatibility.