mirror of
https://github.com/openjdk/jdk.git
synced 2026-07-28 03:43:21 +00:00
8351095: [macos] Add more jpackage tests for --mac-app-store option
Reviewed-by: asemenyuk
This commit is contained in:
parent
847fbab792
commit
b054a56571
@ -149,7 +149,11 @@ public final class LauncherAsServiceVerifier {
|
||||
applyToAdditionalLauncher(target);
|
||||
}
|
||||
target.test().ifPresent(pkg -> {
|
||||
pkg.addInstallVerifier(this::verifyLauncherExecuted);
|
||||
pkg.addInstallVerifier(cmd -> {
|
||||
if (!MacHelper.isForAppStore(cmd)) {
|
||||
verifyLauncherExecuted(cmd);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@ -239,7 +243,9 @@ public final class LauncherAsServiceVerifier {
|
||||
}
|
||||
|
||||
static boolean launcherAsService(JPackageCommand cmd, String launcherName) {
|
||||
if (cmd.isMainLauncher(launcherName)) {
|
||||
if (MacHelper.isForAppStore(cmd)) {
|
||||
return false;
|
||||
} else if (cmd.isMainLauncher(launcherName)) {
|
||||
return PropertyFinder.findLauncherProperty(cmd, null,
|
||||
PropertyFinder.cmdlineBooleanOption("--launcher-as-service"),
|
||||
PropertyFinder.nop(),
|
||||
|
||||
@ -797,6 +797,15 @@ public final class MacHelper {
|
||||
).orElseGet(cmd::name);
|
||||
}
|
||||
|
||||
public static boolean isForAppStore(JPackageCommand cmd) {
|
||||
return PropertyFinder.findAppProperty(cmd,
|
||||
PropertyFinder.cmdlineBooleanOption("--mac-app-store"),
|
||||
PropertyFinder.appImageFile(appImageFile -> {
|
||||
return Boolean.toString(appImageFile.macAppStore());
|
||||
})
|
||||
).map(Boolean::parseBoolean).orElse(false);
|
||||
}
|
||||
|
||||
public static boolean isXcodeDevToolsInstalled() {
|
||||
return Inner.XCODE_DEV_TOOLS_INSTALLED;
|
||||
}
|
||||
|
||||
@ -106,7 +106,11 @@ final class PropertyFinder {
|
||||
|
||||
static Finder<JPackageCommand> cmdlineBooleanOption(String optionName) {
|
||||
return target -> {
|
||||
return Optional.of(target.hasArgument(optionName)).map(Boolean::valueOf).map(Object::toString);
|
||||
if (target.hasArgument(optionName)) {
|
||||
return Optional.of(Boolean.TRUE.toString());
|
||||
} else {
|
||||
return Optional.empty();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
*/
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@ -32,6 +33,7 @@ import jdk.jpackage.test.Annotations.ParameterSupplier;
|
||||
import jdk.jpackage.test.Annotations.Test;
|
||||
import jdk.jpackage.test.JPackageCommand;
|
||||
import jdk.jpackage.test.JPackageStringBundle;
|
||||
import jdk.jpackage.test.MacHelper;
|
||||
import jdk.jpackage.test.PackageTest;
|
||||
import jdk.jpackage.test.PackageType;
|
||||
import jdk.jpackage.test.TKit;
|
||||
@ -50,24 +52,23 @@ import jdk.jpackage.test.TKit;
|
||||
*/
|
||||
public class PkgScriptsTest {
|
||||
|
||||
public static Collection<?> input() {
|
||||
return List.of(new Object[][]{
|
||||
{ new PkgInstallScript[]{
|
||||
PkgInstallScript.PREINSTALL,
|
||||
PkgInstallScript.POSTINSTALL },
|
||||
},
|
||||
{ new PkgInstallScript[]{
|
||||
PkgInstallScript.PREINSTALL },
|
||||
},
|
||||
{ new PkgInstallScript[]{
|
||||
PkgInstallScript.POSTINSTALL },
|
||||
},
|
||||
});
|
||||
public static Collection<Object[]> input() {
|
||||
List<Object[]> data = new ArrayList<>();
|
||||
for (var appStore : List.of(true, false)) {
|
||||
for (var scriptRoles : List.of(
|
||||
List.of(PkgInstallScript.PREINSTALL, PkgInstallScript.POSTINSTALL),
|
||||
List.of(PkgInstallScript.PREINSTALL),
|
||||
List.of(PkgInstallScript.POSTINSTALL)
|
||||
)) {
|
||||
data.add(new Object[] {scriptRoles.toArray(PkgInstallScript[]::new), appStore});
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@Test
|
||||
@ParameterSupplier("input")
|
||||
public void test(PkgInstallScript[] customScriptRoles) {
|
||||
public void test(PkgInstallScript[] customScriptRoles, boolean appStore) {
|
||||
var responseDir = TKit.createTempDirectory("response");
|
||||
|
||||
var customScripts = Stream.of(customScriptRoles).map(role -> {
|
||||
@ -80,6 +81,9 @@ public class PkgScriptsTest {
|
||||
.forTypes(PackageType.MAC_PKG)
|
||||
.configureHelloApp()
|
||||
.addInitializer(cmd -> {
|
||||
if (appStore) {
|
||||
cmd.addArgument("--mac-app-store");
|
||||
}
|
||||
cmd.addArguments("--resource-dir", TKit.createTempDirectory("resources"));
|
||||
customScripts.forEach(customScript -> {
|
||||
customScript.createFor(cmd);
|
||||
@ -156,10 +160,13 @@ public class PkgScriptsTest {
|
||||
}
|
||||
|
||||
void verify(JPackageCommand cmd) {
|
||||
var scriptsEnabled = !MacHelper.isForAppStore(cmd);
|
||||
if (cmd.isPackageUnpacked()) {
|
||||
role.verifyExists(cmd, true);
|
||||
} else {
|
||||
role.verifyExists(cmd, scriptsEnabled);
|
||||
} else if (scriptsEnabled) {
|
||||
TKit.assertFileExists(responseFilePath(cmd));
|
||||
} else {
|
||||
TKit.assertPathExists(responseFilePath(cmd), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -33,6 +33,7 @@ import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Stream;
|
||||
import jdk.jpackage.test.AdditionalLauncher;
|
||||
import jdk.internal.util.OperatingSystem;
|
||||
import jdk.jpackage.test.Annotations.Parameter;
|
||||
import jdk.jpackage.test.Annotations.Test;
|
||||
import jdk.jpackage.test.ConfigurationTarget;
|
||||
@ -155,14 +156,21 @@ public class ServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Parameter("true")
|
||||
@Parameter("false")
|
||||
public void testAddL(boolean mainLauncherAsService) {
|
||||
@Parameter(value = {"true", "false"})
|
||||
@Parameter(value = {"false", "false"})
|
||||
@Parameter(value = {"true", "true"}, ifOS = OperatingSystem.MACOS)
|
||||
@Parameter(value = {"false", "true"}, ifOS = OperatingSystem.MACOS)
|
||||
public void testAddL(boolean mainLauncherAsService, boolean isMacAppStore) {
|
||||
|
||||
final var uniqueOutputFile = uniqueOutputFile();
|
||||
|
||||
createPackageTest()
|
||||
.addHelloAppInitializer("com.buz.AddLaunchersServiceTest")
|
||||
.addInitializer(cmd -> {
|
||||
if (isMacAppStore) {
|
||||
cmd.addArgument("--mac-app-store");
|
||||
}
|
||||
})
|
||||
.mutate(test -> {
|
||||
if (mainLauncherAsService) {
|
||||
LauncherAsServiceVerifier.build()
|
||||
@ -199,9 +207,11 @@ public class ServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Parameter("true")
|
||||
@Parameter("false")
|
||||
public void testAddLFromAppImage(boolean mainLauncherAsService) {
|
||||
@Parameter(value = {"true", "false"})
|
||||
@Parameter(value = {"false", "false"})
|
||||
@Parameter(value = {"true", "true"}, ifOS = OperatingSystem.MACOS)
|
||||
@Parameter(value = {"false", "true"}, ifOS = OperatingSystem.MACOS)
|
||||
public void testAddLFromAppImage(boolean mainLauncherAsService, boolean isMacAppStore) {
|
||||
|
||||
var uniqueOutputFile = uniqueOutputFile();
|
||||
|
||||
@ -213,6 +223,10 @@ public class ServiceTest {
|
||||
appImageCmd.addInitializer(JPackageCommand::ignoreFakeRuntime);
|
||||
}
|
||||
|
||||
if (isMacAppStore) {
|
||||
appImageCmd.cmd().orElseThrow().addArgument("--mac-app-store");
|
||||
}
|
||||
|
||||
if (mainLauncherAsService) {
|
||||
LauncherAsServiceVerifier.build()
|
||||
.mutate(uniqueOutputFile).appendAppOutputFileNamePrefix("-")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user