diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2022-06-14 15:10:07 -0500 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2022-06-14 21:51:14 -0500 |
| commit | 98c369a92891244bde76448ae4a2b623b3ab394c (patch) | |
| tree | 398105d02a888ba41b426e84965375e491d79bb7 /src/test | |
| parent | dea657295df261bb0e3e4d620eeae321531e3a11 (diff) | |
| download | wix-98c369a92891244bde76448ae4a2b623b3ab394c.tar.gz wix-98c369a92891244bde76448ae4a2b623b3ab394c.tar.bz2 wix-98c369a92891244bde76448ae4a2b623b3ab394c.zip | |
Allow BundlePackage to fallback to QuietUninstallString to uninstall.
Partial implementation of 6756
Diffstat (limited to 'src/test')
5 files changed, 167 insertions, 2 deletions
diff --git a/src/test/burn/TestData/BundlePackageTests/BundlePackageUninstallFailureBundle/BundlePackageUninstallFailureBundle.wixproj b/src/test/burn/TestData/BundlePackageTests/BundlePackageUninstallFailureBundle/BundlePackageUninstallFailureBundle.wixproj new file mode 100644 index 00000000..276d9dcb --- /dev/null +++ b/src/test/burn/TestData/BundlePackageTests/BundlePackageUninstallFailureBundle/BundlePackageUninstallFailureBundle.wixproj | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | <!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. --> | ||
| 2 | <Project Sdk="WixToolset.Sdk"> | ||
| 3 | <PropertyGroup> | ||
| 4 | <OutputType>Bundle</OutputType> | ||
| 5 | <UpgradeCode>{1CD57FE5-A2FA-4A72-BEBA-74D9730C2C93}</UpgradeCode> | ||
| 6 | </PropertyGroup> | ||
| 7 | <ItemGroup> | ||
| 8 | <Compile Include="..\..\Templates\Bundle.wxs" Link="Bundle.wxs" /> | ||
| 9 | </ItemGroup> | ||
| 10 | <ItemGroup> | ||
| 11 | <ProjectReference Include="..\PackageFail\PackageFail.wixproj" /> | ||
| 12 | <ProjectReference Include="..\..\BasicFunctionalityTests\BundleA\BundleA.wixproj" /> | ||
| 13 | <ProjectReference Include="..\..\TestBA\TestBAWixlib\testbawixlib.wixproj" /> | ||
| 14 | </ItemGroup> | ||
| 15 | <ItemGroup> | ||
| 16 | <PackageReference Include="WixToolset.Bal.wixext" /> | ||
| 17 | <PackageReference Include="WixToolset.NetFx.wixext" /> | ||
| 18 | </ItemGroup> | ||
| 19 | </Project> \ No newline at end of file | ||
diff --git a/src/test/burn/TestData/BundlePackageTests/BundlePackageUninstallFailureBundle/BundlePackageUninstallFailureBundle.wxs b/src/test/burn/TestData/BundlePackageTests/BundlePackageUninstallFailureBundle/BundlePackageUninstallFailureBundle.wxs new file mode 100644 index 00000000..1e27161c --- /dev/null +++ b/src/test/burn/TestData/BundlePackageTests/BundlePackageUninstallFailureBundle/BundlePackageUninstallFailureBundle.wxs | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | <!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. --> | ||
| 2 | |||
| 3 | |||
| 4 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal"> | ||
| 5 | <Fragment> | ||
| 6 | <Variable Name="FAILWHENDEFERRED" bal:Overridable="yes" /> | ||
| 7 | |||
| 8 | <PackageGroup Id="BundlePackages"> | ||
| 9 | <MsiPackage Id="PackageFail" SourceFile="$(var.PackageFail.TargetPath)"> | ||
| 10 | <MsiProperty Name="WIXFAILWHENDEFERRED" Value="[FAILWHENDEFERRED]" /> | ||
| 11 | </MsiPackage> | ||
| 12 | <BundlePackage Id="PackageA" SourceFile="$(var.BundleA.TargetPath)" /> | ||
| 13 | </PackageGroup> | ||
| 14 | </Fragment> | ||
| 15 | </Wix> | ||
diff --git a/src/test/burn/TestData/BundlePackageTests/PackageFail/PackageFail.wixproj b/src/test/burn/TestData/BundlePackageTests/PackageFail/PackageFail.wixproj new file mode 100644 index 00000000..68b5470b --- /dev/null +++ b/src/test/burn/TestData/BundlePackageTests/PackageFail/PackageFail.wixproj | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | <!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. --> | ||
| 2 | <Project Sdk="WixToolset.Sdk"> | ||
| 3 | <PropertyGroup> | ||
| 4 | <UpgradeCode>{2674BFB2-634D-42DB-A1EC-C2CD148A2328}</UpgradeCode> | ||
| 5 | </PropertyGroup> | ||
| 6 | <ItemGroup> | ||
| 7 | <Compile Include="..\..\Templates\PackageFail.wxs" Link="PackageFail.wxs" /> | ||
| 8 | </ItemGroup> | ||
| 9 | <ItemGroup> | ||
| 10 | <PackageReference Include="WixToolset.Util.wixext" /> | ||
| 11 | </ItemGroup> | ||
| 12 | </Project> \ No newline at end of file | ||
diff --git a/src/test/burn/WixTestTools/BundleVerifier.cs b/src/test/burn/WixTestTools/BundleVerifier.cs index ff45a291..3a19ca02 100644 --- a/src/test/burn/WixTestTools/BundleVerifier.cs +++ b/src/test/burn/WixTestTools/BundleVerifier.cs | |||
| @@ -158,14 +158,21 @@ namespace WixTestTools | |||
| 158 | } | 158 | } |
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | public void VerifyPackageIsCached(string packageId, bool cached = true) | 161 | public string GetPackageEntryPointCachePath(string packageId) |
| 162 | { | 162 | { |
| 163 | using var wixOutput = WixOutput.Read(this.BundlePdb); | 163 | using var wixOutput = WixOutput.Read(this.BundlePdb); |
| 164 | var intermediate = Intermediate.Load(wixOutput); | 164 | var intermediate = Intermediate.Load(wixOutput); |
| 165 | var section = intermediate.Sections.Single(); | 165 | var section = intermediate.Sections.Single(); |
| 166 | var packageSymbol = section.Symbols.OfType<WixBundlePackageSymbol>().Single(p => p.Id.Id == packageId); | 166 | var packageSymbol = section.Symbols.OfType<WixBundlePackageSymbol>().Single(p => p.Id.Id == packageId); |
| 167 | var packagePayloadSymbol = section.Symbols.OfType<WixBundlePayloadSymbol>().Single(p => p.Id.Id == packageSymbol.PayloadRef); | ||
| 167 | var cachePath = this.GetPackageCachePathForCacheId(packageSymbol.CacheId, packageSymbol.PerMachine == true); | 168 | var cachePath = this.GetPackageCachePathForCacheId(packageSymbol.CacheId, packageSymbol.PerMachine == true); |
| 168 | Assert.Equal(cached, Directory.Exists(cachePath)); | 169 | return Path.Combine(cachePath, packagePayloadSymbol.Name); |
| 170 | } | ||
| 171 | |||
| 172 | public void VerifyPackageIsCached(string packageId, bool cached = true) | ||
| 173 | { | ||
| 174 | var entryPointCachePath = this.GetPackageEntryPointCachePath(packageId); | ||
| 175 | Assert.Equal(cached, File.Exists(entryPointCachePath)); | ||
| 169 | } | 176 | } |
| 170 | 177 | ||
| 171 | public void VerifyPackageProviderRemoved(string packageId) | 178 | public void VerifyPackageProviderRemoved(string packageId) |
diff --git a/src/test/burn/WixToolsetTest.BurnE2E/BundlePackageTests.cs b/src/test/burn/WixToolsetTest.BurnE2E/BundlePackageTests.cs index 0c6e5873..b3ef9430 100644 --- a/src/test/burn/WixToolsetTest.BurnE2E/BundlePackageTests.cs +++ b/src/test/burn/WixToolsetTest.BurnE2E/BundlePackageTests.cs | |||
| @@ -5,6 +5,7 @@ namespace WixToolsetTest.BurnE2E | |||
| 5 | using System; | 5 | using System; |
| 6 | using System.IO; | 6 | using System.IO; |
| 7 | using WixTestTools; | 7 | using WixTestTools; |
| 8 | using WixToolset.Mba.Core; | ||
| 8 | using Xunit; | 9 | using Xunit; |
| 9 | using Xunit.Abstractions; | 10 | using Xunit.Abstractions; |
| 10 | 11 | ||
| @@ -137,5 +138,116 @@ namespace WixToolsetTest.BurnE2E | |||
| 137 | upgradeBundlePackageBundlev1.VerifyUnregisteredAndRemovedFromPackageCache(); | 138 | upgradeBundlePackageBundlev1.VerifyUnregisteredAndRemovedFromPackageCache(); |
| 138 | bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache(); | 139 | bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache(); |
| 139 | } | 140 | } |
| 141 | |||
| 142 | [RuntimeFact] | ||
| 143 | public void CanRecacheAndReinstallBundlePackageOnUninstallRollback() | ||
| 144 | { | ||
| 145 | var packageFail = this.CreatePackageInstaller("PackageFail"); | ||
| 146 | var packageA = this.CreatePackageInstaller(@"..\BasicFunctionalityTests\PackageA"); | ||
| 147 | var bundleA = this.CreateBundleInstaller(@"..\BasicFunctionalityTests\BundleA"); | ||
| 148 | var bundlePackageUninstallFailureBundle = this.CreateBundleInstaller("BundlePackageUninstallFailureBundle"); | ||
| 149 | var testBAController = this.CreateTestBAController(); | ||
| 150 | var bundleASelfCachedPath = bundleA.GetExpectedCachedBundlePath(); | ||
| 151 | var bundleAEmbeddedCachedPath = bundlePackageUninstallFailureBundle.GetPackageEntryPointCachePath("PackageA"); | ||
| 152 | |||
| 153 | packageA.VerifyInstalled(false); | ||
| 154 | packageFail.VerifyInstalled(false); | ||
| 155 | bundleA.VerifyUnregisteredAndRemovedFromPackageCache(); | ||
| 156 | |||
| 157 | testBAController.SetPackageRequestedCacheType("PackageA", BOOTSTRAPPER_CACHE_TYPE.Remove); | ||
| 158 | |||
| 159 | var installLogPath = bundlePackageUninstallFailureBundle.Install(); | ||
| 160 | bundlePackageUninstallFailureBundle.VerifyRegisteredAndInPackageCache(); | ||
| 161 | packageFail.VerifyInstalled(true); | ||
| 162 | bundleA.VerifyRegisteredAndInPackageCache(expectedSystemComponent: 1); | ||
| 163 | |||
| 164 | Assert.False(LogVerifier.MessageInLogFile(installLogPath, $"Applying execute package: PackageA, action: Install, path: {bundleASelfCachedPath}"), bundleASelfCachedPath); | ||
| 165 | Assert.True(LogVerifier.MessageInLogFile(installLogPath, $"Applying execute package: PackageA, action: Install, path: {bundleAEmbeddedCachedPath}"), bundleAEmbeddedCachedPath); | ||
| 166 | |||
| 167 | testBAController.ResetPackageStates("PackageA"); | ||
| 168 | testBAController.SetAllowAcquireAfterValidationFailure(); | ||
| 169 | |||
| 170 | var uninstallLogPath = bundlePackageUninstallFailureBundle.Uninstall((int)MSIExec.MSIExecReturnCode.ERROR_INSTALL_FAILURE, "FAILWHENDEFERRED=1"); | ||
| 171 | bundlePackageUninstallFailureBundle.VerifyRegisteredAndInPackageCache(); | ||
| 172 | bundleA.VerifyRegisteredAndInPackageCache(expectedSystemComponent: 1); | ||
| 173 | packageFail.VerifyInstalled(true); | ||
| 174 | |||
| 175 | Assert.True(LogVerifier.MessageInLogFile(uninstallLogPath, "TESTBA: OnCachePackageNonVitalValidationFailure() - id: PackageA, default: None, requested: Acquire")); | ||
| 176 | Assert.False(LogVerifier.MessageInLogFile(uninstallLogPath, $"Applying execute package: PackageA, action: Uninstall, path: {bundleASelfCachedPath}"), bundleASelfCachedPath); | ||
| 177 | Assert.True(LogVerifier.MessageInLogFile(uninstallLogPath, $"Applying execute package: PackageA, action: Uninstall, path: {bundleAEmbeddedCachedPath}"), bundleAEmbeddedCachedPath); | ||
| 178 | Assert.False(LogVerifier.MessageInLogFile(uninstallLogPath, $"Applying rollback package: PackageA, action: Install, path: {bundleASelfCachedPath}"), bundleASelfCachedPath); | ||
| 179 | Assert.True(LogVerifier.MessageInLogFile(uninstallLogPath, $"Applying rollback package: PackageA, action: Install, path: {bundleAEmbeddedCachedPath}"), bundleAEmbeddedCachedPath); | ||
| 180 | } | ||
| 181 | |||
| 182 | [RuntimeFact] | ||
| 183 | public void CanReinstallBundlePackageOnUninstallRollback() | ||
| 184 | { | ||
| 185 | var packageFail = this.CreatePackageInstaller("PackageFail"); | ||
| 186 | var packageA = this.CreatePackageInstaller(@"..\BasicFunctionalityTests\PackageA"); | ||
| 187 | var bundleA = this.CreateBundleInstaller(@"..\BasicFunctionalityTests\BundleA"); | ||
| 188 | var bundlePackageUninstallFailureBundle = this.CreateBundleInstaller("BundlePackageUninstallFailureBundle"); | ||
| 189 | var bundleASelfCachedPath = bundleA.GetExpectedCachedBundlePath(); | ||
| 190 | var bundleAEmbeddedCachedPath = bundlePackageUninstallFailureBundle.GetPackageEntryPointCachePath("PackageA"); | ||
| 191 | |||
| 192 | packageA.VerifyInstalled(false); | ||
| 193 | packageFail.VerifyInstalled(false); | ||
| 194 | bundleA.VerifyUnregisteredAndRemovedFromPackageCache(); | ||
| 195 | |||
| 196 | var installLogPath = bundlePackageUninstallFailureBundle.Install(); | ||
| 197 | bundlePackageUninstallFailureBundle.VerifyRegisteredAndInPackageCache(); | ||
| 198 | packageFail.VerifyInstalled(true); | ||
| 199 | bundleA.VerifyRegisteredAndInPackageCache(expectedSystemComponent: 1); | ||
| 200 | |||
| 201 | Assert.False(LogVerifier.MessageInLogFile(installLogPath, $"Applying execute package: PackageA, action: Install, path: {bundleASelfCachedPath}"), bundleASelfCachedPath); | ||
| 202 | Assert.True(LogVerifier.MessageInLogFile(installLogPath, $"Applying execute package: PackageA, action: Install, path: {bundleAEmbeddedCachedPath}"), bundleAEmbeddedCachedPath); | ||
| 203 | |||
| 204 | var uninstallLogPath = bundlePackageUninstallFailureBundle.Uninstall((int)MSIExec.MSIExecReturnCode.ERROR_INSTALL_FAILURE, "FAILWHENDEFERRED=1"); | ||
| 205 | bundlePackageUninstallFailureBundle.VerifyRegisteredAndInPackageCache(); | ||
| 206 | bundleA.VerifyRegisteredAndInPackageCache(expectedSystemComponent: 1); | ||
| 207 | packageFail.VerifyInstalled(true); | ||
| 208 | |||
| 209 | Assert.False(LogVerifier.MessageInLogFile(uninstallLogPath, "TESTBA: OnCachePackageNonVitalValidationFailure() - id: PackageA")); | ||
| 210 | Assert.False(LogVerifier.MessageInLogFile(uninstallLogPath, $"Applying execute package: PackageA, action: Uninstall, path: {bundleASelfCachedPath}"), bundleASelfCachedPath); | ||
| 211 | Assert.True(LogVerifier.MessageInLogFile(uninstallLogPath, $"Applying execute package: PackageA, action: Uninstall, path: {bundleAEmbeddedCachedPath}"), bundleAEmbeddedCachedPath); | ||
| 212 | Assert.False(LogVerifier.MessageInLogFile(uninstallLogPath, $"Applying rollback package: PackageA, action: Install, path: {bundleASelfCachedPath}"), bundleASelfCachedPath); | ||
| 213 | Assert.True(LogVerifier.MessageInLogFile(uninstallLogPath, $"Applying rollback package: PackageA, action: Install, path: {bundleAEmbeddedCachedPath}"), bundleAEmbeddedCachedPath); | ||
| 214 | } | ||
| 215 | |||
| 216 | [RuntimeFact] | ||
| 217 | public void CanSkipReinstallBundlePackageOnUninstallRollback() | ||
| 218 | { | ||
| 219 | var packageFail = this.CreatePackageInstaller("PackageFail"); | ||
| 220 | var packageA = this.CreatePackageInstaller(@"..\BasicFunctionalityTests\PackageA"); | ||
| 221 | var bundleA = this.CreateBundleInstaller(@"..\BasicFunctionalityTests\BundleA"); | ||
| 222 | var bundlePackageUninstallFailureBundle = this.CreateBundleInstaller("BundlePackageUninstallFailureBundle"); | ||
| 223 | var testBAController = this.CreateTestBAController(); | ||
| 224 | var bundleASelfCachedPath = bundleA.GetExpectedCachedBundlePath(); | ||
| 225 | var bundleAEmbeddedCachedPath = bundlePackageUninstallFailureBundle.GetPackageEntryPointCachePath("PackageA"); | ||
| 226 | |||
| 227 | packageA.VerifyInstalled(false); | ||
| 228 | packageFail.VerifyInstalled(false); | ||
| 229 | bundleA.VerifyUnregisteredAndRemovedFromPackageCache(); | ||
| 230 | |||
| 231 | testBAController.SetPackageRequestedCacheType("PackageA", BOOTSTRAPPER_CACHE_TYPE.Remove); | ||
| 232 | |||
| 233 | var installLogPath = bundlePackageUninstallFailureBundle.Install(); | ||
| 234 | bundlePackageUninstallFailureBundle.VerifyRegisteredAndInPackageCache(); | ||
| 235 | packageFail.VerifyInstalled(true); | ||
| 236 | bundleA.VerifyRegisteredAndInPackageCache(expectedSystemComponent: 1); | ||
| 237 | |||
| 238 | Assert.False(LogVerifier.MessageInLogFile(installLogPath, $"Applying execute package: PackageA, action: Install, path: {bundleASelfCachedPath}"), bundleASelfCachedPath); | ||
| 239 | Assert.True(LogVerifier.MessageInLogFile(installLogPath, $"Applying execute package: PackageA, action: Install, path: {bundleAEmbeddedCachedPath}"), bundleAEmbeddedCachedPath); | ||
| 240 | |||
| 241 | var uninstallLogPath = bundlePackageUninstallFailureBundle.Uninstall((int)MSIExec.MSIExecReturnCode.ERROR_INSTALL_FAILURE, "FAILWHENDEFERRED=1"); | ||
| 242 | bundlePackageUninstallFailureBundle.VerifyRegisteredAndInPackageCache(); | ||
| 243 | bundleA.VerifyUnregisteredAndRemovedFromPackageCache(); | ||
| 244 | packageFail.VerifyInstalled(true); | ||
| 245 | |||
| 246 | Assert.True(LogVerifier.MessageInLogFile(uninstallLogPath, "TESTBA: OnCachePackageNonVitalValidationFailure() - id: PackageA, default: None, requested: None")); | ||
| 247 | Assert.True(LogVerifier.MessageInLogFile(uninstallLogPath, $"Applying execute package: PackageA, action: Uninstall, path: {bundleASelfCachedPath}"), bundleASelfCachedPath); | ||
| 248 | Assert.False(LogVerifier.MessageInLogFile(uninstallLogPath, $"Applying execute package: PackageA, action: Uninstall, path: {bundleAEmbeddedCachedPath}"), bundleAEmbeddedCachedPath); | ||
| 249 | Assert.False(LogVerifier.MessageInLogFile(uninstallLogPath, $"Applying rollback package: PackageA, action: Install, path: {bundleASelfCachedPath}"), bundleASelfCachedPath); | ||
| 250 | Assert.False(LogVerifier.MessageInLogFile(uninstallLogPath, $"Applying rollback package: PackageA, action: Install, path: {bundleAEmbeddedCachedPath}"), bundleAEmbeddedCachedPath); | ||
| 251 | } | ||
| 140 | } | 252 | } |
| 141 | } | 253 | } |
