Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8273361: InfoOptsTest is failing in tier1 #5381

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -69,19 +69,18 @@ void testInfoOpt(String opt, String... expect) {

@Test
void testUniqueInfoOpts() throws IOException {
testUniqueInfoOpt(new String[] {"--help", "--help"}, "possible options");
testUniqueInfoOpt(new String[] {"-X", "-X"}, "extra options");
testUniqueInfoOpt(new String[] {"--help-lint", "--help-lint"}, "supported keys");
testUniqueInfoOpt(new String[] {"--help", "--help"}, "where possible options");
testUniqueInfoOpt(new String[] {"-X", "-X"}, "These extra options");
testUniqueInfoOpt(new String[] {"--help-lint", "--help-lint"}, "The supported keys");

String specVersion = System.getProperty("java.specification.version");
testUniqueInfoOpt(new String[] {"-version", "-version"}, "javac", specVersion);
testUniqueInfoOpt(new String[] {"-fullversion", "-fullversion"}, "javac", specVersion);
testUniqueInfoOpt(new String[] {"-version", "-version"}, "javac");
testUniqueInfoOpt(new String[] {"-fullversion", "-fullversion"}, "javac full version");
}

void testUniqueInfoOpt(String[] opts, String... expect) {
String[] files = { };
runMain(opts, files)
.checkOK()
.checkUniqueLog(expect);
.checkUniqueStartLog(expect);
}
}
@@ -45,6 +45,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;
import javax.tools.JavaFileManager;
import javax.tools.JavaFileObject;
@@ -269,16 +270,23 @@ TestResult checkLog(Log l, String... expects) {
return this;
}

TestResult checkUniqueLog(String... uniqueExpects) {
return checkUniqueLog(Log.DIRECT, uniqueExpects);
TestResult checkUniqueStartLog(String... uniqueExpects) {
return checkUniqueStartLog(Log.DIRECT, uniqueExpects);
}

TestResult checkUniqueLog(Log l, String... uniqueExpects) {
TestResult checkUniqueStartLog(Log l, String... uniqueExpects) {
String log = logs.get(l);
for (String e : uniqueExpects) {
if (!log.contains(e)) {
Scanner scanner = new Scanner(log);
int num = 0;
while (scanner.hasNextLine()) {
if (scanner.nextLine().startsWith(e)) {
num++;
}
}
if (num == 0) {
error("Expected string not found: " + e);
} else if (log.indexOf(e) != log.lastIndexOf(e)) {
} else if (num > 1) {
error("Expected string appears more than once: " + e);
}
}