--- old/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/HelloApp.java 2020-05-22 11:05:51.720534600 -0400 +++ new/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/HelloApp.java 2020-05-22 11:05:49.356745800 -0400 @@ -204,6 +204,9 @@ expected.addAll(params.entrySet().stream() .sorted(Comparator.comparing(Map.Entry::getKey)) .map(entry -> String.format("-D%s=%s", entry.getKey(), +/* + unQuote(entry.getValue()))) +*/ entry.getValue())) .collect(Collectors.toList())); @@ -276,6 +279,30 @@ .executeAndVerifyOutput(args); } + public static Executor.Result executeLauncher(JPackageCommand cmd, + String... args) { + final Path launcherPath = cmd.appLauncherPath(); + if (cmd.isFakeRuntime(String.format("Not running [%s] launcher", + launcherPath))) { + return null; + } + + return assertApp(launcherPath) + .addDefaultArguments(Optional + .ofNullable(cmd.getAllArgumentValues("--arguments")) + .orElseGet(() -> new String[0])) + .addJavaOptions(Optional + .ofNullable(cmd.getAllArgumentValues("--java-options")) + .orElseGet(() -> new String[0])) + .executeOnly(args); + } + + private static String unQuote(String s) { + return ((s.startsWith("\"") && s.endsWith("\"")) || + (s.startsWith("'") && s.endsWith("'"))) ? + s.substring(1, s.length() - 1) : s; + } + public final static class AppOutputVerifier { AppOutputVerifier(Path helloAppLauncher) { this.launcherPath = helloAppLauncher; @@ -317,8 +344,14 @@ public AppOutputVerifier addJavaOptions(Collection v) { return addParams(v.stream() +/* + .filter(javaOpt -> unQuote(javaOpt).startsWith("-D")) +*/ .filter(javaOpt -> javaOpt.startsWith("-D")) .map(javaOpt -> { +/* + var components = unQuote(javaOpt).split("=", 2); +*/ var components = javaOpt.split("=", 2); return Map.entry(components[0].substring(2), components[1]); }) @@ -356,6 +389,28 @@ verifyOutputFile(outputFile, appArgs, params); } + public Executor.Result executeOnly(String...args) { + // Output file might be created in the current directory. + Path outputFile = TKit.workDir().resolve(OUTPUT_FILENAME); + ThrowingFunction.toFunction(Files::deleteIfExists).apply(outputFile); + + final Path executablePath; + if (launcherPath.isAbsolute()) { + executablePath = launcherPath; + } else { + // Make sure path to executable is relative to the current directory. + executablePath = Path.of(".").resolve(launcherPath.normalize()); + } + + final List launcherArgs = List.of(args); + return new Executor() + .setDirectory(outputFile.getParent()) + .setExecutable(executablePath) + .addArguments(launcherArgs) + .saveOutput() + .executeWithoutExitCodeCheck(); + } + private final Path launcherPath; private final List defaultLauncherArgs; private final Map params;