# HG changeset patch # User herrick # Date 1561120149 14400 # Node ID 44c2481650cef2a74f1f9904ce53f15bb67b1fc5 # Parent 50ac38fbd874701d124ac1358fd6711af6b98fcf 8225092: Several jpackage tests failes when run with jcov enabled Submitted-by: almatvee Reviewed-by: herrick, almatvee diff -r 50ac38fbd874 -r 44c2481650ce test/jdk/tools/jpackage/JPackageInvalidArgTest.java --- a/test/jdk/tools/jpackage/JPackageInvalidArgTest.java Thu Jun 20 14:47:20 2019 -0400 +++ b/test/jdk/tools/jpackage/JPackageInvalidArgTest.java Fri Jun 21 08:29:09 2019 -0400 @@ -39,7 +39,7 @@ private static final String RESULT2 = "Missing argument:"; private static void validate(String arg, String output) throws Exception { - String[] result = output.split("\n"); + String[] result = JPackageHelper.splitAndFilter(output); if (result.length != 1) { System.err.println(output); throw new AssertionError("Invalid number of lines in output: " diff -r 50ac38fbd874 -r 44c2481650ce test/jdk/tools/jpackage/JPackageMissingArgumentsTest.java --- a/test/jdk/tools/jpackage/JPackageMissingArgumentsTest.java Thu Jun 20 14:47:20 2019 -0400 +++ b/test/jdk/tools/jpackage/JPackageMissingArgumentsTest.java Fri Jun 21 08:29:09 2019 -0400 @@ -91,7 +91,7 @@ private static void validate(String output, String [] expected, boolean single) throws Exception { - String[] result = output.split("\n"); + String[] result = JPackageHelper.splitAndFilter(output); if (single && result.length != 1) { System.err.println(output); throw new AssertionError("Invalid number of lines in output: " diff -r 50ac38fbd874 -r 44c2481650ce test/jdk/tools/jpackage/JPackageNoArgTest.java --- a/test/jdk/tools/jpackage/JPackageNoArgTest.java Thu Jun 20 14:47:20 2019 -0400 +++ b/test/jdk/tools/jpackage/JPackageNoArgTest.java Fri Jun 21 08:29:09 2019 -0400 @@ -37,7 +37,7 @@ {"--help", "list of possible options"}; private static void validate(String output) throws Exception { - String[] result = output.split("\n"); + String[] result = JPackageHelper.splitAndFilter(output); if (result.length != 2) { System.err.println(output); throw new AssertionError( diff -r 50ac38fbd874 -r 44c2481650ce test/jdk/tools/jpackage/JPackageVersionTest.java --- a/test/jdk/tools/jpackage/JPackageVersionTest.java Thu Jun 20 14:47:20 2019 -0400 +++ b/test/jdk/tools/jpackage/JPackageVersionTest.java Fri Jun 21 08:29:09 2019 -0400 @@ -36,7 +36,7 @@ private static final String RESULT = System.getProperty("java.version"); private static void validate(String output) throws Exception { - String[] result = output.split("\n"); + String[] result = JPackageHelper.splitAndFilter(output); if (result.length != 1) { System.err.println(output); throw new AssertionError("Invalid number of lines in output: " + result.length); diff -r 50ac38fbd874 -r 44c2481650ce test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageBase.java --- a/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageBase.java Thu Jun 20 14:47:20 2019 -0400 +++ b/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageBase.java Fri Jun 21 08:29:09 2019 -0400 @@ -21,7 +21,6 @@ * questions. */ -import java.io.File; import java.nio.file.Files; import java.nio.file.Path; @@ -46,7 +45,7 @@ public static void validate(String app) throws Exception { Path outPath = Path.of(appWorkingDir, appOutput); - int retVal = JPackageHelper.execute(outPath.toFile(), app); + int retVal = JPackageHelper.execute(null, app); if (outPath.toFile().exists()) { System.out.println("output contents: "); @@ -66,7 +65,7 @@ } String output = Files.readString(outPath); - String[] result = output.split("\n"); + String[] result = JPackageHelper.splitAndFilter(output); validateResult(result); } diff -r 50ac38fbd874 -r 44c2481650ce test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageJavaOptionsBase.java --- a/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageJavaOptionsBase.java Thu Jun 20 14:47:20 2019 -0400 +++ b/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageJavaOptionsBase.java Fri Jun 21 08:29:09 2019 -0400 @@ -119,7 +119,7 @@ } String output = Files.readString(outfile.toPath()); - String[] result = output.split("\n"); + String[] result = JPackageHelper.splitAndFilter(output); validateResult(result, expectedArgs); } diff -r 50ac38fbd874 -r 44c2481650ce test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageJavaOptionsEqualsTest.java --- a/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageJavaOptionsEqualsTest.java Thu Jun 20 14:47:20 2019 -0400 +++ b/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageJavaOptionsEqualsTest.java Fri Jun 21 08:29:09 2019 -0400 @@ -71,13 +71,13 @@ } String output = Files.readString(outfile.toPath()); - String[] result = output.split("\n"); + String[] result = JPackageHelper.splitAndFilter(output); if (result.length != 4) { throw new AssertionError( "Unexpected number of lines: " + result.length + " - output: " + output); } - + if (!result[0].startsWith("WARNING: Unknown module: me.mymodule.foo")){ throw new AssertionError("Unexpected result[0]: " + result[0]); } diff -r 50ac38fbd874 -r 44c2481650ce test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageMainClassErrorTest.java --- a/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageMainClassErrorTest.java Thu Jun 20 14:47:20 2019 -0400 +++ b/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageMainClassErrorTest.java Fri Jun 21 08:29:09 2019 -0400 @@ -46,7 +46,7 @@ "--main-jar", "hello.jar"}; private static void validate(String output) throws Exception { - String[] result = output.split("\n"); + String[] result = JPackageHelper.splitAndFilter(output); if (result.length != 2) { throw new AssertionError( "Unexpected number of lines: " + result.length); diff -r 50ac38fbd874 -r 44c2481650ce test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageRuntimeBase.java --- a/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageRuntimeBase.java Thu Jun 20 14:47:20 2019 -0400 +++ b/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageRuntimeBase.java Fri Jun 21 08:29:09 2019 -0400 @@ -57,7 +57,7 @@ } String output = Files.readString(outfile.toPath()); - String[] result = output.split("\n"); + String[] result = JPackageHelper.splitAndFilter(output); validateResult(result); } @@ -73,7 +73,7 @@ } String output = Files.readString(outfile.toPath()); - String[] result = output.split("\n"); + String[] result = JPackageHelper.splitAndFilter(output); if (result.length != 1) { throw new AssertionError("Unexpected number of lines: " + result.length); } diff -r 50ac38fbd874 -r 44c2481650ce test/jdk/tools/jpackage/createinstaller/macosx/dmg/JPackageCreateInstallerMacOptionsTest.java --- a/test/jdk/tools/jpackage/createinstaller/macosx/dmg/JPackageCreateInstallerMacOptionsTest.java Thu Jun 20 14:47:20 2019 -0400 +++ b/test/jdk/tools/jpackage/createinstaller/macosx/dmg/JPackageCreateInstallerMacOptionsTest.java Fri Jun 21 08:29:09 2019 -0400 @@ -32,6 +32,7 @@ * @build JPackageCreateInstallerMacOptionsBase * @requires (os.family == "mac") * @modules jdk.jpackage + * @ignore * @run main/othervm -Xmx512m JPackageCreateInstallerMacOptionsTest */ public class JPackageCreateInstallerMacOptionsTest { diff -r 50ac38fbd874 -r 44c2481650ce test/jdk/tools/jpackage/helpers/JPackageHelper.java --- a/test/jdk/tools/jpackage/helpers/JPackageHelper.java Thu Jun 20 14:47:20 2019 -0400 +++ b/test/jdk/tools/jpackage/helpers/JPackageHelper.java Fri Jun 21 08:29:09 2019 -0400 @@ -34,6 +34,7 @@ import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; import java.util.List; +import java.util.Arrays; import java.util.spi.ToolProvider; @@ -527,6 +528,26 @@ return newAList.toArray(new String[0]); } + public static String [] splitAndFilter(String output) { + if (output == null) { + return null; + } + + String[] result = output.split("\n"); + if (result == null || result.length == 0) { + return result; + } + + List origList = new ArrayList(Arrays.asList(result)); + List newlist = new ArrayList(); + origList.stream().filter((str) -> + (!str.startsWith("Picked up"))).forEachOrdered((str) -> { + newlist.add(str); + }); + + return newlist.toArray(new String[newlist.size()]); + } + private static String quote(String in, boolean toolProvider) { if (in == null) { return null;