Skip to content

Commit e0368a2

Browse files
Nagata, HaruhitoRealCLanger
authored andcommitted
8283606: Tests may fail with zh locale on MacOS
Reviewed-by: clanger Backport-of: 7d545084f45af44386cb38172fd783f889a8c4e7
1 parent e262f64 commit e0368a2

File tree

9 files changed

+37
-23
lines changed

9 files changed

+37
-23
lines changed

test/hotspot/jtreg/runtime/classFileParserBug/TestEmptyBootstrapMethodsAttr.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -49,7 +49,8 @@ public static void main(String args[]) throws Throwable {
4949
// ======= execute test case #1
5050
// Expect a lack of main method, this implies that the class loaded correctly
5151
// with an empty bootstrap_methods and did not generate a ClassFormatError.
52-
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(className);
52+
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
53+
"-Duser.language=en", "-Duser.country=US", className);
5354
OutputAnalyzer output = new OutputAnalyzer(pb.start());
5455
output.shouldNotContain("java.lang.ClassFormatError");
5556
output.shouldContain("Main method not found in class " + className);
@@ -63,7 +64,8 @@ public static void main(String args[]) throws Throwable {
6364
// ======= execute test case #2
6465
// Expect a lack of main method, this implies that the class loaded correctly
6566
// with an empty bootstrap_methods and did not generate ClassFormatError.
66-
pb = ProcessTools.createJavaProcessBuilder(className);
67+
pb = ProcessTools.createJavaProcessBuilder(
68+
"-Duser.language=en", "-Duser.country=US", className);
6769
output = new OutputAnalyzer(pb.start());
6870
output.shouldNotContain("java.lang.ClassFormatError");
6971
output.shouldContain("Main method not found in class " + className);

test/langtools/jdk/javadoc/tool/6964914/TestStdDoclet.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -56,6 +56,8 @@ void run() throws Exception {
5656
List<String> cmdArgs = new ArrayList<>();
5757
cmdArgs.add(javadoc.getPath());
5858
cmdArgs.addAll(Arrays.asList(
59+
"-J-Duser.language=en",
60+
"-J-Duser.country=US",
5961
"-classpath", ".", // insulates us from ambient classpath
6062
"-Xdoclint:none",
6163
"-package",

test/langtools/jdk/javadoc/tool/6964914/TestUserDoclet.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -69,6 +69,8 @@ void run() throws Exception {
6969
List<String> cmdArgs = new ArrayList<>();
7070
cmdArgs.add(javadoc.getPath());
7171
cmdArgs.addAll(Arrays.asList(
72+
"-J-Duser.language=en",
73+
"-J-Duser.country=US",
7274
"-doclet", thisClassName,
7375
"-docletpath", testClasses.getPath(),
7476
new File(testSrc, thisClassName + ".java").getPath()

test/langtools/jdk/javadoc/tool/EnsureNewOldDoclet.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -106,7 +106,8 @@ public static void main(String... args) throws Exception {
106106
// outcome: new tool and new doclet
107107
@Test
108108
public void testDefault() throws Exception {
109-
setArgs("-classpath", ".", // insulates us from ambient classpath
109+
setArgs("-J-Duser.language=en", "-J-Duser.country=US",
110+
"-classpath", ".", // insulates us from ambient classpath
110111
testSrc.toString());
111112
Task.Result tr = task.run(Task.Expect.SUCCESS);
112113
List<String> err = tr.getOutputLines(Task.OutputKind.STDERR);
@@ -117,7 +118,9 @@ public void testDefault() throws Exception {
117118
// outcome: new doclet and new taglet should register
118119
@Test
119120
public void testNewDocletNewTaglet() throws Exception {
120-
setArgs("-classpath", ".", // ambient classpath insulation
121+
setArgs("-J-Duser.language=en",
122+
"-J-Duser.country=US",
123+
"-classpath", ".", // ambient classpath insulation
121124
"-doclet",
122125
NEW_STDDOCLET,
123126
"-taglet",

test/langtools/jdk/javadoc/tool/testLocaleOption/TestLocaleOption.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -242,6 +242,9 @@ private Task.Result javadoc(Locale defaultLocale, Locale localeOption, String...
242242
options.add("-J-Duser.language=" + defaultLocale.getLanguage());
243243
options.add("-J-Duser.country=" + defaultLocale.getCountry());
244244
options.add("-J-Duser.variant=" + defaultLocale.getVariant());
245+
} else {
246+
options.add("-J-Duser.language=en");
247+
options.add("-J-Duser.country=us");
245248
}
246249
if (localeOption != null) {
247250
options.addAll(List.of("-locale", localeOption.toString()));

test/langtools/tools/javac/T8132562/ClassPathWithDoubleQuotesTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -125,7 +125,7 @@ public void test(Path base) throws Exception {
125125
"and for which they are a legal filename character");
126126
List<String> log = new JavacTask(tb, Task.Mode.EXEC)
127127
.envVar("CLASSPATH", "Ztest/jarOut/J.jar" + File.pathSeparator + "test/srcZ")
128-
.options("-XDrawDiagnostics")
128+
.options("-XDrawDiagnostics", "-J-Duser.language=en", "-J-Duser.country=US")
129129
.files("test/src/A.java").run(Task.Expect.FAIL)
130130
.writeAll()
131131
.getOutputLines(Task.OutputKind.STDERR);
@@ -138,7 +138,7 @@ public void test(Path base) throws Exception {
138138
System.err.println("invoking javac EXEC mode with double quotes in the CLASSPATH env variable");
139139
List<String> log2 = new JavacTask(tb, Task.Mode.EXEC)
140140
.envVar("CLASSPATH", "\"test/jarOut/J.jar" + File.pathSeparator + "test/src\"")
141-
.options("-Xlint:path", "-XDrawDiagnostics")
141+
.options("-Xlint:path", "-XDrawDiagnostics", "-J-Duser.language=en", "-J-Duser.country=US")
142142
.files("test/src/A.java").run(Task.Expect.FAIL)
143143
.writeAll()
144144
.getOutputLines(Task.OutputKind.STDERR);

test/langtools/tools/javac/options/smokeTests/OptionSmokeTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -206,6 +206,7 @@ public void unmatchedQuoteInEnvVar(Path base) throws Exception {
206206
List<String> log = new JavacTask(tb, Task.Mode.EXEC)
207207
.envVar("JDK_JAVAC_OPTIONS",
208208
String.format("--add-exports jdk.compiler%scom.sun.tools.javac.jvm=\"ALL-UNNAMED", fileSeparator))
209+
.options("-J-Duser.language=en", "-J-Duser.country=US")
209210
.files(findJavaFiles(src))
210211
.run(Task.Expect.FAIL)
211212
.writeAll()

test/langtools/tools/javac/platform/PlatformProviderTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -131,7 +131,8 @@ void doTestFailure() {
131131
Task.Result result =
132132
new JavacTask(tb, Task.Mode.EXEC)
133133
.outdir(".")
134-
.options("-J--class-path=" + System.getProperty("test.classes"),
134+
.options("-J-Duser.language=en", "-J-Duser.country=US",
135+
"-J--class-path=" + System.getProperty("test.classes"),
135136
"-J--add-exports=jdk.compiler/com.sun.tools.javac.platform=ALL-UNNAMED",
136137
"-J--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
137138
"--release",

test/langtools/tools/jdeps/MultiReleaseJar.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -80,10 +80,10 @@ public void initialize() throws Exception {
8080

8181
@Test
8282
public void basic() throws Exception {
83-
Result r = run("jdeps --multi-release 9 -v missing.jar");
83+
Result r = run("jdeps -J-Duser.language=en -J-Duser.country=US --multi-release 9 -v missing.jar");
8484
checkResult(r, false, "Warning: Path does not exist: missing.jar");
8585

86-
r = run("jdeps -v Version.jar");
86+
r = run("jdeps -J-Duser.language=en -J-Duser.country=US -v Version.jar");
8787
checkResult(r, false, "--multi-release option is not set");
8888

8989
r = run("jdeps --multi-release base -v Version.jar");
@@ -115,10 +115,10 @@ public void basic() throws Exception {
115115
"9/test.NonPublic"
116116
);
117117

118-
r = run("jdeps --multi-release 8 -v Version.jar");
118+
r = run("jdeps -J-Duser.language=en -J-Duser.country=US --multi-release 8 -v Version.jar");
119119
checkResult(r, false, "Error: invalid argument for option: 8");
120120

121-
r = run("jdeps --multi-release 9.1 -v Version.jar");
121+
r = run("jdeps -J-Duser.language=en -J-Duser.country=US --multi-release 9.1 -v Version.jar");
122122
checkResult(r, false, "Error: invalid argument for option: 9.1");
123123

124124
runJdeps("Main.class");
@@ -127,10 +127,10 @@ public void basic() throws Exception {
127127

128128

129129
private void runJdeps(String path) throws Exception {
130-
Result r = run("jdeps -v -R -cp Version.jar " + path);
130+
Result r = run("jdeps -J-Duser.language=en -J-Duser.country=US -v -R -cp Version.jar " + path);
131131
checkResult(r, false, "--multi-release option is not set");
132132

133-
r = run("jdeps -v -R -cp Version.jar --module-path Foo.jar -multi-release 9 " + path);
133+
r = run("jdeps -J-Duser.language=en -J-Duser.country=US -v -R -cp Version.jar --module-path Foo.jar -multi-release 9 " + path);
134134
checkResult(r, false,
135135
"Error: unknown option: -multi-release",
136136
"Usage: jdeps <options> <path",
@@ -208,7 +208,7 @@ private void runJdeps(String path) throws Exception {
208208
"p.Foo"
209209
);
210210

211-
r = run("jdeps -v -R -cp Version.jar --module-path Foo.jar --multi-release 9.1 " + path);
211+
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);
212212
checkResult(r, false, "Error: invalid argument for option: 9.1");
213213

214214
// Version_9.jar does not have any version 10 entry

0 commit comments

Comments
 (0)