changeset 3402:c2d589333410

8042830: A recently added Xprefer test fails on Windows Summary: Test now accepts both / and \ as file separator. Reviewed-by: mcimadamore
author alundblad
date Thu, 12 Jun 2014 14:29:09 +0200
parents 017098c7fa18
children 220bfc92607e
files test/tools/javac/options/xprefer/XPreferTest.java
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/test/tools/javac/options/xprefer/XPreferTest.java	Thu May 22 12:16:53 2014 -0700
+++ b/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;
         }