Skip to content

Commit

Permalink
Fix treating log messages from Node same as direct messages (#8954)
Browse files Browse the repository at this point in the history
Fixes #8814

Context
Messages coming from Nodes were handled differently than direct messages, for failing builds purposes.

Changes Made
Treating log messages from Node same as direct messages

Testing
Cant repro the local repro after changes

Notes
  • Loading branch information
rokonec authored Jun 27, 2023
1 parent 68d3eea commit 265f341
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/Build/BackEnd/Components/Logging/LoggingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,7 @@ private void RouteBuildEvent(object loggingEvent)
{
if (ShouldTreatWarningAsMessage(warningEvent))
{
loggingEvent = new BuildMessageEventArgs(
buildEventArgs = new BuildMessageEventArgs(
warningEvent.Subcategory,
warningEvent.Code,
warningEvent.File,
Expand All @@ -1458,7 +1458,7 @@ private void RouteBuildEvent(object loggingEvent)
}
else if (ShouldTreatWarningAsError(warningEvent))
{
loggingEvent = new BuildErrorEventArgs(
buildEventArgs = new BuildErrorEventArgs(
warningEvent.Subcategory,
warningEvent.Code,
warningEvent.File,
Expand All @@ -1477,26 +1477,32 @@ private void RouteBuildEvent(object loggingEvent)
}
}

if (loggingEvent is BuildErrorEventArgs errorEvent)
if (buildEventArgs is BuildErrorEventArgs errorEvent)
{
// Keep track of build submissions that have logged errors. If there is no build context, add BuildEventContext.InvalidSubmissionId.
_buildSubmissionIdsThatHaveLoggedErrors.Add(errorEvent.BuildEventContext?.SubmissionId ?? BuildEventContext.InvalidSubmissionId);
}

if (loggingEvent is ProjectFinishedEventArgs projectFinishedEvent && projectFinishedEvent.BuildEventContext != null)
if (buildEventArgs is ProjectFinishedEventArgs projectFinishedEvent && projectFinishedEvent.BuildEventContext != null)
{
int key = GetWarningsAsErrorOrMessageKey(projectFinishedEvent);
_warningsAsErrorsByProject?.Remove(key);
_warningsNotAsErrorsByProject?.Remove(key);
_warningsAsMessagesByProject?.Remove(key);
}

if (loggingEvent is BuildEventArgs loggingEventBuildArgs)
if (loggingEvent is BuildEventArgs)
{
RouteBuildEvent(loggingEventBuildArgs);
RouteBuildEvent(buildEventArgs);
}
else if (loggingEvent is KeyValuePair<int, BuildEventArgs> loggingEventKeyValuePair)
{
if (loggingEventKeyValuePair.Value != buildEventArgs)
{
// buildEventArgs has been altered, lets use that new one
loggingEventKeyValuePair = new KeyValuePair<int, BuildEventArgs>(loggingEventKeyValuePair.Key, buildEventArgs);
}

RouteBuildEvent(loggingEventKeyValuePair);
}
}
Expand Down

0 comments on commit 265f341

Please sign in to comment.