8225092: Several jpackage tests failes when run with jcov enabled JDK-8200758-branch
authorherrick
Fri, 21 Jun 2019 08:29:09 -0400
branchJDK-8200758-branch
changeset 57419 44c2481650ce
parent 57415 50ac38fbd874
child 57420 c84d7dc9e434
8225092: Several jpackage tests failes when run with jcov enabled Submitted-by: almatvee Reviewed-by: herrick, almatvee
test/jdk/tools/jpackage/JPackageInvalidArgTest.java
test/jdk/tools/jpackage/JPackageMissingArgumentsTest.java
test/jdk/tools/jpackage/JPackageNoArgTest.java
test/jdk/tools/jpackage/JPackageVersionTest.java
test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageBase.java
test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageJavaOptionsBase.java
test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageJavaOptionsEqualsTest.java
test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageMainClassErrorTest.java
test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageRuntimeBase.java
test/jdk/tools/jpackage/createinstaller/macosx/dmg/JPackageCreateInstallerMacOptionsTest.java
test/jdk/tools/jpackage/helpers/JPackageHelper.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: "
--- 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: "
--- 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(
--- 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);
--- 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);
     }
 
--- 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);
     }
 
--- 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]);
         }
--- 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);
--- 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);
         }
--- 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 {
--- 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<String> origList = new ArrayList(Arrays.asList(result));
+        List<String> 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;