8042830: A recently added Xprefer test fails on Windows
authoralundblad
Thu, 12 Jun 2014 14:29:09 +0200
changeset 25005 645284cd7d1d
parent 25004 b33effe4f252
child 25006 5d5fa4abab27
8042830: A recently added Xprefer test fails on Windows Summary: Test now accepts both / and \ as file separator. Reviewed-by: mcimadamore
langtools/test/tools/javac/options/xprefer/XPreferTest.java
--- a/langtools/test/tools/javac/options/xprefer/XPreferTest.java	Thu May 22 12:16:53 2014 -0700
+++ b/langtools/test/tools/javac/options/xprefer/XPreferTest.java	Thu Jun 12 14:29:09 2014 +0200
@@ -26,7 +26,6 @@
  * @summary Tests which path is used to represent an implicit type given
  * various xprefer arguments and multiple .class / .java files involved.
  * @bug 8028196
- * @ignore 8042839 XPreferTest fails on Windows
  */
 
 import java.io.File;
@@ -42,6 +41,7 @@
 import java.util.ListIterator;
 import java.util.NoSuchElementException;
 import java.util.Scanner;
+import java.util.regex.Pattern;
 
 import javax.tools.JavaCompiler;
 import javax.tools.JavaCompiler.CompilationTask;
@@ -180,10 +180,16 @@
             Scanner s = new Scanner(compilerOutput);
             while (s.hasNextLine()) {
                 String line = s.nextLine();
-                if (line.matches("\\[loading .*\\]"))
-                    for (Dir dir : Dir.values())
-                        if (line.contains(dir.file.getName() + "/" + classId))
+                if (line.matches("\\[loading .*\\]")) {
+                    for (Dir dir : Dir.values()) {
+                        // On Windows all paths are printed with '/' except
+                        // paths inside zip-files, which are printed with '\'.
+                        // For this reason we accept both '/' and '\' below.
+                        String regex = dir.file.getName() + "[\\\\/]" + classId;
+                        if (Pattern.compile(regex).matcher(line).find())
                             return dir;
+                    }
+                }
             }
             return null;
         }