8290398: jpackage exe installers are not installed in jtreg tests

Reviewed-by: almatvee
This commit is contained in:
Alexey Semenyuk 2022-07-19 19:46:51 +00:00
parent 1af7c33df5
commit c2cbeb3ee8

View File

@ -414,7 +414,26 @@ public final class PackageTest extends RunnablePackageTest {
terminated = true;
}
if (aborted) {
boolean skip = false;
if (unhandledAction != null) {
switch (unhandledAction) {
case CREATE:
skip = true;
break;
case UNPACK:
case INSTALL:
skip = (action == Action.VERIFY_INSTALL);
break;
case UNINSTALL:
skip = (action == Action.VERIFY_UNINSTALL);
break;
}
}
if (skip) {
TKit.trace(String.format("Skip [%s] action of %s command",
action, cmd.getPrintableCommandLine()));
return;
}
@ -429,38 +448,44 @@ public final class PackageTest extends RunnablePackageTest {
switch (action) {
case UNPACK: {
cmd.setUnpackedPackageLocation(null);
var handler = packageHandlers.get(type).unpackHandler;
if (!(aborted = (handler == null))) {
unpackDir = TKit.createTempDirectory(
handleAction(action,
packageHandlers.get(type).unpackHandler,
handler -> {
unpackDir = TKit.createTempDirectory(
String.format("unpacked-%s",
type.getName()));
unpackDir = handler.apply(cmd, unpackDir);
cmd.setUnpackedPackageLocation(unpackDir);
}
unpackDir = handler.apply(cmd, unpackDir);
cmd.setUnpackedPackageLocation(unpackDir);
});
break;
}
case INSTALL: {
cmd.setUnpackedPackageLocation(null);
var handler = packageHandlers.get(type).installHandler;
if (!(aborted = (handler == null))) {
handler.accept(curCmd.get());
}
handleAction(action,
packageHandlers.get(type).installHandler,
handler -> {
handler.accept(curCmd.get());
});
break;
}
case UNINSTALL: {
var handler = packageHandlers.get(type).uninstallHandler;
if (!(aborted = (handler == null))) {
handler.accept(curCmd.get());
}
handleAction(action,
packageHandlers.get(type).uninstallHandler,
handler -> {
handler.accept(curCmd.get());
});
break;
}
case CREATE:
cmd.setUnpackedPackageLocation(null);
handler.accept(action, curCmd.get());
aborted = (expectedJPackageExitCode != 0);
handleAction(action,
(expectedJPackageExitCode == 0) ? Boolean.TRUE : null,
handler -> {
});
return;
default:
@ -468,15 +493,25 @@ public final class PackageTest extends RunnablePackageTest {
break;
}
if (aborted) {
TKit.trace(
String.format("Aborted [%s] action of %s command",
action, cmd.getPrintableCommandLine()));
Optional.ofNullable(unhandledAction).ifPresent(v -> {
TKit.trace(String.format(
"No handler of [%s] action for %s command", v,
cmd.getPrintableCommandLine()));
});
}
private <T> void handleAction(Action action, T handler,
ThrowingConsumer<T> consumer) throws Throwable {
if (handler == null) {
unhandledAction = action;
} else {
unhandledAction = null;
consumer.accept(handler);
}
}
private Path unpackDir;
private boolean aborted;
private Action unhandledAction;
private boolean terminated;
private final JPackageCommand cmd = Functional.identity(() -> {
JPackageCommand result = new JPackageCommand();