Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8350013: Add a test for JDK-8150442 #23825

Closed
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
79719ee
Convert helpers-test tests to junit format. It is easier to debug the…
alexeysemenyukoracle Feb 8, 2025
115f4ef
Make junit pass
alexeysemenyukoracle Feb 12, 2025
2d929b1
Manual merge
alexeysemenyukoracle Feb 13, 2025
c66c591
Fix AnnotationsTest to create test work directory in temp directory s…
alexeysemenyukoracle Feb 12, 2025
5b9d7e0
Fix bug in TestBuilder that created tests for functions without @Test…
alexeysemenyukoracle Feb 12, 2025
eb36f4d
Can use @ParameterSupplier annotation without a value.
alexeysemenyukoracle Feb 12, 2025
45a2ab5
Undo unrelated change
alexeysemenyukoracle Feb 13, 2025
bd6018a
Merge branch 'decouple-junit' into decouple-fix-annotations
alexeysemenyukoracle Feb 13, 2025
45eec0e
Revert "Undo unrelated change"
alexeysemenyukoracle Feb 13, 2025
c216296
Minor
alexeysemenyukoracle Feb 12, 2025
292d8fb
Fix typo
alexeysemenyukoracle Feb 12, 2025
c4215e4
Merge branch 'decouple-junit' into decouple-fix-annotations
alexeysemenyukoracle Feb 13, 2025
691c5f9
Decouple Executor.Result and Executor classes
alexeysemenyukoracle Feb 11, 2025
781100e
Bugfix Executor.createResult() and add Executor.getExecutable()
alexeysemenyukoracle Feb 12, 2025
5922465
Rework TKit.createTempFile() to make it create unique file names not …
alexeysemenyukoracle Feb 12, 2025
a0d6625
Cleanup
alexeysemenyukoracle Feb 12, 2025
5b43d3f
Unified TKit.createTempFile() and TKit.createTempDirectory()
alexeysemenyukoracle Feb 12, 2025
12c810b
Better shape TKitTest.testCreateTempDirectory() and TKitTest.testCrea…
alexeysemenyukoracle Feb 12, 2025
dcf393a
Remove "throws IOException" from TKit.createTempDirectory() and TKit.…
alexeysemenyukoracle Feb 13, 2025
87050e7
Allow install action exit with non-zero exit code. Can be handy to te…
alexeysemenyukoracle Feb 6, 2025
d26497f
Added tests for PackageTest class
alexeysemenyukoracle Feb 11, 2025
929b356
Manual merge
alexeysemenyukoracle Feb 13, 2025
e60f42a
Better test coverage for PackageTest
alexeysemenyukoracle Feb 11, 2025
0f52bcf
Add a test for OS-version condition
alexeysemenyukoracle Feb 12, 2025
e6ba3db
Added WindowsHelper.lastMsiLogFile()
alexeysemenyukoracle Feb 12, 2025
26fffa7
Revisit msi log configuration. Decouple internals of PackageTest clas…
alexeysemenyukoracle Feb 12, 2025
7c59054
Rerun only unpack if exit code is 1603
alexeysemenyukoracle Feb 13, 2025
b5fb3bf
Improve PackageTest.PackageTypePipeline implementation
alexeysemenyukoracle Feb 13, 2025
d0c815d
Remove TKit.assertEquals(boolean) and TKit.assertNotEquals(boolean). …
alexeysemenyukoracle Feb 13, 2025
399c15f
Merge branch 'decouple-junit' into decouple-fix-annotations
alexeysemenyukoracle Feb 13, 2025
d6b7f8e
Merge branch 'decouple-fix-annotations' into decouple-executor-result
alexeysemenyukoracle Feb 13, 2025
b37fa2f
Merge branch 'decouple-executor-result' into decouple-tkit
alexeysemenyukoracle Feb 13, 2025
1fdb01c
Fix merge
alexeysemenyukoracle Feb 13, 2025
294136b
Merge branch 'decouple-tkit' into decouple-os-condition
alexeysemenyukoracle Feb 13, 2025
ae5ddc7
Remove redundant "return"
alexeysemenyukoracle Feb 14, 2025
2c39345
Merge branch 'master' into decouple-junit
alexeysemenyukoracle Feb 14, 2025
09cec2f
Merge branch 'decouple-junit' into decouple-fix-annotations
alexeysemenyukoracle Feb 14, 2025
1247c84
Fix javac error
alexeysemenyukoracle Feb 14, 2025
f7d104c
Merge branch 'decouple-fix-annotations' into decouple-executor-result
alexeysemenyukoracle Feb 14, 2025
937c46f
Merge branch 'decouple-executor-result' into decouple-tkit
alexeysemenyukoracle Feb 14, 2025
74c2ac5
Test if the main jar is in the app image if specified.
alexeysemenyukoracle Feb 14, 2025
e6614c0
Merge branch 'master' into decouple-tkit
alexeysemenyukoracle Feb 24, 2025
01fa252
Better test description and add tests for roles with dots
alexeysemenyukoracle Feb 24, 2025
e1a7d43
Better log message
alexeysemenyukoracle Feb 24, 2025
56d6326
Merge branch 'decouple-tkit' into decouple-os-condition
alexeysemenyukoracle Feb 24, 2025
9d24e48
Merge branch 'master' into decouple-os-condition
alexeysemenyukoracle Feb 27, 2025
a27cb52
Cleanup
alexeysemenyukoracle Feb 27, 2025
43ff870
Cleanup
alexeysemenyukoracle Feb 28, 2025
a38876d
Trailing whitespace cleanup
alexeysemenyukoracle Feb 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@

