Skip to content

Commit a8fd72f

Browse files
Enhance RuntimePackageTest to test that jpackage can derive package name from the runtime image directory name if --name option is not given
1 parent 556feef commit a8fd72f

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

test/jdk/tools/jpackage/share/RuntimePackageTest.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@
2929
import java.util.function.Predicate;
3030
import java.util.stream.Collectors;
3131
import jdk.jpackage.test.PackageType;
32+
import jdk.jpackage.test.RunnablePackageTest.Action;
3233
import jdk.jpackage.test.PackageTest;
3334
import jdk.jpackage.test.JPackageCommand;
3435
import jdk.jpackage.test.TKit;
3536
import jdk.jpackage.test.Annotations.Test;
37+
import jdk.jpackage.test.Annotations.Parameter;
3638
import jdk.jpackage.test.Executor;
3739
import jdk.jpackage.test.JavaTool;
3840
import jdk.jpackage.test.LinuxHelper;
@@ -83,17 +85,24 @@ public static void test() {
8385
}
8486

8587
@Test
86-
public static void testUsrInstallDir() {
88+
@Parameter("/usr")
89+
@Parameter("/usr/lib/Java")
90+
public static void testUsrInstallDir(String installDir) {
8791
init(PackageType.LINUX)
8892
.addInitializer(cmd -> cmd.addArguments("--install-dir", "/usr"))
8993
.run();
9094
}
9195

9296
@Test
93-
public static void testUsrInstallDir2() {
94-
init(PackageType.LINUX)
95-
.addInitializer(cmd -> cmd.addArguments("--install-dir", "/usr/lib/Java"))
96-
.run();
97+
public static void testName() {
98+
// Test that jpackage can derive package name from the path to runtime image.
99+
init(PackageType.NATIVE)
100+
.addInitializer(cmd -> cmd.removeArgumentWithValue("--name"))
101+
// Don't attempt to install this package as it may have an odd name derived from
102+
// the runtime image path. Say, on Linux for `--runtime-image foo/bar/sed`
103+
// command line jpackage will create a package named 'sed' that will conflict
104+
// with the default 'sed' package.
105+
.run(Action.CREATE_AND_UNPACK);
97106
}
98107

99108
private static PackageTest init(Set<PackageType> types) {
@@ -157,7 +166,8 @@ private static PackageTest init(Set<PackageType> types) {
157166
"Check the package doesn't deliver [%s] copyright file",
158167
copyright));
159168
}
160-
});
169+
})
170+
.forTypes(types);
161171
}
162172

163173
private static Set<Path> listFiles(Path root) throws IOException {

0 commit comments

Comments
 (0)