diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2021-04-25 23:35:50 -0500 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2021-04-25 23:46:11 -0500 |
commit | 9eac17a8ab63f157253a74828b0fbd593f53d71a (patch) | |
tree | 349d9d7b7c0445dc9df4d9071fa2983781ddb41a | |
parent | d3aa9df30f8013b6ee60f0001a9473d4234b33ff (diff) | |
download | wix-9eac17a8ab63f157253a74828b0fbd593f53d71a.tar.gz wix-9eac17a8ab63f157253a74828b0fbd593f53d71a.tar.bz2 wix-9eac17a8ab63f157253a74828b0fbd593f53d71a.zip |
Add tests for #5253 and #5586.
-rw-r--r-- | src/TestData/CacheTests/BundleA/BundleA.wixproj | 19 | ||||
-rw-r--r-- | src/TestData/CacheTests/BundleA/BundleA.wxs | 11 | ||||
-rw-r--r-- | src/TestData/CacheTests/BundleB/BundleB.wixproj | 19 | ||||
-rw-r--r-- | src/TestData/CacheTests/BundleB/BundleB.wxs | 11 | ||||
-rw-r--r-- | src/TestData/CacheTests/PackageA/PackageA.wixproj | 9 | ||||
-rw-r--r-- | src/TestData/CacheTests/PackageB/PackageB.wixproj | 9 | ||||
-rw-r--r-- | src/WixTestTools/BundleInstaller.cs | 12 | ||||
-rw-r--r-- | src/WixToolsetTest.BurnE2E/CacheTests.cs | 106 |
8 files changed, 196 insertions, 0 deletions
diff --git a/src/TestData/CacheTests/BundleA/BundleA.wixproj b/src/TestData/CacheTests/BundleA/BundleA.wixproj new file mode 100644 index 00000000..5071c1c7 --- /dev/null +++ b/src/TestData/CacheTests/BundleA/BundleA.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>{C48D0F58-0F8F-461D-A60D-D83E5F35BA8E}</UpgradeCode> | ||
6 | </PropertyGroup> | ||
7 | <ItemGroup> | ||
8 | <Compile Include="..\..\Templates\Bundle.wxs" Link="Bundle.wxs" /> | ||
9 | </ItemGroup> | ||
10 | <ItemGroup> | ||
11 | <ProjectReference Include="..\PackageA\PackageA.wixproj" /> | ||
12 | <ProjectReference Include="..\PackageB\PackageB.wixproj" /> | ||
13 | <ProjectReference Include="..\..\TestBA\TestBAWixlib\testbawixlib.wixproj" /> | ||
14 | </ItemGroup> | ||
15 | <ItemGroup> | ||
16 | <PackageReference Include="WixToolset.Bal.wixext" Version="4.0.100" /> | ||
17 | <PackageReference Include="WixToolset.NetFx.wixext" Version="4.0.72" /> | ||
18 | </ItemGroup> | ||
19 | </Project> \ No newline at end of file | ||
diff --git a/src/TestData/CacheTests/BundleA/BundleA.wxs b/src/TestData/CacheTests/BundleA/BundleA.wxs new file mode 100644 index 00000000..20262187 --- /dev/null +++ b/src/TestData/CacheTests/BundleA/BundleA.wxs | |||
@@ -0,0 +1,11 @@ | |||
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"> | ||
5 | <Fragment> | ||
6 | <PackageGroup Id="BundlePackages"> | ||
7 | <MsiPackage Id="PackageA" SourceFile="$(var.PackageA.TargetPath)" DownloadUrl="$(var.WebServerBaseUrl)BundleA/{2}" /> | ||
8 | <MsiPackage Id="PackageB" SourceFile="$(var.PackageB.TargetPath)" DownloadUrl="$(var.WebServerBaseUrl)BundleA/{2}" /> | ||
9 | </PackageGroup> | ||
10 | </Fragment> | ||
11 | </Wix> | ||
diff --git a/src/TestData/CacheTests/BundleB/BundleB.wixproj b/src/TestData/CacheTests/BundleB/BundleB.wixproj new file mode 100644 index 00000000..ffc03f79 --- /dev/null +++ b/src/TestData/CacheTests/BundleB/BundleB.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>{3CC71AD2-39F3-4803-A24C-6E6A492B721C}</UpgradeCode> | ||
6 | </PropertyGroup> | ||
7 | <ItemGroup> | ||
8 | <Compile Include="..\..\Templates\Bundle.wxs" Link="Bundle.wxs" /> | ||
9 | </ItemGroup> | ||
10 | <ItemGroup> | ||
11 | <ProjectReference Include="..\PackageA\PackageA.wixproj" /> | ||
12 | <ProjectReference Include="..\PackageB\PackageB.wixproj" /> | ||
13 | <ProjectReference Include="..\..\TestBA\TestBAWixlib\testbawixlib.wixproj" /> | ||
14 | </ItemGroup> | ||
15 | <ItemGroup> | ||
16 | <PackageReference Include="WixToolset.Bal.wixext" Version="4.0.100" /> | ||
17 | <PackageReference Include="WixToolset.NetFx.wixext" Version="4.0.72" /> | ||
18 | </ItemGroup> | ||
19 | </Project> \ No newline at end of file | ||
diff --git a/src/TestData/CacheTests/BundleB/BundleB.wxs b/src/TestData/CacheTests/BundleB/BundleB.wxs new file mode 100644 index 00000000..95e714ec --- /dev/null +++ b/src/TestData/CacheTests/BundleB/BundleB.wxs | |||
@@ -0,0 +1,11 @@ | |||
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"> | ||
5 | <Fragment> | ||
6 | <PackageGroup Id="BundlePackages"> | ||
7 | <MsiPackage Id="PackageA" SourceFile="$(var.PackageA.TargetPath)" /> | ||
8 | <MsiPackage Id="PackageB" SourceFile="$(var.PackageB.TargetPath)" /> | ||
9 | </PackageGroup> | ||
10 | </Fragment> | ||
11 | </Wix> | ||
diff --git a/src/TestData/CacheTests/PackageA/PackageA.wixproj b/src/TestData/CacheTests/PackageA/PackageA.wixproj new file mode 100644 index 00000000..dd8176ed --- /dev/null +++ b/src/TestData/CacheTests/PackageA/PackageA.wixproj | |||
@@ -0,0 +1,9 @@ | |||
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>{5D0BD93A-D1D8-4F59-8417-1390B18A6611}</UpgradeCode> | ||
5 | </PropertyGroup> | ||
6 | <ItemGroup> | ||
7 | <Compile Include="..\..\Templates\Package.wxs" Link="Package.wxs" /> | ||
8 | </ItemGroup> | ||
9 | </Project> \ No newline at end of file | ||
diff --git a/src/TestData/CacheTests/PackageB/PackageB.wixproj b/src/TestData/CacheTests/PackageB/PackageB.wixproj new file mode 100644 index 00000000..efc57bb6 --- /dev/null +++ b/src/TestData/CacheTests/PackageB/PackageB.wixproj | |||
@@ -0,0 +1,9 @@ | |||
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>{ADCE5902-224D-4C87-BA31-2D154B37EE22}</UpgradeCode> | ||
5 | </PropertyGroup> | ||
6 | <ItemGroup> | ||
7 | <Compile Include="..\..\Templates\Package.wxs" Link="Package.wxs" /> | ||
8 | </ItemGroup> | ||
9 | </Project> \ No newline at end of file | ||
diff --git a/src/WixTestTools/BundleInstaller.cs b/src/WixTestTools/BundleInstaller.cs index 34661651..a49c4024 100644 --- a/src/WixTestTools/BundleInstaller.cs +++ b/src/WixTestTools/BundleInstaller.cs | |||
@@ -85,6 +85,18 @@ namespace WixTestTools | |||
85 | } | 85 | } |
86 | 86 | ||
87 | /// <summary> | 87 | /// <summary> |
88 | /// Modify the bundle with optional arguments. | ||
89 | /// </summary> | ||
90 | /// <param name="bundlePath">This should be the bundle in the package cache.</param> | ||
91 | /// <param name="expectedExitCode">Expected exit code, defaults to success.</param> | ||
92 | /// <param name="arguments">Optional arguments to pass to the tool.</param> | ||
93 | /// <returns>Path to the generated log file.</returns> | ||
94 | public string Modify(string bundlePath, int expectedExitCode = (int)MSIExec.MSIExecReturnCode.SUCCESS, params string[] arguments) | ||
95 | { | ||
96 | return this.RunBundleWithArguments(expectedExitCode, MSIExec.MSIExecMode.Modify, arguments, bundlePath: bundlePath); | ||
97 | } | ||
98 | |||
99 | /// <summary> | ||
88 | /// Repairs the bundle with optional arguments. | 100 | /// Repairs the bundle with optional arguments. |
89 | /// </summary> | 101 | /// </summary> |
90 | /// <param name="expectedExitCode">Expected exit code, defaults to success.</param> | 102 | /// <param name="expectedExitCode">Expected exit code, defaults to success.</param> |
diff --git a/src/WixToolsetTest.BurnE2E/CacheTests.cs b/src/WixToolsetTest.BurnE2E/CacheTests.cs new file mode 100644 index 00000000..f62b0874 --- /dev/null +++ b/src/WixToolsetTest.BurnE2E/CacheTests.cs | |||
@@ -0,0 +1,106 @@ | |||
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 | namespace WixToolsetTest.BurnE2E | ||
4 | { | ||
5 | using System.Collections.Generic; | ||
6 | using System.IO; | ||
7 | using WixBuildTools.TestSupport; | ||
8 | using WixToolset.Mba.Core; | ||
9 | using Xunit; | ||
10 | using Xunit.Abstractions; | ||
11 | |||
12 | public class CacheTests : BurnE2ETests | ||
13 | { | ||
14 | public CacheTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } | ||
15 | |||
16 | [Fact] | ||
17 | public void CanDownloadPayloadsFromMissingAttachedContainer() | ||
18 | { | ||
19 | var packageA = this.CreatePackageInstaller("PackageA"); | ||
20 | var packageB = this.CreatePackageInstaller("PackageB"); | ||
21 | var bundleA = this.CreateBundleInstaller("BundleA"); | ||
22 | var testBAController = this.CreateTestBAController(); | ||
23 | var webServer = this.CreateWebServer(); | ||
24 | |||
25 | webServer.AddFiles(new Dictionary<string, string> | ||
26 | { | ||
27 | { "/BundleA/PackageA.msi", Path.Combine(this.TestContext.TestDataFolder, "PackageA.msi") }, | ||
28 | { "/BundleA/PackageB.msi", Path.Combine(this.TestContext.TestDataFolder, "PackageB.msi") }, | ||
29 | }); | ||
30 | webServer.Start(); | ||
31 | |||
32 | // Don't install PackageB initially so it will be installed when run from the package cache. | ||
33 | testBAController.SetPackageRequestedState("PackageB", RequestState.Absent); | ||
34 | |||
35 | packageA.VerifyInstalled(false); | ||
36 | packageB.VerifyInstalled(false); | ||
37 | |||
38 | // Manually copy bundle to separate directory, install from there, and then delete it | ||
39 | // so that when run from the package cache, it can't find the attached container. | ||
40 | using (var dfs = new DisposableFileSystem()) | ||
41 | { | ||
42 | var tempDirectory = dfs.GetFolder(true); | ||
43 | |||
44 | var bundleAFileInfo = new FileInfo(bundleA.Bundle); | ||
45 | var bundleACopiedPath = Path.Combine(tempDirectory, bundleAFileInfo.Name); | ||
46 | bundleAFileInfo.CopyTo(bundleACopiedPath); | ||
47 | |||
48 | bundleA.Install(bundleACopiedPath); | ||
49 | } | ||
50 | |||
51 | var bundlePackageCachePath = bundleA.VerifyRegisteredAndInPackageCache(); | ||
52 | |||
53 | packageA.VerifyInstalled(true); | ||
54 | packageB.VerifyInstalled(false); | ||
55 | |||
56 | testBAController.SetPackageRequestedState("PackageB", RequestState.Present); | ||
57 | |||
58 | bundleA.Modify(bundlePackageCachePath); | ||
59 | bundleA.VerifyRegisteredAndInPackageCache(); | ||
60 | |||
61 | packageA.VerifyInstalled(true); | ||
62 | packageB.VerifyInstalled(true); | ||
63 | } | ||
64 | |||
65 | [Fact] | ||
66 | public void CanFindAttachedContainerFromRenamedBundle() | ||
67 | { | ||
68 | var packageA = this.CreatePackageInstaller("PackageA"); | ||
69 | var packageB = this.CreatePackageInstaller("PackageB"); | ||
70 | var bundleB = this.CreateBundleInstaller("BundleB"); | ||
71 | var testBAController = this.CreateTestBAController(); | ||
72 | |||
73 | // Don't install PackageB initially so it will be installed when run from the package cache. | ||
74 | testBAController.SetPackageRequestedState("PackageB", RequestState.Absent); | ||
75 | |||
76 | packageA.VerifyInstalled(false); | ||
77 | packageB.VerifyInstalled(false); | ||
78 | |||
79 | // Manually copy bundle to separate directory with new name and install from there | ||
80 | // so that when run from the package cache, it has to get the attached container from the renamed bundle. | ||
81 | using (var dfs = new DisposableFileSystem()) | ||
82 | { | ||
83 | var tempDirectory = dfs.GetFolder(true); | ||
84 | |||
85 | var bundleBFileInfo = new FileInfo(bundleB.Bundle); | ||
86 | var bundleBCopiedPath = Path.Combine(tempDirectory, "RenamedBundle.exe"); | ||
87 | bundleBFileInfo.CopyTo(bundleBCopiedPath); | ||
88 | |||
89 | bundleB.Install(bundleBCopiedPath); | ||
90 | |||
91 | var bundlePackageCachePath = bundleB.VerifyRegisteredAndInPackageCache(); | ||
92 | |||
93 | packageA.VerifyInstalled(true); | ||
94 | packageB.VerifyInstalled(false); | ||
95 | |||
96 | testBAController.SetPackageRequestedState("PackageB", RequestState.Present); | ||
97 | |||
98 | bundleB.Modify(bundlePackageCachePath); | ||
99 | bundleB.VerifyRegisteredAndInPackageCache(); | ||
100 | |||
101 | packageA.VerifyInstalled(true); | ||
102 | packageB.VerifyInstalled(true); | ||
103 | } | ||
104 | } | ||
105 | } | ||
106 | } | ||