ASF Bugzilla – Attachment 20948 Details for
Bug 43582
Write log messages from test to AntUnit's log
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to implement this feature
bug43582.patch (text/plain), 2.81 KB, created by
David Jackman
on 2007-10-09 14:12:07 UTC
(
hide
)
Description:
Patch to implement this feature
Filename:
MIME Type:
Creator:
David Jackman
Created:
2007-10-09 14:12:07 UTC
Size:
2.81 KB
patch
obsolete
>Index: src/etc/testcases/antunit.xml >=================================================================== >--- src/etc/testcases/antunit.xml (revision 581771) >+++ src/etc/testcases/antunit.xml (working copy) >@@ -56,6 +56,12 @@ > </au:antunit> > </target> > >+ <target name="echo"> >+ <au:antunit> >+ <file file="antunit/echo.xml"/> >+ </au:antunit> >+ </target> >+ > <target name="testNoPropertySet"> > <au:antunit> > <file file="antunit/echo.xml"/> >Index: src/main/org/apache/ant/antunit/AntUnit.java >=================================================================== >--- src/main/org/apache/ant/antunit/AntUnit.java (revision 581771) >+++ src/main/org/apache/ant/antunit/AntUnit.java (working copy) >@@ -404,6 +404,7 @@ > } > p.setUserProperty(MagicNames.ANT_FILE, f.getAbsolutePath()); > attachListeners(f, p); >+ p.addBuildListener(new AntUnitLogListener()); > > // read build file > ProjectHelper.configureProject(p, f); >@@ -506,4 +507,23 @@ > public void messageLogged(BuildEvent event) {} > } > >+ /** >+ * Routes log messages from the test projects to the running log. >+ */ >+ private class AntUnitLogListener implements BuildListener { >+ >+ public void buildFinished(BuildEvent event) {} >+ public void buildStarted(BuildEvent event) {} >+ public void targetFinished(BuildEvent event) {} >+ public void targetStarted(BuildEvent event) {} >+ public void taskFinished(BuildEvent event) {} >+ public void taskStarted(BuildEvent event) {} >+ >+ public void messageLogged(BuildEvent event) { >+ // Write to either verbose or debug levels >+ int level = (event.getPriority() >= Project.MSG_DEBUG) ? event.getPriority() : Project.MSG_VERBOSE; >+ log(event.getMessage(), level); >+ } >+ >+ } > } >Index: src/tests/junit/org/apache/ant/antunit/AntUnitTest.java >=================================================================== >--- src/tests/junit/org/apache/ant/antunit/AntUnitTest.java (revision 581771) >+++ src/tests/junit/org/apache/ant/antunit/AntUnitTest.java (working copy) >@@ -20,6 +20,7 @@ > package org.apache.ant.antunit; > > import org.apache.tools.ant.BuildFileTest; >+import org.apache.tools.ant.Project; > > public class AntUnitTest extends BuildFileTest { > >@@ -88,4 +89,12 @@ > executeTarget("testNewProject"); > } > >+ public void testLogToVerbose() { >+ configureProject("src/etc/testcases/antunit.xml", Project.MSG_VERBOSE); >+ executeTarget("echo"); >+ String log = getLog(); >+ assertTrue("Info level AntUnit output shouldn't contain test output.", log.indexOf("ant.jar") == -1); >+ String fullLog = getFullLog(); >+ assertTrue("Verbose level AntUnit output should contain test output.", fullLog.indexOf("ant.jar") > -1); >+ } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 43582
: 20948