Skip to content

Commit

Permalink
Print the output
Browse files Browse the repository at this point in the history
  • Loading branch information
dellis1972 committed Aug 26, 2024
1 parent 63d06ac commit 7000f30
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions Tools/MonoGame.Tools.Tests/BuilderTargetsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ string FindTool (string toolName)
TestContext.WriteLine ("returning:" + toolName);
return toolName;
}
bool RunBuild(string buildTool, string projectFile, out string output, params string[] parameters)
bool RunBuild(string buildTool, string projectFile, params string[] parameters)
{
var root = Path.GetDirectoryName(typeof(BuilderTargetsTest).Assembly.Location);
var psi = new ProcessStartInfo(FindTool(buildTool))
Expand All @@ -34,15 +34,30 @@ bool RunBuild(string buildTool, string projectFile, out string output, params st
WorkingDirectory = root,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true
};
TestContext.WriteLine (psi.FileName + " " + psi.Arguments);
using (var process = Process.Start(psi))
{
output = process.StandardOutput.ReadToEnd();
process.OutputDataReceived += (sender, e) => {
if (!string.IsNullOrEmpty(e.Data))
{
TestContext.WriteLine($"Output: {e.Data}");
}
};

process.ErrorDataReceived += (sender, e) => {
if (!string.IsNullOrEmpty(e.Data))
{
TestContext.WriteLine($"Error: {e.Data}");
}
};
process.BeginOutputReadLine();
process.BeginErrorReadLine();
process.WaitForExit();
return process.ExitCode == 0;
}
TestContext.WriteLine (output);
}

[Test]
Expand All @@ -53,10 +68,10 @@ public void BuildSimpleProject()
if (Directory.Exists(outputPath))
Directory.Delete(outputPath, recursive: true);

var result = RunBuild("dotnet", Path.Combine(root, "Assets", "Projects", "BuildSimpleProject.csproj"), out string output, new string[] {
var result = RunBuild("dotnet", Path.Combine(root, "Assets", "Projects", "BuildSimpleProject.csproj"), new string[] {
"-p:MGCBCommand=" + Path.Combine(root, "mgcb.dll")
});
Assert.AreEqual(true, result, $"Content Build should have succeeded.\n{output}");
Assert.AreEqual(true, result, "Content Build should have succeeded.");
var contentFont = Path.Combine(outputPath, "DesktopGL", "Content", "ContentFont.xnb");
Assert.IsTrue(File.Exists(contentFont), "'" + contentFont + "' should exist.");
}
Expand Down

0 comments on commit 7000f30

Please sign in to comment.