]> source.dussan.org Git - aspectj.git/commitdiff
javarun attributes for interpreting error/output streams as errors, used only when...
authorwisberg <wisberg>
Mon, 2 Jun 2003 05:23:53 +0000 (05:23 +0000)
committerwisberg <wisberg>
Mon, 2 Jun 2003 05:23:53 +0000 (05:23 +0000)
testing/src/org/aspectj/testing/harness/bridge/JavaRun.java
testing/src/org/aspectj/testing/xml/AjcSpecXmlReader.java
testing/testsrc/org/aspectj/testing/harness/bridge/AjcSpecTest.java
tests/ajcTestSuite.dtd

index 43c5db4c97c9b1aae05c749e161944b5edbd8d4f..76785b464151a423c7fcbded35e2a6f89dc34fb2 100644 (file)
@@ -143,6 +143,13 @@ public class JavaRun implements IAjcRun {
         ClassLoader loader = null;
         URL[] urls = FileUtil.getFileURLs(libs);
         boolean completedNormally = false;
+        if (spec.outStreamIsError) {
+            // XXX implement same-vm stream snooping
+            // strictly speaking, also warn for errStream, but 
+            // it is on by default (in same-VM, Tester controls;
+            // in other-vm stream-snooping controls)
+            MessageUtil.info(status, "unimplemented: stream-based error implemented in same vm");
+        }
         Class targetClass = null;
         try {
             loader = new TestClassLoader(urls, dirs);
@@ -281,7 +288,10 @@ public class JavaRun implements IAjcRun {
         commandLabel.append(Arrays.asList(controller.getCommand()).toString());
         final ByteArrayOutputStream errSnoop 
             = new ByteArrayOutputStream();
+        final ByteArrayOutputStream outSnoop 
+            = new ByteArrayOutputStream();
         controller.setErrSnoop(errSnoop);
+        controller.setOutSnoop(outSnoop);
         controller.start();
         // give it 3 minutes...
         long maxTime = System.currentTimeMillis() + 3 * 60 * 1000;
@@ -305,10 +315,24 @@ public class JavaRun implements IAjcRun {
             }
         }
         if (0 < errSnoop.size()) {
-            MessageUtil.error(handler, errSnoop.toString());
-            if (!doneFlag.failed) {
-                doneFlag.failed = true;
-            } 
+            if (spec.errStreamIsError) {
+                MessageUtil.error(handler, errSnoop.toString());
+                if (!doneFlag.failed) {
+                    doneFlag.failed = true;
+                } 
+            } else {
+                MessageUtil.info(handler, "Error stream: " + errSnoop.toString());
+            }
+        }
+        if (0 < outSnoop.size()) {
+            if (spec.outStreamIsError) {
+                MessageUtil.error(handler, outSnoop.toString());
+                if (!doneFlag.failed) {
+                    doneFlag.failed = true;
+                } 
+            } else {
+                MessageUtil.info(handler, "Output stream: " + outSnoop.toString());
+            }
         }
         if (doneFlag.failed) {
             MessageUtil.info(handler, "other-vm command-line: " + commandLabel);
@@ -409,6 +433,12 @@ public class JavaRun implements IAjcRun {
         /** if true, skip Tester setup (e.g., if Tester n/a) */
         protected boolean skipTester;
         
+        /** if true, report text to output stream as error */
+        protected boolean outStreamIsError;
+
+        /** if true, report text to error stream as error */
+        protected boolean errStreamIsError = true;
+        
         public Spec() {
             super(XMLNAME);
             setXMLNames(NAMES);
@@ -428,6 +458,14 @@ public class JavaRun implements IAjcRun {
             this.className = className;
         }
         
+        public void setErrStreamIsError(boolean errStreamIsError) {
+            this.errStreamIsError = errStreamIsError;
+        }
+
+        public void setOutStreamIsError(boolean outStreamIsError) {
+            this.outStreamIsError = outStreamIsError;
+        }
+
         /** @param skip if true, then do not set up Tester */
         public void setSkipTester(boolean skip) {
             skipTester = skip;
@@ -467,6 +505,12 @@ public class JavaRun implements IAjcRun {
             if (null != javaVersion) {
                 out.printAttribute("vm", javaVersion);
             }
+            if (outStreamIsError) {
+                out.printAttribute("outStreamIsError", "true");
+            }
+            if (!errStreamIsError) { // defaults to true
+                out.printAttribute("errStreamIsError", "false");
+            }
             super.writeAttributes(out);
             out.endAttributes();
             if (!LangUtil.isEmpty(dirChanges)) {
index 9736486c1d4ade0318afb33b2360de7ccbf0688d..63d324149d77567c0bbbd7665a4042ae247e1f27 100644 (file)
@@ -395,7 +395,9 @@ public class AjcSpecXmlReader {
         jrunspec.addMessage((IMessage) null);
         // input s.b. interpretable by Boolean.valueOf(String)
         jrunspec.setSkipTester(true); 
-
+        jrunspec.setErrStreamIsError(true);
+        jrunspec.setOutStreamIsError(true);
+        
         DirChanges.Spec dcspec = new DirChanges.Spec();
         dcspec.setAdded((String) null);
         dcspec.setRemoved((String) null);
index 2110fbe45afbeb0ab6e90eac56219ea384b4c97e..2c3c46e98be517cbcbe5e5fd9f08d48d1ea1efc8 100644 (file)
@@ -219,6 +219,8 @@ public class AjcSpecTest extends TestCase {
             assertEquals(l.className, r.className);
             assertEquals(l.javaVersion, r.javaVersion);
             assertEquals(l.skipTester, r.skipTester);
+            assertEquals(l.outStreamIsError, r.outStreamIsError);
+            assertEquals(l.errStreamIsError, r.errStreamIsError);
         } else if (c == IncCompilerRun.class) {
             IncCompilerRun.Spec l = ((IncCompilerRun) lhs).spec;
             IncCompilerRun.Spec r = ((IncCompilerRun) rhs).spec;
index fd512974ce9faa0b16855826e5bd8f3f2f989e2f..c0fdc49a724c558b1b071c30ac2c234d60f484c5 100644 (file)
@@ -33,6 +33,8 @@
    <!ATTLIST run skipTester CDATA #IMPLIED >\r
    <!ATTLIST run vm CDATA #IMPLIED >\r
    <!ATTLIST run options CDATA #IMPLIED >\r
+   <!ATTLIST run errStreamIsError CDATA #IMPLIED >\r
+   <!ATTLIST run outStreamIsError CDATA #IMPLIED >\r
 \r
    <!ELEMENT file (#PCDATA)>\r
    <!ATTLIST file path CDATA #IMPLIED >\r