From 94e722baab4e848a615812a45fecc8322335d1f0 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 16 Aug 2022 18:11:54 -0700 Subject: Update heat to use StandardDirectory element Fixes 6631 --- src/tools/test/WixToolsetTest.Heat/HeatFixture.cs | 136 +++++++++++++++++++++ src/tools/test/WixToolsetTest.Heat/HeatRunner.cs | 17 +-- .../WixToolsetTest.Heat/TestData/SingleFile/a.txt | 1 + .../WixToolsetTest.Heat/WixToolsetTest.Heat.csproj | 14 ++- 4 files changed, 153 insertions(+), 15 deletions(-) create mode 100644 src/tools/test/WixToolsetTest.Heat/HeatFixture.cs create mode 100644 src/tools/test/WixToolsetTest.Heat/TestData/SingleFile/a.txt (limited to 'src/tools/test') 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 @@ +// 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. + +namespace WixToolsetTest.Heat +{ + using System.IO; + using System.Linq; + using WixBuildTools.TestSupport; + using Xunit; + + public class HeatFixture + { + [Fact] + public void CanHarvestSimpleDirectory() + { + var folder = TestData.Get("TestData", "SingleFile"); + + using (var fs = new DisposableFileSystem()) + { + var outputPath = Path.Combine(fs.GetFolder(), "out.wxs"); + + var args = new[] + { + "dir", folder, + "-o", outputPath + }; + + var result = HeatRunner.Execute(args); + result.AssertSuccess(); + + var wxs = File.ReadAllLines(outputPath).Select(s => s.Replace("\"", "'")).ToArray(); + WixAssert.CompareLineByLine(new[] + { + "", + "", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "", + }, wxs); + } + } + + [Fact] + public void CanHarvestSimpleDirectoryToInstallFolder() + { + var folder = TestData.Get("TestData", "SingleFile"); + + using (var fs = new DisposableFileSystem()) + { + var outputPath = Path.Combine(fs.GetFolder(), "out.wxs"); + + var args = new[] + { + "dir", folder, + "-dr", "INSTALLFOLDER", + "-o", outputPath + }; + + var result = HeatRunner.Execute(args); + result.AssertSuccess(); + + var wxs = File.ReadAllLines(outputPath).Select(s => s.Replace("\"", "'")).ToArray(); + WixAssert.CompareLineByLine(new[] + { + "", + "", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "", + }, wxs); + } + } + + [Fact] + public void CanHarvestFile() + { + var folder = TestData.Get("TestData", "SingleFile"); + + using (var fs = new DisposableFileSystem()) + { + var outputPath = Path.Combine(fs.GetFolder(), "out.wxs"); + + var args = new[] + { + "file", Path.Combine(folder, "a.txt"), + "-cg", "GroupA", + "-dr", "ProgramFiles6432Folder", + "-o", outputPath + + }; + + var result = HeatRunner.Execute(args); + result.AssertSuccess(); + + var wxs = File.ReadAllLines(outputPath).Select(s => s.Replace("\"", "'")).ToArray(); + WixAssert.CompareLineByLine(new[] + { + "", + "", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "", + }, wxs); + } + } + } +} 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 @@ // 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. -namespace WixToolsetTest.Harvesters +namespace WixToolsetTest.Heat { - using System; using System.Collections.Generic; - using System.Threading; using System.Threading.Tasks; using WixToolset.Core; using WixToolset.Core.TestPackage; using WixToolset.Data; - using WixToolset.Extensibility.Data; using WixToolset.Extensibility.Services; - using WixToolset.Harvesters; + using WixToolset.Tools.Heat; /// /// Utility class to emulate heat.exe. @@ -66,8 +63,6 @@ namespace WixToolsetTest.Harvesters /// public static Task Execute(string[] args, IWixToolsetCoreServiceProvider coreProvider, out List messages, bool warningsAsErrors = true) { - coreProvider.AddBundleBackend(); - var listener = new TestMessageListener(); messages = listener.Messages; @@ -80,12 +75,8 @@ namespace WixToolsetTest.Harvesters messaging.WarningsAsError = true; } - var arguments = coreProvider.GetService(); - arguments.Populate(args); - - var commandLine = HeatCommandLineFactory.CreateCommandLine(coreProvider); - var command = commandLine.ParseStandardCommandLine(arguments); - return command?.ExecuteAsync(CancellationToken.None) ?? Task.FromResult(1); + var program = new Program(); + return program.Run(coreProvider, listener, args); } } } 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 @@ - netcoreapp3.1 + net472 false + embedded + TestData\**;$(DefaultItemExcludes) false - + + + + + + + + + -- cgit v1.2.3-55-g6feb