Skip to content

Commit 58487fb

Browse files
committed
8273361: InfoOptsTest is failing in tier1
Backport-of: 267c61a16a916e35762e8df5737ec74b06defae8
1 parent 2490386 commit 58487fb

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

test/langtools/tools/javac/options/modes/InfoOptsTest.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,23 @@ void testInfoOpt(String opt, String... expect) {
6969

7070
@Test
7171
void testUniqueInfoOpts() throws IOException {
72-
testUniqueInfoOpt(new String[] {"--help", "--help"}, "possible options");
73-
testUniqueInfoOpt(new String[] {"-X", "-X"}, "extra options");
74-
testUniqueInfoOpt(new String[] {"--help-lint", "--help-lint"}, "supported keys");
72+
testUniqueInfoOpt(new String[] {"--help"}, new String[] {"--help", "--help"});
73+
testUniqueInfoOpt(new String[] {"-X"}, new String[] {"-X", "-X"});
74+
testUniqueInfoOpt(new String[] {"--help-lint"}, new String[] {"--help-lint", "--help-lint"});
7575

76-
String specVersion = System.getProperty("java.specification.version");
77-
testUniqueInfoOpt(new String[] {"-version", "-version"}, "javac", specVersion);
78-
testUniqueInfoOpt(new String[] {"-fullversion", "-fullversion"}, "javac", specVersion);
76+
testUniqueInfoOpt(new String[] {"-version"}, new String[] {"-version", "-version"});
77+
testUniqueInfoOpt(new String[] {"-fullversion"}, new String[] {"-fullversion", "-fullversion"});
7978
}
8079

81-
void testUniqueInfoOpt(String[] opts, String... expect) {
80+
void testUniqueInfoOpt(String[] baseOpts, String[] testOpts) {
8281
String[] files = { };
83-
runMain(opts, files)
84-
.checkOK()
85-
.checkUniqueLog(expect);
82+
83+
TestResult base = runMain(baseOpts, files)
84+
.checkOK();
85+
86+
TestResult test = runMain(testOpts, files)
87+
.checkOK();
88+
89+
base.checkSameLog(test);
8690
}
8791
}

test/langtools/tools/javac/options/modes/OptionModesTester.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -269,18 +269,15 @@ TestResult checkLog(Log l, String... expects) {
269269
return this;
270270
}
271271

272-
TestResult checkUniqueLog(String... uniqueExpects) {
273-
return checkUniqueLog(Log.DIRECT, uniqueExpects);
272+
TestResult checkSameLog(TestResult other) {
273+
return checkSameLog(Log.DIRECT, other);
274274
}
275275

276-
TestResult checkUniqueLog(Log l, String... uniqueExpects) {
277-
String log = logs.get(l);
278-
for (String e : uniqueExpects) {
279-
if (!log.contains(e)) {
280-
error("Expected string not found: " + e);
281-
} else if (log.indexOf(e) != log.lastIndexOf(e)) {
282-
error("Expected string appears more than once: " + e);
283-
}
276+
TestResult checkSameLog(Log l, TestResult other) {
277+
String thisLog = logs.get(l);
278+
String otherLog = other.logs.get(l);
279+
if (!thisLog.equals(otherLog)) {
280+
error("Logs are not the same.\nThis:\n" + thisLog + "\nOther:\n" + otherLog);
284281
}
285282
return this;
286283
}

0 commit comments

Comments
 (0)