Skip to content

Commit

Permalink
Error output as info in terminal logger (#5113)
Browse files Browse the repository at this point in the history
  • Loading branch information
nohwnd authored Jun 20, 2024
1 parent 3d2ea06 commit 7264afa
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/Microsoft.TestPlatform.Build/Tasks/VSTestTask2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,11 @@ protected override void LogEventsFromTextOutput(string singleLine, MessageImport
break;
case "output-error":
{
// Downgrade errors to info messages, xUnit outputs every assertion failure and it confuses users who see doubled error count.
// Libraries write to error output, and don't expect tests to fail.
// Logs are often written to error stream as well.
var error = data[0];
if (error != null && error.StartsWith("[xUnit.net", StringComparison.OrdinalIgnoreCase))
{
// Downgrade errors from xunit, because they will end up being duplicated on screen with assertion errors.
// And we end up with more errors in summary which is hard to figure out for users.
LogMSBuildOutputMessage(error);
}
else
{
Log.LogError(data[0]);
}
LogMSBuildOutputMessage(error);

break;
}
Expand Down Expand Up @@ -248,9 +242,14 @@ protected override void LogEventsFromTextOutput(string singleLine, MessageImport
}
}

private void LogMSBuildOutputMessage(string singleLine)
private void LogMSBuildOutputMessage(string? singleLine)
{

if (singleLine == null)
{
return;
}

var message = new ExtendedBuildMessageEventArgs("TLTESTOUTPUT", singleLine, null, null, MessageImportance.High);
BuildEngine.LogMessageEvent(message);
}
Expand Down

0 comments on commit 7264afa

Please sign in to comment.