Skip to content

Commit

Permalink
8236518: There is no Native Packages WinUpgradeUUIDTest-2.0.exe after…
Browse files Browse the repository at this point in the history
… creating Native packages on win

Reviewed-by: asemenyuk, almatvee
  • Loading branch information
Andy Herrick committed May 7, 2020
1 parent 1a16a4b commit 29f015c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ public Executor.Result execute(int expectedExitCode) {

if (isImagePackageType()) {
TKit.deleteDirectoryContentsRecursive(outputDir());
} else if (ThrowingSupplier.toSupplier(() -> Files.deleteIfExists(
} else if (ThrowingSupplier.toSupplier(() -> TKit.deleteIfExists(
outputBundle())).get()) {
TKit.trace(
String.format("Deleted [%s] file before running jpackage",
Expand Down
9 changes: 9 additions & 0 deletions test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,15 @@ public void accept(Path root) {
private boolean contentsOnly;
}

public static boolean deleteIfExists(Path path) throws IOException {
if (isWindows()) {
if (path.toFile().exists()) {
Files.setAttribute(path, "dos:readonly", false);
}
}
return Files.deleteIfExists(path);
}

/**
* Deletes contents of the given directory recursively. Shortcut for
* <code>deleteDirectoryContentsRecursive(path, null)</code>
Expand Down
15 changes: 8 additions & 7 deletions test/jdk/tools/jpackage/windows/WinUpgradeUUIDTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -65,7 +65,7 @@
* @requires (jpackage.test.SQETest == null)
* @build jdk.jpackage.test.*
* @requires (os.family == "windows")
* @modules jdk.jpackage/jdk.jpackage.internal
* @modules jdk.incubator.jpackage/jdk.incubator.jpackage.internal
* @compile WinUpgradeUUIDTest.java
* @run main/othervm/timeout=540 -Xmx512m jdk.jpackage.test.Main
* --jpt-run=WinUpgradeUUIDTest
Expand All @@ -79,10 +79,6 @@ public static void test() {
final UUID upgradeCode = UUID.fromString(
"F0B18E75-52AD-41A2-BC86-6BE4FCD50BEB");
return new PackageTest()
.forTypes(PackageType.WINDOWS)
.configureHelloApp()
.addInitializer(cmd -> cmd.addArguments("--win-upgrade-uuid",
upgradeCode.toString()))
.forTypes(PackageType.WIN_MSI)
.addBundlePropertyVerifier("UpgradeCode", value -> {
if (value.startsWith("{")) {
Expand All @@ -92,7 +88,12 @@ public static void test() {
value = value.substring(0, value.length() - 1);
}
return UUID.fromString(value).equals(upgradeCode);
}, "is a match with");
}, "is a match with")
.forTypes(PackageType.WINDOWS)
.configureHelloApp()
.addInitializer(cmd -> cmd.addArguments("--win-upgrade-uuid",
upgradeCode.toString())) ;

};

// Replace real uninstall command for the first package with nop action.
Expand Down

0 comments on commit 29f015c

Please sign in to comment.