Add additional debug diagnostics for WixToolsetTest.BuildTasks tests
Rob Mensching committed
Jul 13, 2018 at 15:34 UTC
ae2f48bb249a9bfa7b509ae4a006faa99bdd6258
2 files changed
+14
-8
src/test/WixToolsetTest.BuildTasks/FakeBuildEngine.cs
+9
-5
@@ -3,11 +3,13 @@
3
namespace WixToolsetTest.BuildTasks
4
{
5
using System.Collections;
6
- using System.Diagnostics;
6
+ using System.Text;
7
using Microsoft.Build.Framework;
8
9
internal class FakeBuildEngine : IBuildEngine
10
{
11
+ private StringBuilder output = new StringBuilder();
12
+
13
public int ColumnNumberOfTaskNode => 0;
14
15
public bool ContinueOnError => false;
@@ -16,14 +18,16 @@ namespace WixToolsetTest.BuildTasks
18
19
public string ProjectFileOfTaskNode => "fake_wix.targets";
20
21
+ public string Output => this.output.ToString();
22
+
23
public bool BuildProjectFile(string projectFileName, string[] targetNames, IDictionary globalProperties, IDictionary targetOutputs) => throw new System.NotImplementedException();
24
21
- public void LogCustomEvent(CustomBuildEventArgs e) => Debug.Write(e.Message);
25
+ public void LogCustomEvent(CustomBuildEventArgs e) => this.output.AppendLine(e.Message);
26
23
- public void LogErrorEvent(BuildErrorEventArgs e) => Debug.Write(e.Message);
27
+ public void LogErrorEvent(BuildErrorEventArgs e) => this.output.AppendLine(e.Message);
28
25
- public void LogMessageEvent(BuildMessageEventArgs e) => Debug.Write(e.Message);
29
+ public void LogMessageEvent(BuildMessageEventArgs e) => this.output.AppendLine(e.Message);
30
27
- public void LogWarningEvent(BuildWarningEventArgs e) => Debug.Write(e.Message);
31
+ public void LogWarningEvent(BuildWarningEventArgs e) => this.output.AppendLine(e.Message);
32
}
33
}
src/test/WixToolsetTest.BuildTasks/MsbuildFixture.cs
+5
-3
@@ -14,7 +14,7 @@ namespace WixToolsetTest.BuildTasks
14
public partial class MsbuildFixture
15
{
16
[Fact]
17
- public void CanBuildSingleFile()
17
+ public void CanBuildSimpleMsiPackage()
18
{
19
var folder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage");
20
@@ -23,9 +23,11 @@ namespace WixToolsetTest.BuildTasks
23
var baseFolder = fs.GetFolder();
24
var intermediateFolder = Path.Combine(baseFolder, "obj");
25
26
+ var engine = new FakeBuildEngine();
27
+
28
var task = new DoIt
29
{
28
- BuildEngine = new FakeBuildEngine(),
30
+ BuildEngine = engine,
31
SourceFiles = new[]
32
{
33
new TaskItem(Path.Combine(folder, "Package.wxs")),
@@ -44,7 +46,7 @@ namespace WixToolsetTest.BuildTasks
46
};
47
48
var result = task.Execute();
47
- Assert.True(result, "MSBuild task failed unexpectedly.");
49
+ Assert.True(result, $"MSBuild task failed unexpectedly. Output:\r\n{engine.Output}");
50
51
Assert.True(File.Exists(Path.Combine(baseFolder, @"bin\test.msi")));
52
Assert.True(File.Exists(Path.Combine(baseFolder, @"bin\test.wixpdb")));