8283606: Tests may fail with zh locale on MacOS

Reviewed-by: iklam, rriggs
This commit is contained in:
Vikey Chen 2022-05-05 00:06:24 +00:00 committed by Ioi Lam
parent 158d871d05
commit 7d545084f4
9 changed files with 37 additions and 23 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -50,7 +50,8 @@ public class TestEmptyBootstrapMethodsAttr {
// ======= execute test case #1
// Expect a lack of main method, this implies that the class loaded correctly
// with an empty bootstrap_methods and did not generate a ClassFormatError.
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(className);
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-Duser.language=en", "-Duser.country=US", className);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldNotContain("java.lang.ClassFormatError");
output.shouldContain("Main method not found in class " + className);
@ -64,7 +65,8 @@ public class TestEmptyBootstrapMethodsAttr {
// ======= execute test case #2
// Expect a lack of main method, this implies that the class loaded correctly
// with an empty bootstrap_methods and did not generate ClassFormatError.
pb = ProcessTools.createJavaProcessBuilder(className);
pb = ProcessTools.createJavaProcessBuilder(
"-Duser.language=en", "-Duser.country=US", className);
output = new OutputAnalyzer(pb.start());
output.shouldNotContain("java.lang.ClassFormatError");
output.shouldContain("Main method not found in class " + className);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -56,6 +56,8 @@ public class TestStdDoclet {
List<String> cmdArgs = new ArrayList<>();
cmdArgs.add(javadoc.getPath());
cmdArgs.addAll(Arrays.asList(
"-J-Duser.language=en",
"-J-Duser.country=US",
"-classpath", ".", // insulates us from ambient classpath
"-Xdoclint:none",
"-package",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -69,6 +69,8 @@ public class TestUserDoclet implements Doclet {
List<String> cmdArgs = new ArrayList<>();
cmdArgs.add(javadoc.getPath());
cmdArgs.addAll(Arrays.asList(
"-J-Duser.language=en",
"-J-Duser.country=US",
"-doclet", thisClassName,
"-docletpath", testClasses.getPath(),
new File(testSrc, thisClassName + ".java").getPath()

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -106,7 +106,8 @@ public class EnsureNewOldDoclet extends TestRunner {
// outcome: new tool and new doclet
@Test
public void testDefault() throws Exception {
setArgs("-classpath", ".", // insulates us from ambient classpath
setArgs("-J-Duser.language=en", "-J-Duser.country=US",
"-classpath", ".", // insulates us from ambient classpath
testSrc.toString());
Task.Result tr = task.run(Task.Expect.SUCCESS);
List<String> err = tr.getOutputLines(Task.OutputKind.STDERR);
@ -117,7 +118,9 @@ public class EnsureNewOldDoclet extends TestRunner {
// outcome: new doclet and new taglet should register
@Test
public void testNewDocletNewTaglet() throws Exception {
setArgs("-classpath", ".", // ambient classpath insulation
setArgs("-J-Duser.language=en",
"-J-Duser.country=US",
"-classpath", ".", // ambient classpath insulation
"-doclet",
NEW_STDDOCLET,
"-taglet",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -242,6 +242,9 @@ public class TestLocaleOption extends TestRunner {
options.add("-J-Duser.language=" + defaultLocale.getLanguage());
options.add("-J-Duser.country=" + defaultLocale.getCountry());
options.add("-J-Duser.variant=" + defaultLocale.getVariant());
} else {
options.add("-J-Duser.language=en");
options.add("-J-Duser.country=us");
}
if (localeOption != null) {
options.addAll(List.of("-locale", localeOption.toString()));

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -125,7 +125,7 @@ public class ClassPathWithDoubleQuotesTest extends TestRunner {
"and for which they are a legal filename character");
List<String> log = new JavacTask(tb, Task.Mode.EXEC)
.envVar("CLASSPATH", "Ztest/jarOut/J.jar" + File.pathSeparator + "test/srcZ")
.options("-XDrawDiagnostics")
.options("-XDrawDiagnostics", "-J-Duser.language=en", "-J-Duser.country=US")
.files("test/src/A.java").run(Task.Expect.FAIL)
.writeAll()
.getOutputLines(Task.OutputKind.STDERR);
@ -138,7 +138,7 @@ public class ClassPathWithDoubleQuotesTest extends TestRunner {
System.err.println("invoking javac EXEC mode with double quotes in the CLASSPATH env variable");
List<String> log2 = new JavacTask(tb, Task.Mode.EXEC)
.envVar("CLASSPATH", "\"test/jarOut/J.jar" + File.pathSeparator + "test/src\"")
.options("-Xlint:path", "-XDrawDiagnostics")
.options("-Xlint:path", "-XDrawDiagnostics", "-J-Duser.language=en", "-J-Duser.country=US")
.files("test/src/A.java").run(Task.Expect.FAIL)
.writeAll()
.getOutputLines(Task.OutputKind.STDERR);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -206,6 +206,7 @@ public class OptionSmokeTest extends TestRunner {
List<String> log = new JavacTask(tb, Task.Mode.EXEC)
.envVar("JDK_JAVAC_OPTIONS",
String.format("--add-exports jdk.compiler%scom.sun.tools.javac.jvm=\"ALL-UNNAMED", fileSeparator))
.options("-J-Duser.language=en", "-J-Duser.country=US")
.files(findJavaFiles(src))
.run(Task.Expect.FAIL)
.writeAll()

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -131,7 +131,8 @@ public class PlatformProviderTest implements PlatformProvider {
Task.Result result =
new JavacTask(tb, Task.Mode.EXEC)
.outdir(".")
.options("-J--class-path=" + System.getProperty("test.classes"),
.options("-J-Duser.language=en", "-J-Duser.country=US",
"-J--class-path=" + System.getProperty("test.classes"),
"-J--add-exports=jdk.compiler/com.sun.tools.javac.platform=ALL-UNNAMED",
"-J--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
"--release",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -80,10 +80,10 @@ public class MultiReleaseJar {
@Test
public void basic() throws Exception {
Result r = run("jdeps --multi-release 9 -v missing.jar");
Result r = run("jdeps -J-Duser.language=en -J-Duser.country=US --multi-release 9 -v missing.jar");
checkResult(r, false, "Warning: Path does not exist: missing.jar");
r = run("jdeps -v Version.jar");
r = run("jdeps -J-Duser.language=en -J-Duser.country=US -v Version.jar");
checkResult(r, false, "--multi-release option is not set");
r = run("jdeps --multi-release base -v Version.jar");
@ -115,10 +115,10 @@ public class MultiReleaseJar {
"9/test.NonPublic"
);
r = run("jdeps --multi-release 8 -v Version.jar");
r = run("jdeps -J-Duser.language=en -J-Duser.country=US --multi-release 8 -v Version.jar");
checkResult(r, false, "Error: invalid argument for option: 8");
r = run("jdeps --multi-release 9.1 -v Version.jar");
r = run("jdeps -J-Duser.language=en -J-Duser.country=US --multi-release 9.1 -v Version.jar");
checkResult(r, false, "Error: invalid argument for option: 9.1");
runJdeps("Main.class");
@ -127,10 +127,10 @@ public class MultiReleaseJar {
private void runJdeps(String path) throws Exception {
Result r = run("jdeps -v -R -cp Version.jar " + path);
Result r = run("jdeps -J-Duser.language=en -J-Duser.country=US -v -R -cp Version.jar " + path);
checkResult(r, false, "--multi-release option is not set");
r = run("jdeps -v -R -cp Version.jar --module-path Foo.jar -multi-release 9 " + path);
r = run("jdeps -J-Duser.language=en -J-Duser.country=US -v -R -cp Version.jar --module-path Foo.jar -multi-release 9 " + path);
checkResult(r, false,
"Error: unknown option: -multi-release",
"Usage: jdeps <options> <path",
@ -208,7 +208,7 @@ public class MultiReleaseJar {
"p.Foo"
);
r = run("jdeps -v -R -cp Version.jar --module-path Foo.jar --multi-release 9.1 " + path);
r = run("jdeps -J-Duser.language=en -J-Duser.country=US -v -R -cp Version.jar --module-path Foo.jar --multi-release 9.1 " + path);
checkResult(r, false, "Error: invalid argument for option: 9.1");
// Version_9.jar does not have any version 10 entry