Add failing test for wixtoolset/issues#5883.
Bob Arnson committed
Oct 1, 2018 at 15:52 UTC
f6a736c4cbb800904c216ce5730ab02ab7fd4373
5 files changed
+196
-8
src/test/wixcop/TestData/Preprocessor/ConvertedPreprocessor.wxs
new
+62
@@ -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>
src/test/wixcop/TestData/Preprocessor/Preprocessor.wxs
new
+63
@@ -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>
src/test/wixcop/TestData/Preprocessor/wixcop.settings.xml
new
+9
@@ -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
src/test/wixcop/WixCopFixture.cs
+57
-2
@@ -15,7 +15,7 @@ namespace WixCopTests
15
{
16
public class WixCopFixture
17
{
18
- [Fact(Skip = "Problematic at the moment.")]
18
+ [Fact]
19
public void CanConvertSingleFile()
20
{
21
const string beforeFileName = "SingleFile.wxs";
@@ -38,7 +38,53 @@ namespace WixCopTests
38
};
39
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
+
88
Assert.Equal(2, result);
89
90
var actualLines = File.ReadAllLines(targetFile);
@@ -48,6 +94,7 @@ namespace WixCopTests
94
var runner2 = new WixCopRunner
95
{
96
FixErrors = true,
97
+ SettingFile1 = Path.Combine(folder, "wixcop.settings.xml"),
98
SearchPatterns =
99
{
100
targetFile,
@@ -66,14 +113,22 @@ namespace WixCopTests
113
114
public List<string> SearchPatterns { get; } = new List<string>();
115
116
+ public string SettingFile1 { get; set; }
117
+
118
public int Execute(out List<string> messages)
119
{
120
var argList = new List<string>();
121
+
122
if (this.FixErrors)
123
{
124
argList.Add("-f");
125
}
126
127
+ if (!String.IsNullOrEmpty(this.SettingFile1))
128
+ {
129
+ argList.Add($"-set1{this.SettingFile1}");
130
+ }
131
+
132
foreach (string searchPattern in this.SearchPatterns)
133
{
134
argList.Add(searchPattern);
src/test/wixcop/WixCopTests.csproj
+5
-6
@@ -12,12 +12,11 @@
12
<None Remove="TestData\SingleFile\SingleFile.wxs" />
13
</ItemGroup>
14
<ItemGroup>
15
- <Content Include="TestData\SingleFile\ConvertedSingleFile.wxs">
16
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
17
- </Content>
18
- <Content Include="TestData\SingleFile\SingleFile.wxs">
19
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
20
- </Content>
15
+ <Content Include="TestData\SingleFile\ConvertedSingleFile.wxs" CopyToOutputDirectory="PreserveNewest" />
16
+ <Content Include="TestData\SingleFile\SingleFile.wxs" CopyToOutputDirectory="PreserveNewest" />
17
+ <Content Include="TestData\Preprocessor\ConvertedPreprocessor.wxs" CopyToOutputDirectory="PreserveNewest" />
18
+ <Content Include="TestData\Preprocessor\Preprocessor.wxs" CopyToOutputDirectory="PreserveNewest" />
19
+ <Content Include="TestData\Preprocessor\wixcop.settings.xml" CopyToOutputDirectory="PreserveNewest" />
20
</ItemGroup>
21
22
<ItemGroup>