|
25 | 25 | import java.nio.file.Files;
|
26 | 26 | import java.io.IOException;
|
27 | 27 | import java.util.List;
|
| 28 | +import jdk.jpackage.internal.AppImageFile; |
28 | 29 | import jdk.jpackage.test.Annotations.Parameter;
|
29 | 30 | import jdk.jpackage.test.TKit;
|
30 | 31 | import jdk.jpackage.test.JPackageCommand;
|
@@ -101,6 +102,55 @@ public static void testEmpty(boolean withIcon) throws IOException {
|
101 | 102 | // default: {CREATE, UNPACK, VERIFY}, but we can't verify foreign image
|
102 | 103 | }
|
103 | 104 |
|
| 105 | + @Test |
| 106 | + public static void testBadAppImage() throws IOException { |
| 107 | + Path appImageDir = TKit.createTempDirectory("appimage"); |
| 108 | + Files.createFile(appImageDir.resolve("foo")); |
| 109 | + configureAppImageWithoutJPackageXMLFile(appImageDir).addInitializer( |
| 110 | + cmd -> { |
| 111 | + cmd.removeArgumentWithValue("--name"); |
| 112 | + }).run(Action.CREATE); |
| 113 | + } |
| 114 | + |
| 115 | + @Test |
| 116 | + public static void testBadAppImage2() throws IOException { |
| 117 | + Path appImageDir = TKit.createTempDirectory("appimage"); |
| 118 | + Files.createFile(appImageDir.resolve("foo")); |
| 119 | + configureAppImageWithoutJPackageXMLFile(appImageDir).run(Action.CREATE); |
| 120 | + } |
| 121 | + |
| 122 | + @Test |
| 123 | + public static void testBadAppImage3() throws IOException { |
| 124 | + Path appImageDir = TKit.createTempDirectory("appimage"); |
| 125 | + |
| 126 | + JPackageCommand appImageCmd = JPackageCommand.helloAppImage(). |
| 127 | + setFakeRuntime().setArgumentValue("--dest", appImageDir); |
| 128 | + |
| 129 | + configureAppImageWithoutJPackageXMLFile(appImageCmd.outputBundle()). |
| 130 | + addRunOnceInitializer(() -> { |
| 131 | + appImageCmd.execute(); |
| 132 | + Files.delete(AppImageFile.getPathInAppImage(appImageCmd. |
| 133 | + outputBundle())); |
| 134 | + }).run(Action.CREATE); |
| 135 | + } |
| 136 | + |
| 137 | + private static PackageTest configureAppImageWithoutJPackageXMLFile( |
| 138 | + Path appImageDir) { |
| 139 | + return new PackageTest() |
| 140 | + .addInitializer(cmd -> { |
| 141 | + cmd.saveConsoleOutput(true); |
| 142 | + cmd.addArguments("--app-image", appImageDir); |
| 143 | + cmd.removeArgumentWithValue("--input"); |
| 144 | + cmd.ignoreDefaultVerbose(true); // no "--verbose" option |
| 145 | + }) |
| 146 | + .addBundleVerifier((cmd, result) -> { |
| 147 | + TKit.assertTextStream( |
| 148 | + "Error: Missing .jpackage.xml file in app-image dir").apply( |
| 149 | + result.getOutput().stream()); |
| 150 | + }) |
| 151 | + .setExpectedExitCode(1); |
| 152 | + } |
| 153 | + |
104 | 154 | private static Path iconPath(String name) {
|
105 | 155 | return TKit.TEST_SRC_ROOT.resolve(Path.of("resources", name
|
106 | 156 | + TKit.ICON_SUFFIX));
|
|
0 commit comments