aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBob Arnson <bob@firegiant.com>2018-10-01 15:52:53 -0400
committerBob Arnson <bob@firegiant.com>2018-10-01 15:52:53 -0400
commitf6a736c4cbb800904c216ce5730ab02ab7fd4373 (patch)
tree14780e673d5b94aa55065912def89e16dc6f97ff /src
parent39aa251742e7d75992bdad01ebd52fad3ed45195 (diff)
downloadwix-f6a736c4cbb800904c216ce5730ab02ab7fd4373.tar.gz
wix-f6a736c4cbb800904c216ce5730ab02ab7fd4373.tar.bz2
wix-f6a736c4cbb800904c216ce5730ab02ab7fd4373.zip
Add failing test for wixtoolset/issues#5883.
Diffstat (limited to 'src')
-rw-r--r--src/test/wixcop/TestData/Preprocessor/ConvertedPreprocessor.wxs62
-rw-r--r--src/test/wixcop/TestData/Preprocessor/Preprocessor.wxs63
-rw-r--r--src/test/wixcop/TestData/Preprocessor/wixcop.settings.xml9
-rw-r--r--src/test/wixcop/WixCopFixture.cs59
-rw-r--r--src/test/wixcop/WixCopTests.csproj11
5 files changed, 196 insertions, 8 deletions
diff --git a/src/test/wixcop/TestData/Preprocessor/ConvertedPreprocessor.wxs b/src/test/wixcop/TestData/Preprocessor/ConvertedPreprocessor.wxs
new file mode 100644
index 00000000..d6280185
--- /dev/null
+++ b/src/test/wixcop/TestData/Preprocessor/ConvertedPreprocessor.wxs
@@ -0,0 +1,62 @@
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
5
6<?include WixVer.wxi ?>
7
8<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:swid="http://wixtoolset.org/schemas/v4/wxs/tag" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
9 <Product Id="*" Name="!(loc.ShortProduct) v$(var.WixMajorMinor) Core" Language="1033" Manufacturer="!(loc.Company)" Version="$(var.WixMsiProductVersion)" UpgradeCode="3618724B-2523-44F9-A908-866AA619504D">
10 <Package Compressed="yes" InstallerVersion="200" SummaryCodepage="1252" InstallScope="perMachine" />
11 <swid:Tag Regid="!(loc.Regid)" InstallDirectory="INSTALLFOLDER" />
12
13 <MajorUpgrade DowngradeErrorMessage="A later version of [ProductName] is already installed." />
14
15 <MediaTemplate CabinetTemplate="core{0}.cab" />
16
17 <Feature Id="Feature_WiX" Title="WiX Toolset" Level="1">
18 <Component Id="Licensing" Directory="INSTALLFOLDER">
19 <File Id="LICENSE.TXT" Source="LICENSE.TXT" />
20 </Component>
21
22 <Component Id="ProductRegistration" Directory="INSTALLFOLDER">
23 <RegistryKey Root="HKLM" Key="SOFTWARE\Microsoft\Windows Installer XML\$(var.WixMajorMinor)">
24 <RegistryValue Name="InstallFolder" Value="[INSTALLFOLDER]" Type="string" />
25 </RegistryKey>
26 </Component>
27
28 <Component Id="ProductFamilyRegistration" Directory="INSTALLFOLDER">
29 <RegistryKey Root="HKLM" Key="SOFTWARE\Microsoft\Windows Installer XML\$(var.WixMajor).x">
30 <RegistryValue Name="v$(var.WixMajorMinor)" Value="[INSTALLFOLDER]" Type="string" />
31 </RegistryKey>
32 </Component>
33
34 <Component Id="ProductInformation" Directory="BinFolder">
35 <RegistryKey Root="HKLM" Key="SOFTWARE\Microsoft\Windows Installer XML\$(var.WixMajorMinor)">
36 <RegistryValue Name="InstallRoot" Value="[BinFolder]" Type="string" />
37 <RegistryValue Name="ProductVersion" Value="[ProductVersion]" Type="string" />
38 </RegistryKey>
39
40 <RemoveFolder Id="CleanupShortcutFolder" Directory="ShortcutFolder" On="uninstall" />
41 </Component>
42
43 <Component Directory="BinFolder">
44 <File Source="common\wixtoolset.org.ico">
45 <?include ComRegistration.wxi ?>
46 </File>
47 <util:InternetShortcut Id="wixtoolset.org" Directory="ShortcutFolder" Name="WiX Home Page" Target="http://wixtoolset.org/" IconFile="file://[#wixtoolset.org.ico]" />
48 </Component>
49
50 <ComponentGroupRef Id="ToolsetComponents" />
51 <ComponentGroupRef Id="ExtensionComponents" />
52 <ComponentGroupRef Id="LuxComponents" />
53 <ComponentGroupRef Id="DocComponents" />
54 </Feature>
55
56 <FeatureRef Id="Feature_MSBuild" />
57 <FeatureRef Id="Feature_Intellisense2010" />
58 <FeatureRef Id="Feature_Intellisense2012" />
59 <FeatureRef Id="Feature_Intellisense2013" />
60 <FeatureRef Id="Feature_Intellisense2015" />
61 </Product>
62</Wix>
diff --git a/src/test/wixcop/TestData/Preprocessor/Preprocessor.wxs b/src/test/wixcop/TestData/Preprocessor/Preprocessor.wxs
new file mode 100644
index 00000000..2eb908c2
--- /dev/null
+++ b/src/test/wixcop/TestData/Preprocessor/Preprocessor.wxs
@@ -0,0 +1,63 @@
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
5
6<?include WixVer.wxi ?>
7
8<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:swid="http://schemas.microsoft.com/wix/TagExtension" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
9 <Product Id="*" Name="!(loc.ShortProduct) v$(var.WixMajorMinor) Core" Language="1033" Manufacturer="!(loc.Company)"
10 Version="$(var.WixMsiProductVersion)" UpgradeCode="3618724B-2523-44F9-A908-866AA619504D">
11 <Package Compressed="yes" InstallerVersion="200" SummaryCodepage="1252" InstallScope="perMachine" />
12 <swid:Tag Regid="!(loc.Regid)" InstallDirectory="INSTALLFOLDER" />
13
14 <MajorUpgrade DowngradeErrorMessage="A later version of [ProductName] is already installed." />
15
16 <MediaTemplate CabinetTemplate="core{0}.cab" />
17
18 <Feature Id="Feature_WiX" Title="WiX Toolset" Level="1">
19 <Component Id="Licensing" Directory="INSTALLFOLDER">
20 <File Source="LICENSE.TXT" />
21 </Component>
22
23 <Component Id="ProductRegistration" Directory="INSTALLFOLDER">
24 <RegistryKey Root="HKLM" Key="SOFTWARE\Microsoft\Windows Installer XML\$(var.WixMajorMinor)">
25 <RegistryValue Name="InstallFolder" Value="[INSTALLFOLDER]" Type="string" />
26 </RegistryKey>
27 </Component>
28
29 <Component Id="ProductFamilyRegistration" Directory="INSTALLFOLDER">
30 <RegistryKey Root="HKLM" Key="SOFTWARE\Microsoft\Windows Installer XML\$(var.WixMajor).x">
31 <RegistryValue Name="v$(var.WixMajorMinor)" Value="[INSTALLFOLDER]" Type="string" />
32 </RegistryKey>
33 </Component>
34
35 <Component Id="ProductInformation" Directory="BinFolder">
36 <RegistryKey Root="HKLM" Key="SOFTWARE\Microsoft\Windows Installer XML\$(var.WixMajorMinor)">
37 <RegistryValue Name="InstallRoot" Value="[BinFolder]" Type="string"/>
38 <RegistryValue Name="ProductVersion" Value="[ProductVersion]" Type="string" />
39 </RegistryKey>
40
41 <RemoveFolder Id="CleanupShortcutFolder" Directory="ShortcutFolder" On="uninstall" />
42 </Component>
43
44 <Component Directory="BinFolder">
45 <File Source="common\wixtoolset.org.ico">
46 <?include ComRegistration.wxi ?>
47 </File>
48 <util:InternetShortcut Id="wixtoolset.org" Directory="ShortcutFolder" Name="WiX Home Page" Target="http://wixtoolset.org/" IconFile="file://[#wixtoolset.org.ico]" />
49 </Component>
50
51 <ComponentGroupRef Id="ToolsetComponents" />
52 <ComponentGroupRef Id="ExtensionComponents" />
53 <ComponentGroupRef Id="LuxComponents" />
54 <ComponentGroupRef Id="DocComponents" />
55 </Feature>
56
57 <FeatureRef Id="Feature_MSBuild" />
58 <FeatureRef Id="Feature_Intellisense2010" />
59 <FeatureRef Id="Feature_Intellisense2012" />
60 <FeatureRef Id="Feature_Intellisense2013" />
61 <FeatureRef Id="Feature_Intellisense2015" />
62 </Product>
63</Wix>
diff --git a/src/test/wixcop/TestData/Preprocessor/wixcop.settings.xml b/src/test/wixcop/TestData/Preprocessor/wixcop.settings.xml
new file mode 100644
index 00000000..9d3ad496
--- /dev/null
+++ b/src/test/wixcop/TestData/Preprocessor/wixcop.settings.xml
@@ -0,0 +1,9 @@
1<?xml version="1.0"?>
2<Settings>
3 <IgnoreErrors>
4 <Test Id="WhitespacePrecedingNodeWrong"/>
5 <Test Id="WhitespacePrecedingEndElementWrong"/>
6 </IgnoreErrors>
7 <ErrorsAsWarnings/>
8 <ExemptFiles/>
9</Settings> \ No newline at end of file
diff --git a/src/test/wixcop/WixCopFixture.cs b/src/test/wixcop/WixCopFixture.cs
index d11865f1..1fa49be9 100644
--- a/src/test/wixcop/WixCopFixture.cs
+++ b/src/test/wixcop/WixCopFixture.cs
@@ -15,7 +15,7 @@ namespace WixCopTests
15{ 15{
16 public class WixCopFixture 16 public class WixCopFixture
17 { 17 {
18 [Fact(Skip = "Problematic at the moment.")] 18 [Fact]
19 public void CanConvertSingleFile() 19 public void CanConvertSingleFile()
20 { 20 {
21 const string beforeFileName = "SingleFile.wxs"; 21 const string beforeFileName = "SingleFile.wxs";
@@ -38,7 +38,53 @@ namespace WixCopTests
38 }; 38 };
39 39
40 var result = runner.Execute(out var messages); 40 var result = runner.Execute(out var messages);
41 41
42 Assert.Equal(2, result);
43
44 var actualLines = File.ReadAllLines(targetFile);
45 var expectedLines = File.ReadAllLines(Path.Combine(folder, afterFileName));
46 Assert.Equal(expectedLines, actualLines);
47
48 var runner2 = new WixCopRunner
49 {
50 FixErrors = true,
51 SearchPatterns =
52 {
53 targetFile,
54 },
55 };
56
57 var result2 = runner2.Execute(out var messages2);
58
59 Assert.Equal(0, result2);
60 }
61 }
62
63 [Fact]
64 public void RetainsPreprocessorInstructions()
65 {
66 const string beforeFileName = "Preprocessor.wxs";
67 const string afterFileName = "ConvertedPreprocessor.wxs";
68 var folder = TestData.Get(@"TestData\Preprocessor");
69
70 using (var fs = new DisposableFileSystem())
71 {
72 var baseFolder = fs.GetFolder(true);
73 var targetFile = Path.Combine(baseFolder, beforeFileName);
74 File.Copy(Path.Combine(folder, beforeFileName), Path.Combine(baseFolder, beforeFileName));
75
76 var runner = new WixCopRunner
77 {
78 FixErrors = true,
79 SettingFile1 = Path.Combine(folder, "wixcop.settings.xml"),
80 SearchPatterns =
81 {
82 targetFile,
83 },
84 };
85
86 var result = runner.Execute(out var messages);
87
42 Assert.Equal(2, result); 88 Assert.Equal(2, result);
43 89
44 var actualLines = File.ReadAllLines(targetFile); 90 var actualLines = File.ReadAllLines(targetFile);
@@ -48,6 +94,7 @@ namespace WixCopTests
48 var runner2 = new WixCopRunner 94 var runner2 = new WixCopRunner
49 { 95 {
50 FixErrors = true, 96 FixErrors = true,
97 SettingFile1 = Path.Combine(folder, "wixcop.settings.xml"),
51 SearchPatterns = 98 SearchPatterns =
52 { 99 {
53 targetFile, 100 targetFile,
@@ -66,14 +113,22 @@ namespace WixCopTests
66 113
67 public List<string> SearchPatterns { get; } = new List<string>(); 114 public List<string> SearchPatterns { get; } = new List<string>();
68 115
116 public string SettingFile1 { get; set; }
117
69 public int Execute(out List<string> messages) 118 public int Execute(out List<string> messages)
70 { 119 {
71 var argList = new List<string>(); 120 var argList = new List<string>();
121
72 if (this.FixErrors) 122 if (this.FixErrors)
73 { 123 {
74 argList.Add("-f"); 124 argList.Add("-f");
75 } 125 }
76 126
127 if (!String.IsNullOrEmpty(this.SettingFile1))
128 {
129 argList.Add($"-set1{this.SettingFile1}");
130 }
131
77 foreach (string searchPattern in this.SearchPatterns) 132 foreach (string searchPattern in this.SearchPatterns)
78 { 133 {
79 argList.Add(searchPattern); 134 argList.Add(searchPattern);
diff --git a/src/test/wixcop/WixCopTests.csproj b/src/test/wixcop/WixCopTests.csproj
index 0ae50dc8..012ef4db 100644
--- a/src/test/wixcop/WixCopTests.csproj
+++ b/src/test/wixcop/WixCopTests.csproj
@@ -12,12 +12,11 @@
12 <None Remove="TestData\SingleFile\SingleFile.wxs" /> 12 <None Remove="TestData\SingleFile\SingleFile.wxs" />
13 </ItemGroup> 13 </ItemGroup>
14 <ItemGroup> 14 <ItemGroup>
15 <Content Include="TestData\SingleFile\ConvertedSingleFile.wxs"> 15 <Content Include="TestData\SingleFile\ConvertedSingleFile.wxs" CopyToOutputDirectory="PreserveNewest" />
16 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 16 <Content Include="TestData\SingleFile\SingleFile.wxs" CopyToOutputDirectory="PreserveNewest" />
17 </Content> 17 <Content Include="TestData\Preprocessor\ConvertedPreprocessor.wxs" CopyToOutputDirectory="PreserveNewest" />
18 <Content Include="TestData\SingleFile\SingleFile.wxs"> 18 <Content Include="TestData\Preprocessor\Preprocessor.wxs" CopyToOutputDirectory="PreserveNewest" />
19 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 19 <Content Include="TestData\Preprocessor\wixcop.settings.xml" CopyToOutputDirectory="PreserveNewest" />
20 </Content>
21 </ItemGroup> 20 </ItemGroup>
22 21
23 <ItemGroup> 22 <ItemGroup>