8154149: tools/javac/unit/T6198196.java broken on Windows after JDK-8150641
Avoiding interference among sub-tests due to CacheFSInfo by using a new file manager for each sub-test Reviewed-by: jjg
This commit is contained in:
parent
2471896266
commit
5cc78b2a2b
@ -36,34 +36,31 @@ import javax.tools.*;
|
||||
|
||||
public class T6198196 {
|
||||
static String pkginf = "package-info";
|
||||
static StandardJavaFileManager fm;
|
||||
static void test(String pathname, String filename, boolean result) {
|
||||
JavaFileObject fo;
|
||||
fo = fm.getJavaFileObjectsFromStrings(Arrays.asList(pathname)).iterator().next();
|
||||
if (result != fo.isNameCompatible(filename, JavaFileObject.Kind.SOURCE))
|
||||
throw new AssertionError("endsWith(" + pathname + ", "
|
||||
+ filename + ") != " + result);
|
||||
System.out.format("OK: endsWith(%s, %s) = %s%n", pathname, filename, result);
|
||||
}
|
||||
public static void main(String[] args) throws IOException {
|
||||
fm = ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null);
|
||||
try {
|
||||
boolean windows = System.getProperty("os.name").startsWith("Windows");
|
||||
test("/x/y/z/package-info.java", pkginf, true);
|
||||
if (windows) {
|
||||
test("\\x\\y\\z\\package-info.java", pkginf, true);
|
||||
test("..\\x\\y\\z\\package-info.java", pkginf, true);
|
||||
} else {
|
||||
test("\\x\\y\\z\\package-info.java", pkginf, false);
|
||||
test("..\\x\\y\\z\\package-info.java", pkginf, false);
|
||||
}
|
||||
test("Package-info.java", pkginf, false);
|
||||
test("../x/y/z/package-info.java", pkginf, true);
|
||||
test("/x/y/z/package-info.java", pkginf, true);
|
||||
test("x/y/z/package-info.java", pkginf, true);
|
||||
test("package-info.java", pkginf, true);
|
||||
} finally {
|
||||
fm.close();
|
||||
static void test(String pathname, String filename, boolean result) throws IOException {
|
||||
try (StandardJavaFileManager fm =
|
||||
ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null)) {
|
||||
JavaFileObject fo =
|
||||
fm.getJavaFileObjectsFromStrings(Arrays.asList(pathname)).iterator().next();
|
||||
if (result != fo.isNameCompatible(filename, JavaFileObject.Kind.SOURCE))
|
||||
throw new AssertionError("endsWith(" + pathname + ", "
|
||||
+ filename + ") != " + result);
|
||||
System.out.format("OK: endsWith(%s, %s) = %s%n", pathname, filename, result);
|
||||
}
|
||||
}
|
||||
public static void main(String[] args) throws IOException {
|
||||
boolean windows = System.getProperty("os.name").startsWith("Windows");
|
||||
test("/x/y/z/package-info.java", pkginf, true);
|
||||
if (windows) {
|
||||
test("\\x\\y\\z\\package-info.java", pkginf, true);
|
||||
test("..\\x\\y\\z\\package-info.java", pkginf, true);
|
||||
} else {
|
||||
test("\\x\\y\\z\\package-info.java", pkginf, false);
|
||||
test("..\\x\\y\\z\\package-info.java", pkginf, false);
|
||||
}
|
||||
test("Package-info.java", pkginf, false);
|
||||
test("../x/y/z/package-info.java", pkginf, true);
|
||||
test("/x/y/z/package-info.java", pkginf, true);
|
||||
test("x/y/z/package-info.java", pkginf, true);
|
||||
test("package-info.java", pkginf, true);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user