changeset 1144:0de334030a48

jmh-core-ct: separate the test source from the error messages, otherwise assert text always matches
author shade
date Tue, 03 Mar 2015 21:24:10 +0300
parents 4c15defe2406
children 71611fa284a5
files jmh-core-ct/src/test/java/org/openjdk/jmh/ct/CompileTest.java
diffstat 1 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/CompileTest.java	Tue Mar 03 13:42:49 2015 +0300
+++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/CompileTest.java	Tue Mar 03 21:24:10 2015 +0300
@@ -48,12 +48,15 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.List;
 import java.util.Map;
 
 public class CompileTest {
 
     private static final String GENERATOR_TYPE = System.getProperty("jmh.ct.generator", "notset");
 
+    private static final String SRC_PREFIX = "SRC: ";
+
     public static void assertFail(Class<?> klass) {
         InMemoryGeneratorDestination destination = new InMemoryGeneratorDestination();
         boolean success = doTest(klass, destination);
@@ -69,12 +72,16 @@
             Assert.fail("Should have failed.");
         }
 
+        List<String> testErrors = new ArrayList<String>();
         boolean contains = false;
         for (String e : destination.getErrors()) {
+            if (!e.startsWith(SRC_PREFIX)) {
+                testErrors.add(e);
+                contains |= e.contains(error);
+            }
             System.err.println(e);
-            contains |= e.contains(error);
         }
-        Assert.assertTrue("Failure message should contain \"" + error + "\", but was \"" + destination.getErrors() + "\"", contains);
+        Assert.assertTrue("Failure message should contain \"" + error + "\", but was \"" + testErrors + "\"", contains);
     }
 
     public static void assertOK(Class<?> klass) {
@@ -144,7 +151,7 @@
 
         if (!success) {
             for (JavaSourceFromString src : sources) {
-                destination.printError(src.getCharContent(false).toString());
+                destination.printError(SRC_PREFIX + src.getCharContent(false).toString());
             }
             for (Diagnostic diagnostic : diagnostics.getDiagnostics()) {
                 destination.printError(diagnostic.getKind() + " at line " + diagnostic.getLineNumber() + ": " + diagnostic.getMessage(null));
@@ -183,7 +190,7 @@
 
             if (!success) {
                 for (JavaSourceFromString src : sources) {
-                    destination.printError(src.getCharContent(false).toString());
+                    destination.printError(SRC_PREFIX + src.getCharContent(false).toString());
                 }
                 for (Diagnostic diagnostic : diagnostics.getDiagnostics()) {
                     destination.printError(diagnostic.getKind() + " at line " + diagnostic.getLineNumber() + ": " + diagnostic.getMessage(null));