diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2021-03-30 15:50:32 -0500 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2021-03-30 16:05:00 -0500 |
| commit | 72d694ee9cb6954953e55bf05b09c93ddebdc9d3 (patch) | |
| tree | effa94ca53e95eed1eda71f18c38c564d6aca815 /src | |
| parent | 3221757bb210b23e4c8d859d20aa20b43c0df582 (diff) | |
| download | wix-72d694ee9cb6954953e55bf05b09c93ddebdc9d3.tar.gz wix-72d694ee9cb6954953e55bf05b09c93ddebdc9d3.tar.bz2 wix-72d694ee9cb6954953e55bf05b09c93ddebdc9d3.zip | |
Add layout tests.
Diffstat (limited to 'src')
| -rw-r--r-- | src/TestData/LayoutTests/BundleA/Bundle.wxs | 42 | ||||
| -rw-r--r-- | src/TestData/LayoutTests/BundleA/BundleA.wixproj | 23 | ||||
| -rw-r--r-- | src/TestData/LayoutTests/BundleA/BundleA.wxs | 26 | ||||
| -rw-r--r-- | src/TestData/LayoutTests/PackageA/PackageA.wixproj | 9 | ||||
| -rw-r--r-- | src/WixTestTools/BundleInstaller.cs | 31 | ||||
| -rw-r--r-- | src/WixToolsetTest.BurnE2E/LayoutTests.cs | 68 | ||||
| -rw-r--r-- | src/WixToolsetTest.BurnE2E/WebServer/CoreOwinWebServer.cs | 3 |
7 files changed, 200 insertions, 2 deletions
diff --git a/src/TestData/LayoutTests/BundleA/Bundle.wxs b/src/TestData/LayoutTests/BundleA/Bundle.wxs new file mode 100644 index 00000000..e74b8394 --- /dev/null +++ b/src/TestData/LayoutTests/BundleA/Bundle.wxs | |||
| @@ -0,0 +1,42 @@ | |||
| 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 | <?ifndef Version?> | ||
| 4 | <?define Version = 1.0.0.0?> | ||
| 5 | <?endif?> | ||
| 6 | |||
| 7 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal"> | ||
| 8 | <Bundle Name="~$(var.TestGroupName) - $(var.BundleName)" Version="$(var.Version)" UpgradeCode="$(var.UpgradeCode)" Compressed="yes"> | ||
| 9 | <!-- PayloadGroupRef should be the only thing different from the template --> | ||
| 10 | <PayloadGroupRef Id="LayoutOnlyPayloads" /> | ||
| 11 | |||
| 12 | <Log Prefix="~$(var.TestGroupName)_$(var.BundleName)" /> | ||
| 13 | |||
| 14 | <Variable Name="TestGroupName" Value="$(var.TestGroupName)" /> | ||
| 15 | |||
| 16 | <?ifdef SoftwareTag?> | ||
| 17 | <SoftwareTag Regid="regid.1995-08.com.example" InstallPath="[CommonAppDataFolder]regid.1995-08.com.example" /> | ||
| 18 | <?endif?> | ||
| 19 | |||
| 20 | <?ifndef BA?> | ||
| 21 | <!-- pulled in through the PackageGroupRef below --> | ||
| 22 | <?elseif $(var.BA) = "TestBAdnc"?> | ||
| 23 | <!-- pulled in through the PackageGroupRef below --> | ||
| 24 | <?elseif $(var.BA) = "hyperlinkLicense"?> | ||
| 25 | <BootstrapperApplication> | ||
| 26 | <bal:WixStandardBootstrapperApplication LicenseUrl="" Theme="hyperlinkLicense" /> | ||
| 27 | </BootstrapperApplication> | ||
| 28 | <?else?> | ||
| 29 | <BootstrapperApplicationRef Id="$(var.BA)" /> | ||
| 30 | <?endif?> | ||
| 31 | |||
| 32 | <Chain> | ||
| 33 | <?ifndef BA?> | ||
| 34 | <PackageGroupRef Id="TestBA" /> | ||
| 35 | <?elseif $(var.BA) = "TestBAdnc"?> | ||
| 36 | <PackageGroupRef Id="TestBAdnc" /> | ||
| 37 | <?endif?> | ||
| 38 | |||
| 39 | <PackageGroupRef Id="BundlePackages" /> | ||
| 40 | </Chain> | ||
| 41 | </Bundle> | ||
| 42 | </Wix> | ||
diff --git a/src/TestData/LayoutTests/BundleA/BundleA.wixproj b/src/TestData/LayoutTests/BundleA/BundleA.wixproj new file mode 100644 index 00000000..fa7f227c --- /dev/null +++ b/src/TestData/LayoutTests/BundleA/BundleA.wixproj | |||
| @@ -0,0 +1,23 @@ | |||
| 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>{D255FA2D-2B4A-4D78-AE90-C09FECD8491E}</UpgradeCode> | ||
| 6 | </PropertyGroup> | ||
| 7 | <ItemGroup> | ||
| 8 | <ProjectReference Include="..\PackageA\PackageA.wixproj" /> | ||
| 9 | <ProjectReference Include="..\..\TestBA\TestBAWixlib\testbawixlib.wixproj" /> | ||
| 10 | </ItemGroup> | ||
| 11 | <ItemGroup> | ||
| 12 | <PackageReference Include="WixToolset.Bal.wixext" Version="4.0.90" /> | ||
| 13 | <PackageReference Include="WixToolset.NetFx.wixext" Version="4.0.64" /> | ||
| 14 | </ItemGroup> | ||
| 15 | <!-- Workaround wix.targets brokenness --> | ||
| 16 | <Target Name="CopyUncompressedFiles" AfterTargets="AfterBuild"> | ||
| 17 | <ItemGroup> | ||
| 18 | <UncompressedFiles Include="$(IntermediateOutputPath)\BundleA.wxs" /> | ||
| 19 | <UncompressedFiles Include="$(IntermediateOutputPath)\packages.cab" /> | ||
| 20 | </ItemGroup> | ||
| 21 | <Copy SourceFiles="@(UncompressedFiles)" DestinationFolder="$(OutputPath)" /> | ||
| 22 | </Target> | ||
| 23 | </Project> \ No newline at end of file | ||
diff --git a/src/TestData/LayoutTests/BundleA/BundleA.wxs b/src/TestData/LayoutTests/BundleA/BundleA.wxs new file mode 100644 index 00000000..ea46c5b2 --- /dev/null +++ b/src/TestData/LayoutTests/BundleA/BundleA.wxs | |||
| @@ -0,0 +1,26 @@ | |||
| 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 | </PackageGroup> | ||
| 9 | |||
| 10 | <!-- Reenable when fixed | ||
| 11 | <Container Id="PackagesContainer" Name="packages.cab" DownloadUrl="$(var.WebServerBaseUrl)BundleA/{2}"> | ||
| 12 | --> | ||
| 13 | <Container Id="PackagesContainer" Name="packages.cab" DownloadUrl="$(var.WebServerBaseUrl)BundleA/packages.cab"> | ||
| 14 | <PackageGroupRef Id="BundlePackages" /> | ||
| 15 | </Container> | ||
| 16 | </Fragment> | ||
| 17 | |||
| 18 | <Fragment> | ||
| 19 | <PayloadGroup Id="LayoutOnlyPayloads"> | ||
| 20 | <Payload Id="LayoutOnlyPayload" SourceFile="$(sys.SOURCEFILEPATH)" Compressed="no" DownloadUrl="$(var.WebServerBaseUrl)BundleA/LayoutOnlyPayload" /> | ||
| 21 | <!-- Reenable when fixed | ||
| 22 | <Payload Id="LayoutOnlyPayload" SourceFile="$(sys.SOURCEFILEPATH)" Compressed="no" DownloadUrl="$(var.WebServerBaseUrl)BundleA/{1}" /> | ||
| 23 | --> | ||
| 24 | </PayloadGroup> | ||
| 25 | </Fragment> | ||
| 26 | </Wix> | ||
diff --git a/src/TestData/LayoutTests/PackageA/PackageA.wixproj b/src/TestData/LayoutTests/PackageA/PackageA.wixproj new file mode 100644 index 00000000..be425985 --- /dev/null +++ b/src/TestData/LayoutTests/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>{CA12F025-6F6F-4E3C-A1D7-FE8CD45A77F5}</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 859656ad..34661651 100644 --- a/src/WixTestTools/BundleInstaller.cs +++ b/src/WixTestTools/BundleInstaller.cs | |||
| @@ -49,6 +49,31 @@ namespace WixTestTools | |||
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | /// <summary> | 51 | /// <summary> |
| 52 | /// Calls Layout for the bundle with optional arguments. | ||
| 53 | /// </summary> | ||
| 54 | /// <param name="layoutDirectory">The destination directory.</param> | ||
| 55 | /// <param name="expectedExitCode">Expected exit code, defaults to success.</param> | ||
| 56 | /// <param name="arguments">Optional arguments to pass to the tool.</param> | ||
| 57 | /// <returns>Path to the generated log file.</returns> | ||
| 58 | public string Layout(string layoutDirectory, int expectedExitCode = (int)MSIExec.MSIExecReturnCode.SUCCESS, params string[] arguments) | ||
| 59 | { | ||
| 60 | return this.RunBundleWithArguments(expectedExitCode, MSIExec.MSIExecMode.AdministrativeInstall, arguments, layoutDirectory: layoutDirectory); | ||
| 61 | } | ||
| 62 | |||
| 63 | /// <summary> | ||
| 64 | /// Calls Layout for the bundle with optional arguments. | ||
| 65 | /// </summary> | ||
| 66 | /// <param name="bundlePath">Path to the bundle to run.</param> | ||
| 67 | /// <param name="layoutDirectory">The destination directory.</param> | ||
| 68 | /// <param name="expectedExitCode">Expected exit code, defaults to success.</param> | ||
| 69 | /// <param name="arguments">Optional arguments to pass to the tool.</param> | ||
| 70 | /// <returns>Path to the generated log file.</returns> | ||
| 71 | public string Layout(string bundlePath, string layoutDirectory, int expectedExitCode = (int)MSIExec.MSIExecReturnCode.SUCCESS, params string[] arguments) | ||
| 72 | { | ||
| 73 | return this.RunBundleWithArguments(expectedExitCode, MSIExec.MSIExecMode.AdministrativeInstall, arguments, bundlePath: bundlePath, layoutDirectory: layoutDirectory); | ||
| 74 | } | ||
| 75 | |||
| 76 | /// <summary> | ||
| 52 | /// Modify the bundle with optional arguments. | 77 | /// Modify the bundle with optional arguments. |
| 53 | /// </summary> | 78 | /// </summary> |
| 54 | /// <param name="expectedExitCode">Expected exit code, defaults to success.</param> | 79 | /// <param name="expectedExitCode">Expected exit code, defaults to success.</param> |
| @@ -100,7 +125,7 @@ namespace WixTestTools | |||
| 100 | /// <param name="mode">Install mode.</param> | 125 | /// <param name="mode">Install mode.</param> |
| 101 | /// <param name="arguments">Optional arguments to pass to the tool.</param> | 126 | /// <param name="arguments">Optional arguments to pass to the tool.</param> |
| 102 | /// <returns>Path to the generated log file.</returns> | 127 | /// <returns>Path to the generated log file.</returns> |
| 103 | private string RunBundleWithArguments(int expectedExitCode, MSIExec.MSIExecMode mode, string[] arguments, bool assertOnError = true, string bundlePath = null) | 128 | private string RunBundleWithArguments(int expectedExitCode, MSIExec.MSIExecMode mode, string[] arguments, bool assertOnError = true, string bundlePath = null, string layoutDirectory = null) |
| 104 | { | 129 | { |
| 105 | TestTool bundle = new TestTool(bundlePath ?? this.Bundle); | 130 | TestTool bundle = new TestTool(bundlePath ?? this.Bundle); |
| 106 | var sb = new StringBuilder(); | 131 | var sb = new StringBuilder(); |
| @@ -115,6 +140,10 @@ namespace WixTestTools | |||
| 115 | // Set operation. | 140 | // Set operation. |
| 116 | switch (mode) | 141 | switch (mode) |
| 117 | { | 142 | { |
| 143 | case MSIExec.MSIExecMode.AdministrativeInstall: | ||
| 144 | sb.Append($" -layout \"{layoutDirectory}\""); | ||
| 145 | break; | ||
| 146 | |||
| 118 | case MSIExec.MSIExecMode.Modify: | 147 | case MSIExec.MSIExecMode.Modify: |
| 119 | sb.Append(" -modify"); | 148 | sb.Append(" -modify"); |
| 120 | break; | 149 | break; |
diff --git a/src/WixToolsetTest.BurnE2E/LayoutTests.cs b/src/WixToolsetTest.BurnE2E/LayoutTests.cs new file mode 100644 index 00000000..1e36e2a5 --- /dev/null +++ b/src/WixToolsetTest.BurnE2E/LayoutTests.cs | |||
| @@ -0,0 +1,68 @@ | |||
| 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 Xunit; | ||
| 9 | using Xunit.Abstractions; | ||
| 10 | |||
| 11 | public class LayoutTests : BurnE2ETests | ||
| 12 | { | ||
| 13 | public LayoutTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } | ||
| 14 | |||
| 15 | [Fact] | ||
| 16 | public void CanLayoutBundleInPlaceWithMissingPayloads() | ||
| 17 | { | ||
| 18 | var bundleA = this.CreateBundleInstaller("BundleA"); | ||
| 19 | var webServer = this.CreateWebServer(); | ||
| 20 | |||
| 21 | webServer.AddFiles(new Dictionary<string, string> | ||
| 22 | { | ||
| 23 | { "/BundleA/LayoutOnlyPayload", Path.Combine(this.TestContext.TestDataFolder, "BundleA.wxs") }, | ||
| 24 | { "/BundleA/packages.cab", Path.Combine(this.TestContext.TestDataFolder, "packages.cab") }, | ||
| 25 | }); | ||
| 26 | webServer.Start(); | ||
| 27 | |||
| 28 | using var dfs = new DisposableFileSystem(); | ||
| 29 | var layoutDirectory = dfs.GetFolder(true); | ||
| 30 | |||
| 31 | // Manually copy bundle to layout directory and then run from there so the non-compressed payloads have to be resolved. | ||
| 32 | var bundleAFileInfo = new FileInfo(bundleA.Bundle); | ||
| 33 | var bundleACopiedPath = Path.Combine(layoutDirectory, bundleAFileInfo.Name); | ||
| 34 | bundleAFileInfo.CopyTo(bundleACopiedPath); | ||
| 35 | |||
| 36 | bundleA.Layout(bundleACopiedPath, layoutDirectory); | ||
| 37 | bundleA.VerifyUnregisteredAndRemovedFromPackageCache(); | ||
| 38 | |||
| 39 | Assert.True(File.Exists(bundleACopiedPath)); | ||
| 40 | Assert.True(File.Exists(Path.Combine(layoutDirectory, "packages.cab"))); | ||
| 41 | Assert.True(File.Exists(Path.Combine(layoutDirectory, "BundleA.wxs"))); | ||
| 42 | } | ||
| 43 | |||
| 44 | [Fact] | ||
| 45 | public void CanLayoutBundleToNewDirectory() | ||
| 46 | { | ||
| 47 | var bundleA = this.CreateBundleInstaller("BundleA"); | ||
| 48 | var webServer = this.CreateWebServer(); | ||
| 49 | |||
| 50 | webServer.AddFiles(new Dictionary<string, string> | ||
| 51 | { | ||
| 52 | { "/BundleA/LayoutOnlyPayload", Path.Combine(this.TestContext.TestDataFolder, "BundleA.wxs") }, | ||
| 53 | { "/BundleA/packages.cab", Path.Combine(this.TestContext.TestDataFolder, "packages.cab") }, | ||
| 54 | }); | ||
| 55 | webServer.Start(); | ||
| 56 | |||
| 57 | using var dfs = new DisposableFileSystem(); | ||
| 58 | var layoutDirectory = dfs.GetFolder(); | ||
| 59 | |||
| 60 | bundleA.Layout(layoutDirectory); | ||
| 61 | bundleA.VerifyUnregisteredAndRemovedFromPackageCache(); | ||
| 62 | |||
| 63 | Assert.True(File.Exists(Path.Combine(layoutDirectory, "BundleA.exe"))); | ||
| 64 | Assert.True(File.Exists(Path.Combine(layoutDirectory, "packages.cab"))); | ||
| 65 | Assert.True(File.Exists(Path.Combine(layoutDirectory, "BundleA.wxs"))); | ||
| 66 | } | ||
| 67 | } | ||
| 68 | } | ||
diff --git a/src/WixToolsetTest.BurnE2E/WebServer/CoreOwinWebServer.cs b/src/WixToolsetTest.BurnE2E/WebServer/CoreOwinWebServer.cs index 66db226c..89825813 100644 --- a/src/WixToolsetTest.BurnE2E/WebServer/CoreOwinWebServer.cs +++ b/src/WixToolsetTest.BurnE2E/WebServer/CoreOwinWebServer.cs | |||
| @@ -49,7 +49,8 @@ namespace WixToolsetTest.BurnE2E | |||
| 49 | 49 | ||
| 50 | public void Dispose() | 50 | public void Dispose() |
| 51 | { | 51 | { |
| 52 | this.WebHost?.StopAsync(TimeSpan.FromSeconds(5)).GetAwaiter().GetResult(); | 52 | var waitTime = TimeSpan.FromSeconds(5); |
| 53 | this.WebHost?.StopAsync(waitTime).Wait(waitTime); | ||
| 53 | } | 54 | } |
| 54 | 55 | ||
| 55 | public IDirectoryContents GetDirectoryContents(string subpath) => throw new NotImplementedException(); | 56 | public IDirectoryContents GetDirectoryContents(string subpath) => throw new NotImplementedException(); |
