diff --git a/src/Build.UnitTests/BackEnd/LoggingService_Tests.cs b/src/Build.UnitTests/BackEnd/LoggingService_Tests.cs index 7db8ea66ddd..44c8606a77c 100644 --- a/src/Build.UnitTests/BackEnd/LoggingService_Tests.cs +++ b/src/Build.UnitTests/BackEnd/LoggingService_Tests.cs @@ -1153,7 +1153,12 @@ public void ProcessLoggingEventConcurrentWithShutdown_DoesNotThrow() LoggingService loggingService = (LoggingService)LoggingService.CreateLoggingService(LoggerMode.Asynchronous, 1); ((IBuildComponent)loggingService).InitializeComponent(mockHost); - loggingService.RegisterLogger(new ConsoleLogger()); + + loggingService.RegisterLogger(new MockLogger()); + + Exception loggingThreadException = null; + loggingService.OnLoggingThreadException += ex => + Interlocked.CompareExchange(ref loggingThreadException, ex, null); using ManualResetEvent startSignal = new ManualResetEvent(false); Exception caughtException = null; @@ -1166,7 +1171,10 @@ public void ProcessLoggingEventConcurrentWithShutdown_DoesNotThrow() { try { - BuildMessageEventArgs msg = new BuildMessageEventArgs($"Message {i}", null, null, MessageImportance.Low); + BuildMessageEventArgs msg = new BuildMessageEventArgs($"Message {i}", null, null, MessageImportance.Low) + { + BuildEventContext = new BuildEventContext(0, 0, 0, 0), + }; loggingService.ProcessLoggingEvent(msg); } catch (Exception ex) @@ -1186,6 +1194,7 @@ public void ProcessLoggingEventConcurrentWithShutdown_DoesNotThrow() bool joined = logThread.Join(TimeSpan.FromSeconds(10)); joined.ShouldBeTrue("Logging thread did not terminate within the allotted time."); caughtException.ShouldBeNull(); + loggingThreadException.ShouldBeNull(); } #endregion