diff -r 32f161c94337 src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties --- a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties Tue Oct 10 14:39:45 2017 +0200 +++ b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties Tue Nov 28 11:55:04 2017 +0100 @@ -216,7 +216,7 @@ \ Use one -C for each compiler flag or flag argument\n\ \ --version Print version information and exit\n\ \ --show-version Print version information and continue\n\ -\ -? -h --help Print this synopsis of standard options and exit\n\ +\ --help, -?, -h Print this synopsis of standard options and exit\n\ \ --help-extra, -X Print help on non-standard options and exit\n\ A file argument may be a file name, or one of the predefined file names: DEFAULT,\n\ PRINTING, or JAVASE.\n\ diff -r 32f161c94337 test/jdk/tools/launcher/HelpFlagsTest.java --- a/test/jdk/tools/launcher/HelpFlagsTest.java Tue Oct 10 14:39:45 2017 +0200 +++ b/test/jdk/tools/launcher/HelpFlagsTest.java Tue Nov 28 11:55:04 2017 +0100 @@ -68,7 +68,7 @@ "wsgen", "wsimport", "xjc", - // These shall have a help message that resembles that of + // These shall have a help message that resembles that of // MIT's tools. Thus -?, -h and --help are supported, but not // mentioned in the help text. "kinit", @@ -87,11 +87,11 @@ // * the tool prints a help message if the flag is specified // * this help message lists the flag // * the tool exits with exit code '0'. - boolean supports_q; - boolean supports_h; - boolean supports_help; + boolean supportsQestionmark; + boolean supportsH; + boolean supportsHelp; // One tool returns with exit code != '0'. - int exitcode_of_help; + int exitcodeOfHelp; // How legacy -help is handled. // @@ -101,33 +101,33 @@ // // The tools accepts legacy -help. -help should not be // documented in the usage message. - boolean supports_legacy_help; + boolean supportsLegacyHelp; // Java itself documents -help. -help prints to stderr, // while --help prints to stdout. Leave as is. - boolean documents_legacy_help; + boolean documentsLegacyHelp; // The exit code of the tool if an invalid argument is passed to it. // An exit code != 0 would be expected, but not all tools handle it // that way. - int exitcode_of_wrong_flag; + int exitcodeOfWrongFlag; // Some tools accept the invalid argument and thus hang the test. // Don't execute these with the wrong flags. // This actually should be considered a bug in the corresponding tool. - boolean dont_execute_with_wrong_flags; + boolean dontExecuteWithWrongFlags; ToolHelpSpec(String n, int q, int h, int hp, int ex1, int l, int dl, int ex2, int hangs) { toolname = n; - supports_q = ( q == 1 ? true : false ); - supports_h = ( h == 1 ? true : false ); - supports_help = ( hp == 1 ? true : false ); - exitcode_of_help = ex1; + supportsQestionmark = ( q == 1 ? true : false ); + supportsH = ( h == 1 ? true : false ); + supportsHelp = ( hp == 1 ? true : false ); + exitcodeOfHelp = ex1; - supports_legacy_help = ( l == 1 ? true : false ); - documents_legacy_help = ( dl == 1 ? true : false ); - exitcode_of_wrong_flag = ex2; + supportsLegacyHelp = ( l == 1 ? true : false ); + documentsLegacyHelp = ( dl == 1 ? true : false ); + exitcodeOfWrongFlag = ex2; - dont_execute_with_wrong_flags = ( hangs == 1 ? true : false ); + dontExecuteWithWrongFlags = ( hangs == 1 ? true : false ); } } @@ -164,7 +164,6 @@ new ToolHelpSpec("jstatd", 1, 1, 1, 0, 0, 0, 1, 0), // -?, -h, --help new ToolHelpSpec("keytool", 1, 1, 1, 0, 1, 0, 1, 0), // none, prints help message anyways. new ToolHelpSpec("pack200", 1, 1, 1, 0, 1, 0, 2, 0), // -?, -h, --help, -help accepted but not documented. - new ToolHelpSpec("policytool", 0, 0, 0, 0, 0, 0, 0, 0), // none, prints help message anyways. new ToolHelpSpec("rmic", 0, 0, 0, 0, 0, 0, 1, 0), // none, pirnts help message anyways. new ToolHelpSpec("rmid", 0, 0, 0, 0, 0, 0, 1, 0), // none, prints help message anyways. new ToolHelpSpec("rmiregistry", 0, 0, 0, 0, 0, 0, 1, 0), // none, prints help message anyways. @@ -172,19 +171,6 @@ new ToolHelpSpec("unpack200", 1, 1, 1, 0, 1, 0, 2, 0), // -?, -h, --help, -help accepted but not documented. }; - - // Returns true if the file is not a tool. - static boolean notATool(String file) { - file = file.toLowerCase(); - if (file.endsWith(".dll") || - file.endsWith(".map") || - file.endsWith(".pdb") || - file.equals("server")) { // server subdir on windows. - return true; - } - return false; - } - // Returns true if tool is listed in TOOLS_NOT_TO_TEST. static boolean dontTestTool(String tool) { tool = tool.toLowerCase(); @@ -203,7 +189,7 @@ return null; } - // Check whether 'flag' appears in 'line' as a word of itself. I must not + // Check whether 'flag' appears in 'line' as a word of itself. It must not // be a substring of a word, as then similar flags might be matched. // E.g.: --help matches in the documentation of --help-extra. // This works only with english locale, as some tools have translated @@ -352,12 +338,17 @@ public static void main(String[] args) { String errorMessage = ""; + // The test analyses the help messages printed. It assumes englisch + // help messages. Thus only works with english locale. + if (!isEnglishLocale()) { return; } + for (File f : new File(JAVA_BIN).listFiles()) { + if (!f.canExecute()) { + continue; + } + String toolName = f.getName(); - if (notATool(toolName)) { - continue; - } if (dontTestTool(toolName)) { System.out.println("Skipping test of tool " + toolName + ". Tool has no help message."); @@ -372,35 +363,35 @@ } // Test for help flags to be supported. - if (tool.supports_q == true) { - errorMessage += testTool(f, "-?", tool.exitcode_of_help); + if (tool.supportsQestionmark == true) { + errorMessage += testTool(f, "-?", tool.exitcodeOfHelp); } else { System.out.println("Skip " + tool.toolname + ". It does not support -?."); } - if (tool.supports_h == true) { - errorMessage += testTool(f, "-h", tool.exitcode_of_help); + if (tool.supportsH == true) { + errorMessage += testTool(f, "-h", tool.exitcodeOfHelp); } else { System.out.println("Skip " + tool.toolname + ". It does not support -h."); } - if (tool.supports_help == true) { - errorMessage += testTool(f, "--help", tool.exitcode_of_help); + if (tool.supportsHelp == true) { + errorMessage += testTool(f, "--help", tool.exitcodeOfHelp); } else { System.out.println("Skip " + tool.toolname + ". It does not support --help."); } // Check that the return code listing in jdkTools[] is // correct for an invalid flag. - if (!tool.dont_execute_with_wrong_flags) { - errorMessage += testInvalidFlag(f, "-asdfxgr", tool.exitcode_of_wrong_flag); + if (!tool.dontExecuteWithWrongFlags) { + errorMessage += testInvalidFlag(f, "-asdfxgr", tool.exitcodeOfWrongFlag); } // Test for legacy -help flag. - if (!tool.documents_legacy_help) { - if (tool.supports_legacy_help == true) { - errorMessage += testLegacyFlag(f, tool.exitcode_of_help); + if (!tool.documentsLegacyHelp) { + if (tool.supportsLegacyHelp == true) { + errorMessage += testLegacyFlag(f, tool.exitcodeOfHelp); } else { - if (!tool.dont_execute_with_wrong_flags) { - errorMessage += testInvalidFlag(f, "-help", tool.exitcode_of_wrong_flag); + if (!tool.dontExecuteWithWrongFlags) { + errorMessage += testInvalidFlag(f, "-help", tool.exitcodeOfWrongFlag); } } }