diff options
| author | Rob Mensching <rob@firegiant.com> | 2017-12-22 15:53:01 -0800 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2017-12-22 15:53:01 -0800 |
| commit | ecf3a0cca5a424a91ab98557d963d2535963d582 (patch) | |
| tree | 06355e906e5c404480dc6eac342b9b4d2ec9d122 /src/test | |
| parent | dc9f4c329e6f55ce7595970463e0caf148096f4b (diff) | |
| download | wix-ecf3a0cca5a424a91ab98557d963d2535963d582.tar.gz wix-ecf3a0cca5a424a91ab98557d963d2535963d582.tar.bz2 wix-ecf3a0cca5a424a91ab98557d963d2535963d582.zip | |
Reintroduce binder extensions and light.exe for binding .wixouts
Diffstat (limited to 'src/test')
7 files changed, 196 insertions, 0 deletions
diff --git a/src/test/WixToolsetTest.LightIntegration/LightFixture.cs b/src/test/WixToolsetTest.LightIntegration/LightFixture.cs new file mode 100644 index 00000000..21c10be9 --- /dev/null +++ b/src/test/WixToolsetTest.LightIntegration/LightFixture.cs | |||
| @@ -0,0 +1,48 @@ | |||
| 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.LightIntegration | ||
| 4 | { | ||
| 5 | using System.IO; | ||
| 6 | using System.Linq; | ||
| 7 | using WixToolset.Core; | ||
| 8 | using WixToolset.Tools; | ||
| 9 | using WixToolsetTest.LightIntegration.Utility; | ||
| 10 | using Xunit; | ||
| 11 | |||
| 12 | public class LightFixture | ||
| 13 | { | ||
| 14 | [Fact] | ||
| 15 | public void CanBuildFromWixout() | ||
| 16 | { | ||
| 17 | var folder = TestData.Get(@"TestData\Wixout"); | ||
| 18 | |||
| 19 | using (var fs = new DisposableFileSystem()) | ||
| 20 | { | ||
| 21 | var baseFolder = fs.GetFolder(); | ||
| 22 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
| 23 | |||
| 24 | var program = new Light(); | ||
| 25 | var result = program.Run(new WixToolsetServiceProvider(), null, new[] | ||
| 26 | { | ||
| 27 | Path.Combine(folder, "test.wixout"), | ||
| 28 | "-loc", Path.Combine(folder, "Package.en-us.wxl"), | ||
| 29 | "-b", Path.Combine(folder, "data"), | ||
| 30 | "-intermediateFolder", intermediateFolder, | ||
| 31 | "-o", Path.Combine(baseFolder, @"bin\test.msi") | ||
| 32 | }); | ||
| 33 | |||
| 34 | Assert.Equal(0, result); | ||
| 35 | |||
| 36 | var binFolder = Path.Combine(baseFolder, @"bin\"); | ||
| 37 | var builtFiles = Directory.GetFiles(binFolder, "*", SearchOption.AllDirectories); | ||
| 38 | |||
| 39 | Assert.Equal(new[]{ | ||
| 40 | "MsiPackage\\test.txt", | ||
| 41 | "test.msi", | ||
| 42 | "test.wir", | ||
| 43 | "test.wixpdb", | ||
| 44 | }, builtFiles.Select(f => f.Substring(binFolder.Length)).OrderBy(s => s).ToArray()); | ||
| 45 | } | ||
| 46 | } | ||
| 47 | } | ||
| 48 | } | ||
diff --git a/src/test/WixToolsetTest.LightIntegration/TestData/Wixout/Package.en-us.wxl b/src/test/WixToolsetTest.LightIntegration/TestData/Wixout/Package.en-us.wxl new file mode 100644 index 00000000..38c12ac1 --- /dev/null +++ b/src/test/WixToolsetTest.LightIntegration/TestData/Wixout/Package.en-us.wxl | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | |||
| 3 | <!-- | ||
| 4 | This file contains the declaration of all the localizable strings. | ||
| 5 | --> | ||
| 6 | <WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="en-US"> | ||
| 7 | |||
| 8 | <String Id="DowngradeError">A newer version of [ProductName] is already installed.</String> | ||
| 9 | <String Id="FeatureTitle">MsiPackage</String> | ||
| 10 | |||
| 11 | </WixLocalization> | ||
diff --git a/src/test/WixToolsetTest.LightIntegration/TestData/Wixout/data/test.txt b/src/test/WixToolsetTest.LightIntegration/TestData/Wixout/data/test.txt new file mode 100644 index 00000000..cd0db0e1 --- /dev/null +++ b/src/test/WixToolsetTest.LightIntegration/TestData/Wixout/data/test.txt | |||
| @@ -0,0 +1 @@ | |||
| This is test.txt. \ No newline at end of file | |||
diff --git a/src/test/WixToolsetTest.LightIntegration/TestData/Wixout/test.wixout b/src/test/WixToolsetTest.LightIntegration/TestData/Wixout/test.wixout new file mode 100644 index 00000000..009b625f --- /dev/null +++ b/src/test/WixToolsetTest.LightIntegration/TestData/Wixout/test.wixout | |||
| Binary files differ | |||
diff --git a/src/test/WixToolsetTest.LightIntegration/Utility/DisposableFileSystem.cs b/src/test/WixToolsetTest.LightIntegration/Utility/DisposableFileSystem.cs new file mode 100644 index 00000000..3b8c0e19 --- /dev/null +++ b/src/test/WixToolsetTest.LightIntegration/Utility/DisposableFileSystem.cs | |||
| @@ -0,0 +1,86 @@ | |||
| 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.LightIntegration.Utility | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Collections.Generic; | ||
| 7 | using System.IO; | ||
| 8 | |||
| 9 | public class DisposableFileSystem : IDisposable | ||
| 10 | { | ||
| 11 | protected bool Disposed { get; private set; } | ||
| 12 | |||
| 13 | private List<string> CleanupPaths { get; } = new List<string>(); | ||
| 14 | |||
| 15 | protected string GetFile(bool create = false) | ||
| 16 | { | ||
| 17 | var path = Path.GetTempFileName(); | ||
| 18 | |||
| 19 | if (!create) | ||
| 20 | { | ||
| 21 | File.Delete(path); | ||
| 22 | } | ||
| 23 | |||
| 24 | this.CleanupPaths.Add(path); | ||
| 25 | |||
| 26 | return path; | ||
| 27 | } | ||
| 28 | |||
| 29 | public string GetFolder(bool create = false) | ||
| 30 | { | ||
| 31 | var path = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); | ||
| 32 | |||
| 33 | if (create) | ||
| 34 | { | ||
| 35 | Directory.CreateDirectory(path); | ||
| 36 | } | ||
| 37 | |||
| 38 | this.CleanupPaths.Add(path); | ||
| 39 | |||
| 40 | return path; | ||
| 41 | } | ||
| 42 | |||
| 43 | |||
| 44 | #region // IDisposable | ||
| 45 | |||
| 46 | public void Dispose() | ||
| 47 | { | ||
| 48 | this.Dispose(true); | ||
| 49 | GC.SuppressFinalize(this); | ||
| 50 | } | ||
| 51 | |||
| 52 | protected virtual void Dispose(bool disposing) | ||
| 53 | { | ||
| 54 | if (this.Disposed) | ||
| 55 | { | ||
| 56 | return; | ||
| 57 | } | ||
| 58 | |||
| 59 | if (disposing) | ||
| 60 | { | ||
| 61 | foreach (var path in this.CleanupPaths) | ||
| 62 | { | ||
| 63 | try | ||
| 64 | { | ||
| 65 | if (File.Exists(path)) | ||
| 66 | { | ||
| 67 | File.Delete(path); | ||
| 68 | } | ||
| 69 | else if (Directory.Exists(path)) | ||
| 70 | { | ||
| 71 | Directory.Delete(path, true); | ||
| 72 | } | ||
| 73 | } | ||
| 74 | catch | ||
| 75 | { | ||
| 76 | // Best effort delete, so ignore any failures. | ||
| 77 | } | ||
| 78 | } | ||
| 79 | } | ||
| 80 | |||
| 81 | this.Disposed = true; | ||
| 82 | } | ||
| 83 | |||
| 84 | #endregion | ||
| 85 | } | ||
| 86 | } | ||
diff --git a/src/test/WixToolsetTest.LightIntegration/Utility/TestData.cs b/src/test/WixToolsetTest.LightIntegration/Utility/TestData.cs new file mode 100644 index 00000000..c13e9d6d --- /dev/null +++ b/src/test/WixToolsetTest.LightIntegration/Utility/TestData.cs | |||
| @@ -0,0 +1,17 @@ | |||
| 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.LightIntegration.Utility | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.IO; | ||
| 7 | |||
| 8 | public class TestData | ||
| 9 | { | ||
| 10 | public static string LocalPath => Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath); | ||
| 11 | |||
| 12 | public static string Get(params string[] paths) | ||
| 13 | { | ||
| 14 | return Path.Combine(LocalPath, Path.Combine(paths)); | ||
| 15 | } | ||
| 16 | } | ||
| 17 | } | ||
diff --git a/src/test/WixToolsetTest.LightIntegration/WixToolsetTest.LightIntegration.csproj b/src/test/WixToolsetTest.LightIntegration/WixToolsetTest.LightIntegration.csproj new file mode 100644 index 00000000..ef303868 --- /dev/null +++ b/src/test/WixToolsetTest.LightIntegration/WixToolsetTest.LightIntegration.csproj | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | <!-- 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. --> | ||
| 3 | |||
| 4 | <Project Sdk="Microsoft.NET.Sdk"> | ||
| 5 | <PropertyGroup> | ||
| 6 | <TargetFramework>net461</TargetFramework> | ||
| 7 | <IsPackable>false</IsPackable> | ||
| 8 | </PropertyGroup> | ||
| 9 | <ItemGroup> | ||
| 10 | <None Remove="TestData\Wixout\Package.en-us.wxl" /> | ||
| 11 | <None Remove="TestData\Wixout\test.wixout" /> | ||
| 12 | </ItemGroup> | ||
| 13 | |||
| 14 | <ItemGroup> | ||
| 15 | <Content Include="TestData\Wixout\data\test.txt" CopyToOutputDirectory="PreserveNewest" /> | ||
| 16 | <Content Include="TestData\Wixout\Package.en-us.wxl"> | ||
| 17 | <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
| 18 | </Content> | ||
| 19 | <Content Include="TestData\Wixout\test.wixout"> | ||
| 20 | <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
| 21 | </Content> | ||
| 22 | </ItemGroup> | ||
| 23 | |||
| 24 | <ItemGroup> | ||
| 25 | <ProjectReference Include="..\..\light\light.csproj" /> | ||
| 26 | </ItemGroup> | ||
| 27 | |||
| 28 | <ItemGroup> | ||
| 29 | <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0-preview-20170628-02" /> | ||
| 30 | <PackageReference Include="xunit" Version="2.2.0" /> | ||
| 31 | <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" /> | ||
| 32 | </ItemGroup> | ||
| 33 | </Project> | ||
