diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2022-02-22 20:23:43 -0600 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2022-02-22 23:37:57 -0600 |
| commit | 8e8f724d90c6835febb8b5865009746aea73a334 (patch) | |
| tree | b255c0a7232af8d24bcf44fd476b95bdfdcfe777 /src/test | |
| parent | 0740d93ca8be06ec0e5da5b51ceff52f67ab5bf5 (diff) | |
| download | wix-8e8f724d90c6835febb8b5865009746aea73a334.tar.gz wix-8e8f724d90c6835febb8b5865009746aea73a334.tar.bz2 wix-8e8f724d90c6835febb8b5865009746aea73a334.zip | |
Add UnsafeUninstall action.
Fixes #6721
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/burn/WixTestTools/BundleInstaller.cs | 30 | ||||
| -rw-r--r-- | src/test/burn/WixTestTools/MSIExec.cs | 5 | ||||
| -rw-r--r-- | src/test/burn/WixToolsetTest.BurnE2E/ForwardCompatibleBundleTests.cs | 46 |
3 files changed, 74 insertions, 7 deletions
diff --git a/src/test/burn/WixTestTools/BundleInstaller.cs b/src/test/burn/WixTestTools/BundleInstaller.cs index a49c4024..2b449ebf 100644 --- a/src/test/burn/WixTestTools/BundleInstaller.cs +++ b/src/test/burn/WixTestTools/BundleInstaller.cs | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | namespace WixTestTools | 3 | namespace WixTestTools |
| 4 | { | 4 | { |
| 5 | using System; | 5 | using System; |
| 6 | using System.Collections.Generic; | ||
| 6 | using System.IO; | 7 | using System.IO; |
| 7 | using System.Text; | 8 | using System.Text; |
| 8 | 9 | ||
| @@ -131,6 +132,35 @@ namespace WixTestTools | |||
| 131 | } | 132 | } |
| 132 | 133 | ||
| 133 | /// <summary> | 134 | /// <summary> |
| 135 | /// Uninstalls the bundle unsafely with optional arguments. | ||
| 136 | /// </summary> | ||
| 137 | /// <param name="expectedExitCode">Expected exit code, defaults to success.</param> | ||
| 138 | /// <param name="arguments">Optional arguments to pass to the tool.</param> | ||
| 139 | /// <returns>Path to the generated log file.</returns> | ||
| 140 | public string UnsafeUninstall(int expectedExitCode = (int)MSIExec.MSIExecReturnCode.SUCCESS, params string[] arguments) | ||
| 141 | { | ||
| 142 | var newArgumentList = new List<string>(); | ||
| 143 | newArgumentList.Add("-unsafeuninstall"); | ||
| 144 | newArgumentList.AddRange(arguments); | ||
| 145 | return this.RunBundleWithArguments(expectedExitCode, MSIExec.MSIExecMode.Custom, newArgumentList.ToArray()); | ||
| 146 | } | ||
| 147 | |||
| 148 | /// <summary> | ||
| 149 | /// Uninstalls the bundle unsafely at the given path with optional arguments. | ||
| 150 | /// </summary> | ||
| 151 | /// <param name="bundlePath">This should be the bundle in the package cache.</param> | ||
| 152 | /// <param name="expectedExitCode">Expected exit code, defaults to success.</param> | ||
| 153 | /// <param name="arguments">Optional arguments to pass to the tool.</param> | ||
| 154 | /// <returns>Path to the generated log file.</returns> | ||
| 155 | public string UnsafeUninstall(string bundlePath, int expectedExitCode = (int)MSIExec.MSIExecReturnCode.SUCCESS, params string[] arguments) | ||
| 156 | { | ||
| 157 | var newArgumentList = new List<string>(); | ||
| 158 | newArgumentList.Add("-unsafeuninstall"); | ||
| 159 | newArgumentList.AddRange(arguments); | ||
| 160 | return this.RunBundleWithArguments(expectedExitCode, MSIExec.MSIExecMode.Custom, newArgumentList.ToArray(), bundlePath: bundlePath); | ||
| 161 | } | ||
| 162 | |||
| 163 | /// <summary> | ||
| 134 | /// Executes the bundle with optional arguments. | 164 | /// Executes the bundle with optional arguments. |
| 135 | /// </summary> | 165 | /// </summary> |
| 136 | /// <param name="expectedExitCode">Expected exit code.</param> | 166 | /// <param name="expectedExitCode">Expected exit code.</param> |
diff --git a/src/test/burn/WixTestTools/MSIExec.cs b/src/test/burn/WixTestTools/MSIExec.cs index 8dce96cf..a10a48d6 100644 --- a/src/test/burn/WixTestTools/MSIExec.cs +++ b/src/test/burn/WixTestTools/MSIExec.cs | |||
| @@ -697,6 +697,11 @@ namespace WixTestTools | |||
| 697 | /// Uninstalls the product as part of cleanup | 697 | /// Uninstalls the product as part of cleanup |
| 698 | /// </summary> | 698 | /// </summary> |
| 699 | Cleanup, | 699 | Cleanup, |
| 700 | |||
| 701 | /// <summary> | ||
| 702 | /// No action automatically added to arguments | ||
| 703 | /// </summary> | ||
| 704 | Custom, | ||
| 700 | } | 705 | } |
| 701 | 706 | ||
| 702 | /// <summary> | 707 | /// <summary> |
diff --git a/src/test/burn/WixToolsetTest.BurnE2E/ForwardCompatibleBundleTests.cs b/src/test/burn/WixToolsetTest.BurnE2E/ForwardCompatibleBundleTests.cs index eb649c86..357cf515 100644 --- a/src/test/burn/WixToolsetTest.BurnE2E/ForwardCompatibleBundleTests.cs +++ b/src/test/burn/WixToolsetTest.BurnE2E/ForwardCompatibleBundleTests.cs | |||
| @@ -18,6 +18,38 @@ namespace WixToolsetTest.BurnE2E | |||
| 18 | private const string V200 = "2.0.0.0"; | 18 | private const string V200 = "2.0.0.0"; |
| 19 | 19 | ||
| 20 | [Fact] | 20 | [Fact] |
| 21 | public void CanIgnoreBundleDependentForUnsafeUninstall() | ||
| 22 | { | ||
| 23 | string providerId = BundleAProviderId; | ||
| 24 | string parent = "~BundleAv1"; | ||
| 25 | string parentSwitch = String.Concat("-parent ", parent); | ||
| 26 | |||
| 27 | var packageAv1 = this.CreatePackageInstaller("PackageAv1"); | ||
| 28 | var bundleAv1 = this.CreateBundleInstaller("BundleAv1"); | ||
| 29 | var testBAController = this.CreateTestBAController(); | ||
| 30 | |||
| 31 | packageAv1.VerifyInstalled(false); | ||
| 32 | |||
| 33 | // Install the v1 bundle with a parent. | ||
| 34 | bundleAv1.Install(arguments: parentSwitch); | ||
| 35 | bundleAv1.VerifyRegisteredAndInPackageCache(); | ||
| 36 | |||
| 37 | packageAv1.VerifyInstalled(true); | ||
| 38 | Assert.True(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out var actualProviderVersion)); | ||
| 39 | Assert.Equal(V100, actualProviderVersion); | ||
| 40 | Assert.True(BundleRegistration.DependencyDependentExists(providerId, parent)); | ||
| 41 | |||
| 42 | // Cancel package B right away. | ||
| 43 | testBAController.SetPackageCancelExecuteAtProgress("PackageA", 1); | ||
| 44 | |||
| 45 | bundleAv1.UnsafeUninstall((int)MSIExec.MSIExecReturnCode.ERROR_INSTALL_USEREXIT); | ||
| 46 | bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache(); | ||
| 47 | |||
| 48 | packageAv1.VerifyInstalled(true); | ||
| 49 | Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out _)); | ||
| 50 | } | ||
| 51 | |||
| 52 | [Fact] | ||
| 21 | public void CanTrack1ForwardCompatibleDependentThroughMajorUpgrade() | 53 | public void CanTrack1ForwardCompatibleDependentThroughMajorUpgrade() |
| 22 | { | 54 | { |
| 23 | string providerId = BundleAProviderId; | 55 | string providerId = BundleAProviderId; |
| @@ -70,7 +102,7 @@ namespace WixToolsetTest.BurnE2E | |||
| 70 | 102 | ||
| 71 | packageAv1.VerifyInstalled(false); | 103 | packageAv1.VerifyInstalled(false); |
| 72 | packageAv2.VerifyInstalled(false); | 104 | packageAv2.VerifyInstalled(false); |
| 73 | Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion)); | 105 | Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out _)); |
| 74 | } | 106 | } |
| 75 | 107 | ||
| 76 | [Fact] | 108 | [Fact] |
| @@ -116,7 +148,7 @@ namespace WixToolsetTest.BurnE2E | |||
| 116 | 148 | ||
| 117 | packageAv1.VerifyInstalled(false); | 149 | packageAv1.VerifyInstalled(false); |
| 118 | packageAv2.VerifyInstalled(false); | 150 | packageAv2.VerifyInstalled(false); |
| 119 | Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion)); | 151 | Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out _)); |
| 120 | } | 152 | } |
| 121 | 153 | ||
| 122 | [Fact] | 154 | [Fact] |
| @@ -198,7 +230,7 @@ namespace WixToolsetTest.BurnE2E | |||
| 198 | 230 | ||
| 199 | packageAv1.VerifyInstalled(false); | 231 | packageAv1.VerifyInstalled(false); |
| 200 | packageAv2.VerifyInstalled(false); | 232 | packageAv2.VerifyInstalled(false); |
| 201 | Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion)); | 233 | Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out _)); |
| 202 | } | 234 | } |
| 203 | 235 | ||
| 204 | [Fact] | 236 | [Fact] |
| @@ -280,7 +312,7 @@ namespace WixToolsetTest.BurnE2E | |||
| 280 | 312 | ||
| 281 | packageCv1.VerifyInstalled(false); | 313 | packageCv1.VerifyInstalled(false); |
| 282 | packageCv2.VerifyInstalled(false); | 314 | packageCv2.VerifyInstalled(false); |
| 283 | Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion)); | 315 | Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out _)); |
| 284 | } | 316 | } |
| 285 | 317 | ||
| 286 | [Fact] | 318 | [Fact] |
| @@ -366,7 +398,7 @@ namespace WixToolsetTest.BurnE2E | |||
| 366 | 398 | ||
| 367 | packageAv1.VerifyInstalled(false); | 399 | packageAv1.VerifyInstalled(false); |
| 368 | packageAv2.VerifyInstalled(false); | 400 | packageAv2.VerifyInstalled(false); |
| 369 | Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion)); | 401 | Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out _)); |
| 370 | } | 402 | } |
| 371 | 403 | ||
| 372 | [Fact] | 404 | [Fact] |
| @@ -414,7 +446,7 @@ namespace WixToolsetTest.BurnE2E | |||
| 414 | 446 | ||
| 415 | packageAv1.VerifyInstalled(false); | 447 | packageAv1.VerifyInstalled(false); |
| 416 | packageAv2.VerifyInstalled(false); | 448 | packageAv2.VerifyInstalled(false); |
| 417 | Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion)); | 449 | Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out _)); |
| 418 | } | 450 | } |
| 419 | 451 | ||
| 420 | [Fact] | 452 | [Fact] |
| @@ -463,7 +495,7 @@ namespace WixToolsetTest.BurnE2E | |||
| 463 | 495 | ||
| 464 | packageAv1.VerifyInstalled(false); | 496 | packageAv1.VerifyInstalled(false); |
| 465 | packageAv2.VerifyInstalled(false); | 497 | packageAv2.VerifyInstalled(false); |
| 466 | Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out actualProviderVersion)); | 498 | Assert.False(BundleRegistration.TryGetDependencyProviderValue(providerId, "Version", out _)); |
| 467 | } | 499 | } |
| 468 | } | 500 | } |
| 469 | } | 501 | } |
