You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2016/06/07 22:46:38 UTC

svn commit: r1747324 - /commons/proper/bcel/trunk/src/test/java/org/apache/bcel/util/BCELifierTestCase.java

Author: sebb
Date: Tue Jun  7 22:46:38 2016
New Revision: 1747324

URL: http://svn.apache.org/viewvc?rev=1747324&view=rev
Log:
Fix ignored test case by canonicalising the javap output

Modified:
    commons/proper/bcel/trunk/src/test/java/org/apache/bcel/util/BCELifierTestCase.java

Modified: commons/proper/bcel/trunk/src/test/java/org/apache/bcel/util/BCELifierTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/util/BCELifierTestCase.java?rev=1747324&r1=1747323&r2=1747324&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/bcel/util/BCELifierTestCase.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/bcel/util/BCELifierTestCase.java Tue Jun  7 22:46:38 2016
@@ -29,7 +29,6 @@ public class BCELifierTestCase {
      * TODO: detect if JDK present and skip test if not 
      */
     @Test
-    @org.junit.Ignore // does not work properly on some systems. Also the output is rather different 
     public void testJavapCompare() throws Exception {
         testClassOnPath("target/test-classes/Java8Example.class");
     }
@@ -50,7 +49,15 @@ public class BCELifierTestCase {
         exec(workDir, "javac", "-cp", "classes", outfile.getName());
         exec(workDir, "java", "-cp", ".:classes", outfile.getName().replace(".java", ""));
         final String output = exec(workDir, "javap", "-p", "-c", infile.getName());
-        assertEquals(initial, output);
+        assertEquals(canonHashRef(initial), canonHashRef(output));
+    }
+
+    // Canonicalise the javap output so it compares better
+    private String canonHashRef(String input) {
+        input = input.replaceAll("#\\d+", "#n"); // numbers may vary in length
+        input = input.replaceAll(" +", " "); // collapse spaces
+        input = input.replaceAll("//.+",""); // comments may vary
+        return input;
     }
 
     private String exec(final File workDir, final String ... args) throws Exception {