Add tests for #5253 and #5586.
Sean Hall committed
Apr 25, 2021 at 23:35 UTC
9eac17a8ab63f157253a74828b0fbd593f53d71a
8 files changed
+196
src/TestData/CacheTests/BundleA/BundleA.wixproj
new
+19
@@ -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
src/TestData/CacheTests/BundleA/BundleA.wxs
new
+11
@@ -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>
src/TestData/CacheTests/BundleB/BundleB.wixproj
new
+19
@@ -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
src/TestData/CacheTests/BundleB/BundleB.wxs
new
+11
@@ -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>
src/TestData/CacheTests/PackageA/PackageA.wixproj
new
+9
@@ -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
src/TestData/CacheTests/PackageB/PackageB.wixproj
new
+9
@@ -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
src/WixTestTools/BundleInstaller.cs
+12
@@ -84,6 +84,18 @@ namespace WixTestTools
84
return this.RunBundleWithArguments(expectedExitCode, MSIExec.MSIExecMode.Modify, arguments);
85
}
86
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>
100
/// Repairs the bundle with optional arguments.
101
/// </summary>
src/WixToolsetTest.BurnE2E/CacheTests.cs
new
+106
@@ -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
+}