diff options
| author | Rob Mensching <rob@firegiant.com> | 2022-08-16 18:11:54 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2022-08-16 23:21:06 -0700 |
| commit | 94e722baab4e848a615812a45fecc8322335d1f0 (patch) | |
| tree | 8b1124ba75f3b1fc55981113660407c903d45543 /src/tools/test | |
| parent | da5cc586114e537461b239a882c5bbea470d812d (diff) | |
| download | wix-94e722baab4e848a615812a45fecc8322335d1f0.tar.gz wix-94e722baab4e848a615812a45fecc8322335d1f0.tar.bz2 wix-94e722baab4e848a615812a45fecc8322335d1f0.zip | |
Update heat to use StandardDirectory element
Fixes 6631
Diffstat (limited to 'src/tools/test')
4 files changed, 153 insertions, 15 deletions
diff --git a/src/tools/test/WixToolsetTest.Heat/HeatFixture.cs b/src/tools/test/WixToolsetTest.Heat/HeatFixture.cs new file mode 100644 index 00000000..befcedcc --- /dev/null +++ b/src/tools/test/WixToolsetTest.Heat/HeatFixture.cs | |||
| @@ -0,0 +1,136 @@ | |||
| 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.Heat | ||
| 4 | { | ||
| 5 | using System.IO; | ||
| 6 | using System.Linq; | ||
| 7 | using WixBuildTools.TestSupport; | ||
| 8 | using Xunit; | ||
| 9 | |||
| 10 | public class HeatFixture | ||
| 11 | { | ||
| 12 | [Fact] | ||
| 13 | public void CanHarvestSimpleDirectory() | ||
| 14 | { | ||
| 15 | var folder = TestData.Get("TestData", "SingleFile"); | ||
| 16 | |||
| 17 | using (var fs = new DisposableFileSystem()) | ||
| 18 | { | ||
| 19 | var outputPath = Path.Combine(fs.GetFolder(), "out.wxs"); | ||
| 20 | |||
| 21 | var args = new[] | ||
| 22 | { | ||
| 23 | "dir", folder, | ||
| 24 | "-o", outputPath | ||
| 25 | }; | ||
| 26 | |||
| 27 | var result = HeatRunner.Execute(args); | ||
| 28 | result.AssertSuccess(); | ||
| 29 | |||
| 30 | var wxs = File.ReadAllLines(outputPath).Select(s => s.Replace("\"", "'")).ToArray(); | ||
| 31 | WixAssert.CompareLineByLine(new[] | ||
| 32 | { | ||
| 33 | "<?xml version='1.0' encoding='utf-8'?>", | ||
| 34 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
| 35 | " <Fragment>", | ||
| 36 | " <StandardDirectory Id='TARGETDIR'>", | ||
| 37 | " <Directory Id='dirwsJn0Cqs9KdlDSFdQsu9ygYvMF8' Name='SingleFile' />", | ||
| 38 | " </StandardDirectory>", | ||
| 39 | " </Fragment>", | ||
| 40 | " <Fragment>", | ||
| 41 | " <DirectoryRef Id='dirwsJn0Cqs9KdlDSFdQsu9ygYvMF8'>", | ||
| 42 | " <Component Id='cmp0i3dThrp4nheCteEmXvHxBDa_VE' Guid='PUT-GUID-HERE'>", | ||
| 43 | " <File Id='filziMcXYgrmcbVF8PuTUfIB9Vgqo0' KeyPath='yes' Source='SourceDir\\a.txt' />", | ||
| 44 | " </Component>", | ||
| 45 | " </DirectoryRef>", | ||
| 46 | " </Fragment>", | ||
| 47 | "</Wix>", | ||
| 48 | }, wxs); | ||
| 49 | } | ||
| 50 | } | ||
| 51 | |||
| 52 | [Fact] | ||
| 53 | public void CanHarvestSimpleDirectoryToInstallFolder() | ||
| 54 | { | ||
| 55 | var folder = TestData.Get("TestData", "SingleFile"); | ||
| 56 | |||
| 57 | using (var fs = new DisposableFileSystem()) | ||
| 58 | { | ||
| 59 | var outputPath = Path.Combine(fs.GetFolder(), "out.wxs"); | ||
| 60 | |||
| 61 | var args = new[] | ||
| 62 | { | ||
| 63 | "dir", folder, | ||
| 64 | "-dr", "INSTALLFOLDER", | ||
| 65 | "-o", outputPath | ||
| 66 | }; | ||
| 67 | |||
| 68 | var result = HeatRunner.Execute(args); | ||
| 69 | result.AssertSuccess(); | ||
| 70 | |||
| 71 | var wxs = File.ReadAllLines(outputPath).Select(s => s.Replace("\"", "'")).ToArray(); | ||
| 72 | WixAssert.CompareLineByLine(new[] | ||
| 73 | { | ||
| 74 | "<?xml version='1.0' encoding='utf-8'?>", | ||
| 75 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
| 76 | " <Fragment>", | ||
| 77 | " <DirectoryRef Id='INSTALLFOLDER'>", | ||
| 78 | " <Directory Id='dirlooNEIrtEBL2w_RhFEIgiKcUlxE' Name='SingleFile' />", | ||
| 79 | " </DirectoryRef>", | ||
| 80 | " </Fragment>", | ||
| 81 | " <Fragment>", | ||
| 82 | " <DirectoryRef Id='dirlooNEIrtEBL2w_RhFEIgiKcUlxE'>", | ||
| 83 | " <Component Id='cmpxHVF6oXohc0EWgRphmYZvw5.GGU' Guid='PUT-GUID-HERE'>", | ||
| 84 | " <File Id='filk_7KUAfL4VfzxSRsGFf_XOBHln0' KeyPath='yes' Source='SourceDir\\a.txt' />", | ||
| 85 | " </Component>", | ||
| 86 | " </DirectoryRef>", | ||
| 87 | " </Fragment>", | ||
| 88 | "</Wix>", | ||
| 89 | }, wxs); | ||
| 90 | } | ||
| 91 | } | ||
| 92 | |||
| 93 | [Fact] | ||
| 94 | public void CanHarvestFile() | ||
| 95 | { | ||
| 96 | var folder = TestData.Get("TestData", "SingleFile"); | ||
| 97 | |||
| 98 | using (var fs = new DisposableFileSystem()) | ||
| 99 | { | ||
| 100 | var outputPath = Path.Combine(fs.GetFolder(), "out.wxs"); | ||
| 101 | |||
| 102 | var args = new[] | ||
| 103 | { | ||
| 104 | "file", Path.Combine(folder, "a.txt"), | ||
| 105 | "-cg", "GroupA", | ||
| 106 | "-dr", "ProgramFiles6432Folder", | ||
| 107 | "-o", outputPath | ||
| 108 | |||
| 109 | }; | ||
| 110 | |||
| 111 | var result = HeatRunner.Execute(args); | ||
| 112 | result.AssertSuccess(); | ||
| 113 | |||
| 114 | var wxs = File.ReadAllLines(outputPath).Select(s => s.Replace("\"", "'")).ToArray(); | ||
| 115 | WixAssert.CompareLineByLine(new[] | ||
| 116 | { | ||
| 117 | "<?xml version='1.0' encoding='utf-8'?>", | ||
| 118 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
| 119 | " <Fragment>", | ||
| 120 | " <StandardDirectory Id='ProgramFiles6432Folder'>", | ||
| 121 | " <Directory Id='dirl6r_Yc0gvMUEUVe5rioOOIIasoU' Name='SingleFile' />", | ||
| 122 | " </StandardDirectory>", | ||
| 123 | " </Fragment>", | ||
| 124 | " <Fragment>", | ||
| 125 | " <ComponentGroup Id='GroupA'>", | ||
| 126 | " <Component Id='cmpfBcW61_XzosRWK3EzUTBtJrcJD8' Directory='dirl6r_Yc0gvMUEUVe5rioOOIIasoU' Guid='PUT-GUID-HERE'>", | ||
| 127 | " <File Id='filKrZgaIOSKpNZXFnezZc9X.LKGpw' KeyPath='yes' Source='SourceDir\\SingleFile\\a.txt' />", | ||
| 128 | " </Component>", | ||
| 129 | " </ComponentGroup>", | ||
| 130 | " </Fragment>", | ||
| 131 | "</Wix>", | ||
| 132 | }, wxs); | ||
| 133 | } | ||
| 134 | } | ||
| 135 | } | ||
| 136 | } | ||
diff --git a/src/tools/test/WixToolsetTest.Heat/HeatRunner.cs b/src/tools/test/WixToolsetTest.Heat/HeatRunner.cs index d8b6b39a..c914dcac 100644 --- a/src/tools/test/WixToolsetTest.Heat/HeatRunner.cs +++ b/src/tools/test/WixToolsetTest.Heat/HeatRunner.cs | |||
| @@ -1,17 +1,14 @@ | |||
| 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. | 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 | 2 | ||
| 3 | namespace WixToolsetTest.Harvesters | 3 | namespace WixToolsetTest.Heat |
| 4 | { | 4 | { |
| 5 | using System; | ||
| 6 | using System.Collections.Generic; | 5 | using System.Collections.Generic; |
| 7 | using System.Threading; | ||
| 8 | using System.Threading.Tasks; | 6 | using System.Threading.Tasks; |
| 9 | using WixToolset.Core; | 7 | using WixToolset.Core; |
| 10 | using WixToolset.Core.TestPackage; | 8 | using WixToolset.Core.TestPackage; |
| 11 | using WixToolset.Data; | 9 | using WixToolset.Data; |
| 12 | using WixToolset.Extensibility.Data; | ||
| 13 | using WixToolset.Extensibility.Services; | 10 | using WixToolset.Extensibility.Services; |
| 14 | using WixToolset.Harvesters; | 11 | using WixToolset.Tools.Heat; |
| 15 | 12 | ||
| 16 | /// <summary> | 13 | /// <summary> |
| 17 | /// Utility class to emulate heat.exe. | 14 | /// Utility class to emulate heat.exe. |
| @@ -66,8 +63,6 @@ namespace WixToolsetTest.Harvesters | |||
| 66 | /// <returns></returns> | 63 | /// <returns></returns> |
| 67 | public static Task<int> Execute(string[] args, IWixToolsetCoreServiceProvider coreProvider, out List<Message> messages, bool warningsAsErrors = true) | 64 | public static Task<int> Execute(string[] args, IWixToolsetCoreServiceProvider coreProvider, out List<Message> messages, bool warningsAsErrors = true) |
| 68 | { | 65 | { |
| 69 | coreProvider.AddBundleBackend(); | ||
| 70 | |||
| 71 | var listener = new TestMessageListener(); | 66 | var listener = new TestMessageListener(); |
| 72 | 67 | ||
| 73 | messages = listener.Messages; | 68 | messages = listener.Messages; |
| @@ -80,12 +75,8 @@ namespace WixToolsetTest.Harvesters | |||
| 80 | messaging.WarningsAsError = true; | 75 | messaging.WarningsAsError = true; |
| 81 | } | 76 | } |
| 82 | 77 | ||
| 83 | var arguments = coreProvider.GetService<ICommandLineArguments>(); | 78 | var program = new Program(); |
| 84 | arguments.Populate(args); | 79 | return program.Run(coreProvider, listener, args); |
| 85 | |||
| 86 | var commandLine = HeatCommandLineFactory.CreateCommandLine(coreProvider); | ||
| 87 | var command = commandLine.ParseStandardCommandLine(arguments); | ||
| 88 | return command?.ExecuteAsync(CancellationToken.None) ?? Task.FromResult(1); | ||
| 89 | } | 80 | } |
| 90 | } | 81 | } |
| 91 | } | 82 | } |
diff --git a/src/tools/test/WixToolsetTest.Heat/TestData/SingleFile/a.txt b/src/tools/test/WixToolsetTest.Heat/TestData/SingleFile/a.txt new file mode 100644 index 00000000..4410bb5e --- /dev/null +++ b/src/tools/test/WixToolsetTest.Heat/TestData/SingleFile/a.txt | |||
| @@ -0,0 +1 @@ | |||
| This is a.txt | |||
diff --git a/src/tools/test/WixToolsetTest.Heat/WixToolsetTest.Heat.csproj b/src/tools/test/WixToolsetTest.Heat/WixToolsetTest.Heat.csproj index 73eb078c..c887297b 100644 --- a/src/tools/test/WixToolsetTest.Heat/WixToolsetTest.Heat.csproj +++ b/src/tools/test/WixToolsetTest.Heat/WixToolsetTest.Heat.csproj | |||
| @@ -3,13 +3,23 @@ | |||
| 3 | 3 | ||
| 4 | <Project Sdk="Microsoft.NET.Sdk"> | 4 | <Project Sdk="Microsoft.NET.Sdk"> |
| 5 | <PropertyGroup> | 5 | <PropertyGroup> |
| 6 | <TargetFramework>netcoreapp3.1</TargetFramework> | 6 | <TargetFramework>net472</TargetFramework> |
| 7 | <IsPackable>false</IsPackable> | 7 | <IsPackable>false</IsPackable> |
| 8 | <DebugType>embedded</DebugType> | ||
| 9 | <DefaultItemExcludes>TestData\**;$(DefaultItemExcludes)</DefaultItemExcludes> | ||
| 8 | <SignOutput>false</SignOutput> | 10 | <SignOutput>false</SignOutput> |
| 9 | </PropertyGroup> | 11 | </PropertyGroup> |
| 10 | 12 | ||
| 11 | <ItemGroup> | 13 | <ItemGroup> |
| 12 | <PackageReference Include="WixBuildTools.TestSupport" /> | 14 | <Content Include="TestData\**" CopyToOutputDirectory="PreserveNewest" /> |
| 15 | </ItemGroup> | ||
| 16 | |||
| 17 | <ItemGroup> | ||
| 18 | <ProjectReference Include="..\..\heat\heat.csproj" /> | ||
| 19 | </ItemGroup> | ||
| 20 | |||
| 21 | <ItemGroup> | ||
| 22 | <PackageReference Include="WixToolset.Core.TestPackage" /> | ||
| 13 | </ItemGroup> | 23 | </ItemGroup> |
| 14 | 24 | ||
| 15 | <ItemGroup> | 25 | <ItemGroup> |
