Try to fix build flakiness with Example.Extension. Add failing test for the TableDefinition overload of EnsureTable.
Try to fix build flakiness with Example.Extension. Add failing test for the TableDefinition overload of EnsureTable.
Sean Hall committed
Apr 6, 2020 at 14:06 UTC
59ffa86b7d62ddc52ec813fb65c47f812aeded66
6 files changed
+69
-1
src/test/Example.Extension/Example.Extension.csproj
+1
-1
@@ -33,7 +33,7 @@
33
</ItemGroup>
34
</Target>
35
36
- <Target Name="BuildExtensionWixlib" AfterTargets="ResolveProjectReferences" DependsOnTargets="SetExtensionWixlib" Inputs="@(ExtensionWxs);$(CompileWixlibExePath)" Outputs="$(WixlibPath)">
36
+ <Target Name="BuildExtensionWixlib" AfterTargets="ResolveProjectReferences" DependsOnTargets="ResolveProjectReferences;SetExtensionWixlib" Inputs="@(ExtensionWxs);$(CompileWixlibExePath)" Outputs="$(WixlibPath)">
37
<Exec Command='$(CompileWixlibExePath) "$(IntermediateOutputPath)\" "$(WixlibPath)" "@(ExtensionWxs)"' />
38
</Target>
39
</Project>
src/test/Example.Extension/ExampleCompilerExtension.cs
+10
@@ -23,6 +23,10 @@ namespace Example.Extension
23
case "Fragment":
24
switch (element.Name.LocalName)
25
{
26
+ case "ExampleEnsureTable":
27
+ this.ParseExampleEnsureTableElement(intermediate, section, element);
28
+ processed = true;
29
+ break;
30
case "ExampleSearch":
31
this.ParseExampleSearchElement(intermediate, section, element);
32
processed = true;
@@ -93,6 +97,12 @@ namespace Example.Extension
97
}
98
}
99
100
+ private void ParseExampleEnsureTableElement(Intermediate intermediate, IntermediateSection section, XElement element)
101
+ {
102
+ var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element);
103
+ this.ParseHelper.EnsureTable(section, sourceLineNumbers, ExampleTableDefinitions.NotInAll);
104
+ }
105
+
106
private void ParseExampleSearchElement(Intermediate intermediate, IntermediateSection section, XElement element)
107
{
108
var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element);
src/test/Example.Extension/ExampleTableDefinitions.cs
+10
@@ -17,6 +17,16 @@ namespace Example.Extension
17
tupleIdIsPrimaryKey: true
18
);
19
20
+ public static readonly TableDefinition NotInAll = new TableDefinition(
21
+ "TableDefinitionNotExposedByExtension",
22
+ new[]
23
+ {
24
+ new ColumnDefinition("Example", ColumnType.String, 72, true, false, ColumnCategory.Identifier),
25
+ new ColumnDefinition("Value", ColumnType.String, 0, false, false, ColumnCategory.Formatted),
26
+ },
27
+ tupleIdIsPrimaryKey: true
28
+ );
29
+
30
public static readonly TableDefinition[] All = new[] { ExampleTable };
31
}
32
}
src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs
+36
@@ -2,8 +2,10 @@
2
3
namespace WixToolsetTest.CoreIntegration
4
{
5
+ using System;
6
using System.IO;
7
using System.Linq;
8
+ using Example.Extension;
9
using WixBuildTools.TestSupport;
10
using WixToolset.Core.TestPackage;
11
using WixToolset.Data;
@@ -882,5 +884,39 @@ namespace WixToolsetTest.CoreIntegration
884
Assert.NotEmpty(output.SubStorages);
885
}
886
}
887
+
888
+ [Fact(Skip = "Test demonstrates failure")]
889
+ public void FailsBuildAtLinkTimeForMissingEnsureTable()
890
+ {
891
+ var folder = TestData.Get(@"TestData");
892
+ var extensionPath = Path.GetFullPath(new Uri(typeof(ExampleExtensionFactory).Assembly.CodeBase).LocalPath);
893
+
894
+ using (var fs = new DisposableFileSystem())
895
+ {
896
+ var baseFolder = fs.GetFolder();
897
+ var intermediateFolder = Path.Combine(baseFolder, "obj");
898
+ var msiPath = Path.Combine(baseFolder, @"bin\test.msi");
899
+
900
+ var result = WixRunner.Execute(new[]
901
+ {
902
+ "build",
903
+ Path.Combine(folder, "BadEnsureTable", "BadEnsureTable.wxs"),
904
+ Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"),
905
+ Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"),
906
+ "-ext", extensionPath,
907
+ "-bindpath", Path.Combine(folder, "SingleFile", "data"),
908
+ "-intermediateFolder", intermediateFolder,
909
+ "-o", msiPath
910
+ });
911
+ Assert.Collection(result.Messages,
912
+ first =>
913
+ {
914
+ Assert.Equal(MessageLevel.Error, first.Level);
915
+ Assert.Equal("The identifier 'WixCustomTable:TableDefinitionNotExposedByExtension' could not be found. Ensure you have typed the reference correctly and that all the necessary inputs are provided to the linker.", first.ToString());
916
+ });
917
+
918
+ Assert.False(File.Exists(msiPath));
919
+ }
920
+ }
921
}
922
}
src/test/WixToolsetTest.CoreIntegration/TestData/BadEnsureTable/BadEnsureTable.wxs
new
+11
@@ -0,0 +1,11 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
3
+ xmlns:ex="http://www.example.com/scheams/v1/wxs">
4
+ <Fragment>
5
+ <ComponentGroup Id="ProductComponents">
6
+ <ComponentGroupRef Id="MinimalComponentGroup" />
7
+ </ComponentGroup>
8
+
9
+ <ex:ExampleEnsureTable />
10
+ </Fragment>
11
+</Wix>
src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj
+1
@@ -21,6 +21,7 @@
21
<Content Include="TestData\AppSearch\FileSearch.wxs" CopyToOutputDirectory="PreserveNewest" />
22
<Content Include="TestData\AppSearch\NestedDirSearchUnderRegSearch.msi" CopyToOutputDirectory="PreserveNewest" />
23
<Content Include="TestData\AppSearch\RegistrySearch.wxs" CopyToOutputDirectory="PreserveNewest" />
24
+ <Content Include="TestData\BadEnsureTable\BadEnsureTable.wxs" CopyToOutputDirectory="PreserveNewest" />
25
<Content Include="TestData\BundleExtension\BundleExtension.wxs" CopyToOutputDirectory="PreserveNewest" />
26
<Content Include="TestData\BundleExtension\BundleExtensionSearches.wxs" CopyToOutputDirectory="PreserveNewest" />
27
<Content Include="TestData\BundleExtension\BundleWithSearches.wxs" CopyToOutputDirectory="PreserveNewest" />