mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-15 10:23:28 +00:00
8284067: jpackage'd launcher reports non-zero exit codes with error prompt
Reviewed-by: almatvee
This commit is contained in:
parent
bbe894fc81
commit
b9cc3bc1bf
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,7 @@
|
||||
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "AppLauncher.h"
|
||||
@ -180,11 +181,7 @@ void launchApp() {
|
||||
GetExitCodeProcess));
|
||||
}
|
||||
|
||||
if (exitCode != 0) {
|
||||
JP_THROW(tstrings::any() << "Child process exited with code "
|
||||
<< exitCode);
|
||||
}
|
||||
|
||||
exit(exitCode);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -70,6 +70,8 @@ public class Hello implements OpenFilesHandler {
|
||||
lock.wait();
|
||||
}
|
||||
}
|
||||
|
||||
System.exit(Integer.getInteger("jpackage.test.exitCode", 0));
|
||||
}
|
||||
|
||||
private static List<String> printArgs(String[] args) {
|
||||
|
||||
@ -370,6 +370,8 @@ public final class HelloApp {
|
||||
params.put(name, value);
|
||||
} else if ("jpackage.test.appOutput".equals(name)) {
|
||||
outputFilePath = Path.of(value);
|
||||
} else if ("jpackage.test.exitCode".equals(name)) {
|
||||
expectedExitCode = Integer.parseInt(value);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@ -421,8 +423,8 @@ public final class HelloApp {
|
||||
final int attempts = 3;
|
||||
final int waitBetweenAttemptsSeconds = 5;
|
||||
getExecutor(launcherArgs.toArray(new String[0])).dumpOutput().setRemovePath(
|
||||
removePath).executeAndRepeatUntilExitCode(0, attempts,
|
||||
waitBetweenAttemptsSeconds);
|
||||
removePath).executeAndRepeatUntilExitCode(expectedExitCode,
|
||||
attempts, waitBetweenAttemptsSeconds);
|
||||
verifyOutputFile(outputFilePath, appArgs, params);
|
||||
}
|
||||
|
||||
@ -468,6 +470,7 @@ public final class HelloApp {
|
||||
|
||||
private final Path launcherPath;
|
||||
private Path outputFilePath;
|
||||
private int expectedExitCode;
|
||||
private final List<String> defaultLauncherArgs;
|
||||
private final Map<String, String> params;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -349,6 +349,17 @@ public final class BasicTest {
|
||||
HelloApp.executeLauncherAndVerifyOutput(cmd);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Parameter("1")
|
||||
@Parameter("123")
|
||||
public void testExitCode(int exitCode) {
|
||||
JPackageCommand cmd = JPackageCommand
|
||||
.helloAppImage()
|
||||
.addArguments("--java-options", String.format(
|
||||
"-Djpackage.test.exitCode=%d", exitCode));
|
||||
cmd.executeAndAssertHelloAppImageCreated();
|
||||
}
|
||||
|
||||
private static Executor getJPackageToolProvider() {
|
||||
return getToolProvider(JavaTool.JPACKAGE);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user