]> source.dussan.org Git - aspectj.git/commitdiff
Bug 153772 "Support stdout/stderr specifications for the ant compiler test step"
authormwebster <mwebster>
Mon, 14 Aug 2006 15:52:16 +0000 (15:52 +0000)
committermwebster <mwebster>
Mon, 14 Aug 2006 15:52:16 +0000 (15:52 +0000)
testing/newsrc/org/aspectj/testing/AntSpec.java

index ca95b4e26320c8992d10350457c659a0832f9e06..8ea86cdb5e5d75c05998cfee357e9d028feabaf0 100644 (file)
@@ -17,6 +17,8 @@ import org.apache.tools.ant.ProjectHelper;
 import org.apache.tools.ant.DefaultLogger;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.BuildEvent;
+import org.apache.tools.ant.Target;
+import org.apache.tools.ant.taskdefs.Java;
 import org.apache.tools.ant.types.Path;
 
 import java.io.File;
@@ -109,13 +111,17 @@ public class AntSpec implements ITestStep {
                     }
                 }
                 public void messageLogged(BuildEvent event) {
-                    super.messageLogged(event);
-                    if (event.getTarget() != null && event.getPriority() >= Project.MSG_INFO && m_antTarget.equals(event.getTarget().getName())) {
-                        if (event.getException() == null) {
-                            stdout.append(event.getMessage()).append('\n');
-                        } else {
-                            stderr.append(event.getMessage());
-                        }
+                       super.messageLogged(event);
+                    
+                       Target target = event.getTarget();
+                    if (target != null && m_antTarget.equals(target.getName()) && event.getSource() instanceof Java)
+                       switch(event.getPriority()) {
+                       case Project.MSG_INFO:
+                               stdout.append(event.getMessage()).append('\n');
+                               break;
+                       case Project.MSG_WARN:
+                               stderr.append(event.getMessage()).append('\n');
+                               break;
                     }
                 }
             };
@@ -136,14 +142,13 @@ public class AntSpec implements ITestStep {
             AjcTestCase.fail(failMessage + "error when invoking target :" + t.toString());
         }
 
-        // match lines
-        //TODO AV experimental: requires full match so rather useless.
-        // if someone needs it, we ll have to impl a "include / exclude" stuff
-        if (m_stdOutSpec != null)
+        /* See if stdout/stderr matches test specification */
+        if (m_stdOutSpec != null) {
             m_stdOutSpec.matchAgainst(stdout.toString());
-        // match lines
-        if (m_stdErrSpec != null)
-            m_stdErrSpec.matchAgainst(stdout.toString());
+        }
+        if (m_stdErrSpec != null) {
+            m_stdErrSpec.matchAgainst(stderr.toString());
+        }
     }
 
     public void addStdErrSpec(OutputSpec spec) {