import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.SecureRandom;
@@ -76,6 +77,7 @@ public JPackageCommand(JPackageCommand cmd) {
appLayoutAsserts = cmd.appLayoutAsserts;
outputValidator = cmd.outputValidator;
executeInDirectory = cmd.executeInDirectory;
winMsiLogFile = cmd.winMsiLogFile;
}

JPackageCommand createImmutableCopy() {
@@ -992,6 +994,22 @@ JPackageCommand setUnpackedPackageLocation(Path path) {
return this;
}

JPackageCommand winMsiLogFile(Path v) {
this.winMsiLogFile = v;
return this;
}

public Optional<Path> winMsiLogFile() {
return Optional.ofNullable(winMsiLogFile);
}

public Optional<Stream<String>> winMsiLogFileContents() {
return winMsiLogFile().map(ThrowingFunction.toFunction(msiLog -> {
// MSI log files are UTF16LE-encoded
return Files.lines(msiLog, StandardCharsets.UTF_16LE);
}));
}

private JPackageCommand adjustArgumentsBeforeExecution() {
if (!isWithToolProvider()) {
// if jpackage is launched as a process then set the jlink.debug system property
@@ -1168,6 +1186,7 @@ public void run() {
private final Actions prerequisiteActions;
private final Actions verifyActions;
private Path executeInDirectory;
private Path winMsiLogFile;
private Set<AppLayoutAssert> appLayoutAsserts = Set.of(AppLayoutAssert.values());
private Consumer<Stream<String>> outputValidator;
private static boolean defaultWithToolProvider;
99 changes: 51 additions & 48 deletions test/jdk/tools/jpackage/helpers/jdk/jpackage/test/LinuxHelper.java
Original file line number Diff line number Diff line change
@@ -195,58 +195,61 @@ public static String getBundleProperty(JPackageCommand cmd,
}

static PackageHandlers createDebPackageHandlers() {
PackageHandlers deb = new PackageHandlers();
deb.installHandler = cmd -> {
cmd.verifyIsOfType(PackageType.LINUX_DEB);
Executor.of("sudo", "dpkg", "-i")
.addArgument(cmd.outputBundle())
.execute();
};
deb.uninstallHandler = cmd -> {
cmd.verifyIsOfType(PackageType.LINUX_DEB);
var packageName = getPackageName(cmd);
String script = String.format("! dpkg -s %s || sudo dpkg -r %s",
packageName, packageName);
Executor.of("sh", "-c", script).execute();
};
deb.unpackHandler = (cmd, destinationDir) -> {
cmd.verifyIsOfType(PackageType.LINUX_DEB);
Executor.of("dpkg", "-x")
.addArgument(cmd.outputBundle())
.addArgument(destinationDir)
.execute();
return destinationDir;
};
return deb;
return new PackageHandlers(LinuxHelper::installDeb, LinuxHelper::uninstallDeb, LinuxHelper::unpackDeb);
}

private static int installDeb(JPackageCommand cmd) {
cmd.verifyIsOfType(PackageType.LINUX_DEB);
return Executor.of("sudo", "dpkg", "-i")
.addArgument(cmd.outputBundle())
.execute().getExitCode();
}

private static void uninstallDeb(JPackageCommand cmd) {
cmd.verifyIsOfType(PackageType.LINUX_DEB);
var packageName = getPackageName(cmd);
String script = String.format("! dpkg -s %s || sudo dpkg -r %s",
packageName, packageName);
Executor.of("sh", "-c", script).execute();
}

private static Path unpackDeb(JPackageCommand cmd, Path destinationDir) {
cmd.verifyIsOfType(PackageType.LINUX_DEB);
Executor.of("dpkg", "-x")
.addArgument(cmd.outputBundle())
.addArgument(destinationDir)
.execute(0);
return destinationDir;
}

static PackageHandlers createRpmPackageHandlers() {
PackageHandlers rpm = new PackageHandlers();
rpm.installHandler = cmd -> {
cmd.verifyIsOfType(PackageType.LINUX_RPM);
Executor.of("sudo", "rpm", "-U")
.addArgument(cmd.outputBundle())
.execute();
};
rpm.uninstallHandler = cmd -> {
cmd.verifyIsOfType(PackageType.LINUX_RPM);
var packageName = getPackageName(cmd);
String script = String.format("! rpm -q %s || sudo rpm -e %s",
packageName, packageName);
Executor.of("sh", "-c", script).execute();
};
rpm.unpackHandler = (cmd, destinationDir) -> {
cmd.verifyIsOfType(PackageType.LINUX_RPM);
Executor.of("sh", "-c", String.format(
"rpm2cpio '%s' | cpio -idm --quiet",
JPackageCommand.escapeAndJoin(
cmd.outputBundle().toAbsolutePath().toString())))
.setDirectory(destinationDir)
.execute();
return destinationDir;
};
return new PackageHandlers(LinuxHelper::installRpm, LinuxHelper::uninstallRpm, LinuxHelper::unpackRpm);
}

return rpm;
private static int installRpm(JPackageCommand cmd) {
cmd.verifyIsOfType(PackageType.LINUX_RPM);
return Executor.of("sudo", "rpm", "-U")
.addArgument(cmd.outputBundle())
.execute().getExitCode();
}

private static void uninstallRpm(JPackageCommand cmd) {
cmd.verifyIsOfType(PackageType.LINUX_RPM);
var packageName = getPackageName(cmd);
String script = String.format("! rpm -q %s || sudo rpm -e %s",
packageName, packageName);
Executor.of("sh", "-c", script).execute();
}

private static Path unpackRpm(JPackageCommand cmd, Path destinationDir) {
cmd.verifyIsOfType(PackageType.LINUX_RPM);
Executor.of("sh", "-c", String.format(
"rpm2cpio '%s' | cpio -idm --quiet",
JPackageCommand.escapeAndJoin(
cmd.outputBundle().toAbsolutePath().toString())))
.setDirectory(destinationDir)
.execute(0);
return destinationDir;
}

static Path getLauncherPath(JPackageCommand cmd) {
Loading