Make jpackage test lib more practical. List of changes: Support multiple args and var args in `@Parameter` annotation:
@Test @Parameter({"12", "foo"}) @Parameter({"-89", "bar", "more"}) @Parameter({"-89", "bar", "more", "moore"}) public void testVarArg(int a, String b, String ... other) {} Full support for var args in test constructors.<br/>Better results when looking up the suitable ctor for the ctor args with `null`-s.<br/>Support multiple functions with `@Parameteres` annotation, all will be executed instead of the first one earlier: class FooTest { public FooTest(String... args) {} public FooTest(int o) {} public FooTest(int a, Boolean[] b, String c, String ... other) {} @Parameters public static Collection<Object[]> input() { return List.of(new Object[][] { {}, {"str"}, {55, new Boolean[]{false, true, false}, "foo", "bar"}, }); } @Parameters public static Collection<Object[]> input2() { return List.of(new Object[][] { {78}, {34, null, null}, }); } } Static test method will be executed only once and not as many times as the number of the test class instances. Introduced `@ParameterSupplier` annotation as a flexible alternative to `@Parameter`: class FooTest { @Test @ParameterSupplier("dateSupplier") @ParameterSupplier("AnotherClass.dateSupplier") public void testDates(LocalDate v) {} public static Collection<Object[]> dateSupplier() { return List.of(new Object[][] { { LocalDate.parse("2018-05-05") }, { LocalDate.parse("2018-07-11") }, }); } } class AnotherClass { public static Collection<Object[]> dateSupplier() { return List.of(new Object[][] { { LocalDate.parse("2028-07-11") }, }); } } All annotations support `ifOS` and `ifNotOS` properties of type `jdk.internal.util.OperatingSystem`: @Test(ifOS = OperatingSystem.LINUX) public void testRunIfLinux() {} @Test(ifNotOS = OperatingSystem.LINUX) public void testRunIfNotLinux() {} @Test(ifNotOS = {OperatingSystem.LINUX,OperatingSystem.MACOS}) public void testRunIfNotLinuxOrMacOS() {} @Test @Parameter(value = "foo", ifOS = OperatingSystem.LINUX) @Parameter(value = {"foo", "bar"}, ifOS = { OperatingSystem.LINUX, OperatingSystem.MACOS }) @Parameter(value = {}, ifNotOS = { OperatingSystem.WINDOWS }) @ParameterSupplier(value = "getWindowsStrings", ifOS = OperatingSystem.WINDOWS) public void test(String ... args) {} public static List<Object[]> getWindowsStrings() { ... } class FooTest { public FooTest(int a, String b) { super(a, b); } @Parameters(ifOS = OperatingSystem.LINUX) public static Collection<Object[]> input() { return List.of(new Object[][] { {7, null}, }); } @Parameters(ifNotOS = {OperatingSystem.LINUX, OperatingSystem.MACOS}) public static Collection<Object[]> input2() { return List.of(new Object[][] { {10, "hello"}, }); } } The test case description contains a fully qualified test class name instead of the short name earlier. Added `JPackageCommand.validateOutput()` and adjusted `ErrorTest.java` to use it. Tighten tests in `LinuxHelper`: if the jpackage command is not using an external app image it will test that all "*.desktop" files match app launchers of the app. Earlier it validated the contents of "*.desktop" files without relation to app launchers. Add support for `@command` files to `Main.main()` method. E.g.: %> java ... Main.main @args.txt will result in reading arguments from "args.txt" file. Arguments will be split at whitespaces and line breaks. If `@` is followed by `=`, arguments will be split at line breaks. `InstallDirTest.java` and `InOutPath.java` tests updated to use new features. Other tests may be refactored later if appropriate. ------------- Commit messages: - Minor cleanup - Merge branch 'master' into JDK-8343876 - Use "validate" instead of "verify" for the new API - Don't run static test methods with test instances - Don't create intermediate set of expected test descs for very test class when building the total set of all test descs - Add test case to validate static test case will be executed only once in parameterized test - Full test class name in test case description - Use Comparator - Merge branch 'master' into JDK-8343876 - - add test coverage to @Parameters.ifOS and @Parameters.ifNotOS. - ... and 23 more: https://git.openjdk.org/jdk/compare/95a00f8a...1c7e0592 Changes: https://git.openjdk.org/jdk/pull/21996/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=21996&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8343876 Stats: 1889 lines in 17 files changed: 1515 ins; 208 del; 166 mod Patch: https://git.openjdk.org/jdk/pull/21996.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/21996/head:pull/21996 PR: https://git.openjdk.org/jdk/pull/21996