From afb0cfdc2d0cda529b4229c0c07b610b15de9fab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 24 Jun 2020 23:48:30 +0200 Subject: [PATCH] [wasm] Disable threading and other tests that cause issues in Microsoft.Extensions.Logging (#38338) Filed https://github.com/dotnet/runtime/issues/38337 for the tests that cause a runtime assert. The rest are normal threading ignores. --- .../tests/Common/ConsoleLoggerTest.cs | 68 ++++++++++--------- .../tests/Common/LoggerFactoryTest.cs | 1 + 2 files changed, 37 insertions(+), 32 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Logging/tests/Common/ConsoleLoggerTest.cs b/src/libraries/Microsoft.Extensions.Logging/tests/Common/ConsoleLoggerTest.cs index c0b14f8c090..448e4ba45af 100644 --- a/src/libraries/Microsoft.Extensions.Logging/tests/Common/ConsoleLoggerTest.cs +++ b/src/libraries/Microsoft.Extensions.Logging/tests/Common/ConsoleLoggerTest.cs @@ -95,7 +95,7 @@ private static string GetSyslogSeverityString(LogLevel level) } } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] public void LogsWhenMessageIsNotProvided() { // Arrange @@ -127,7 +127,7 @@ public void LogsWhenMessageIsNotProvided() GetMessage(sink.Writes.GetRange(2 * t.WritesPerMsg, t.WritesPerMsg))); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] public void DoesNotLog_NewLine_WhenNoExceptionIsProvided() { // Arrange @@ -155,7 +155,7 @@ public void DoesNotLog_NewLine_WhenNoExceptionIsProvided() Assert.Equal(expected2, GetMessage(sink.Writes.GetRange(3 * t.WritesPerMsg, t.WritesPerMsg))); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] [InlineData("Route with name 'Default' was not found.")] public void Writes_NewLine_WhenExceptionIsProvided(string message) { @@ -179,7 +179,7 @@ public void Writes_NewLine_WhenExceptionIsProvided(string message) Assert.Equal(expectedHeader + expectedMessage + expectedExceptionMessage, sink.Writes[1].Message); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] public void ThrowsException_WhenNoFormatterIsProvided() { // Arrange @@ -190,7 +190,7 @@ public void ThrowsException_WhenNoFormatterIsProvided() Assert.Throws(() => logger.Log(LogLevel.Trace, 1, "empty", new Exception(), null)); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] public void LogsWhenNullFilterGiven() { // Arrange @@ -211,7 +211,7 @@ public void LogsWhenNullFilterGiven() Assert.Equal(expectedHeader + expectedMessage, sink.Writes[1].Message); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] public void WriteCritical_LogsCorrectColors() { // Arrange @@ -253,7 +253,7 @@ public void WriteError_LogsCorrectColors() Assert.Equal(TestConsole.DefaultForegroundColor, write.ForegroundColor); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] public void WriteWarning_LogsCorrectColors() { // Arrange @@ -274,7 +274,7 @@ public void WriteWarning_LogsCorrectColors() Assert.Equal(TestConsole.DefaultForegroundColor, write.ForegroundColor); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] public void WriteInformation_LogsCorrectColors() { // Arrange @@ -316,7 +316,7 @@ public void WriteDebug_LogsCorrectColors() Assert.Equal(TestConsole.DefaultForegroundColor, write.ForegroundColor); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] public void WriteTrace_LogsCorrectColors() { // Arrange @@ -337,7 +337,7 @@ public void WriteTrace_LogsCorrectColors() Assert.Equal(TestConsole.DefaultForegroundColor, write.ForegroundColor); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] public void WriteAllLevelsDisabledColors_LogsNoColors() { // Arrange @@ -361,7 +361,7 @@ public void WriteAllLevelsDisabledColors_LogsNoColors() } } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] [MemberData(nameof(FormatsAndLevels))] public void WriteCore_LogsCorrectTimestamp(ConsoleLoggerFormat format, LogLevel level) { @@ -443,7 +443,7 @@ public void WriteCore_LogsCorrectTimestampInUtc(ConsoleLoggerFormat format, LogL } } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] [MemberData(nameof(FormatsAndLevels))] public void WriteCore_LogsCorrectMessages(ConsoleLoggerFormat format, LogLevel level) { @@ -487,7 +487,7 @@ public void WriteCore_LogsCorrectMessages(ConsoleLoggerFormat format, LogLevel l } } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] public void NoLogScope_DoesNotWriteAnyScopeContentToOutput() { // Arrange @@ -534,7 +534,7 @@ public void WritingScopes_LogsWithCorrectColors() Assert.Equal(TestConsole.DefaultForegroundColor, write.ForegroundColor); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] [MemberData(nameof(Formats))] public void WritingScopes_LogsExpectedMessage(ConsoleLoggerFormat format) { @@ -585,7 +585,7 @@ public void WritingScopes_LogsExpectedMessage(ConsoleLoggerFormat format) } } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] [MemberData(nameof(Formats))] public void WritingNestedScope_LogsNullScopeName(ConsoleLoggerFormat format) { @@ -634,7 +634,7 @@ public void WritingNestedScope_LogsNullScopeName(ConsoleLoggerFormat format) } } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] [MemberData(nameof(Formats))] public void WritingNestedScopes_LogsExpectedMessage(ConsoleLoggerFormat format) { @@ -688,7 +688,7 @@ public void WritingNestedScopes_LogsExpectedMessage(ConsoleLoggerFormat format) } } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] [MemberData(nameof(Formats))] public void WritingMultipleScopes_LogsExpectedMessage(ConsoleLoggerFormat format) { @@ -757,7 +757,7 @@ public void WritingMultipleScopes_LogsExpectedMessage(ConsoleLoggerFormat format } } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] public void CallingBeginScopeOnLogger_AlwaysReturnsNewDisposableInstance() { // Arrange @@ -775,7 +775,7 @@ public void CallingBeginScopeOnLogger_AlwaysReturnsNewDisposableInstance() Assert.NotSame(disposable1, disposable2); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] public void CallingBeginScopeOnLogger_ReturnsNonNullableInstance() { // Arrange @@ -790,7 +790,7 @@ public void CallingBeginScopeOnLogger_ReturnsNonNullableInstance() Assert.NotNull(disposable); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] [MemberData(nameof(Formats))] public void ConsoleLoggerLogsToError_WhenOverErrorLevel(ConsoleLoggerFormat format) { @@ -840,7 +840,7 @@ public void ConsoleLoggerLogsToError_WhenOverErrorLevel(ConsoleLoggerFormat form } } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] [MemberData(nameof(FormatsAndLevels))] public void WriteCore_NullMessageWithException(ConsoleLoggerFormat format, LogLevel level) { @@ -884,7 +884,7 @@ public void WriteCore_NullMessageWithException(ConsoleLoggerFormat format, LogLe } } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] [MemberData(nameof(FormatsAndLevels))] public void WriteCore_EmptyMessageWithException(ConsoleLoggerFormat format, LogLevel level) { @@ -927,7 +927,7 @@ public void WriteCore_EmptyMessageWithException(ConsoleLoggerFormat format, LogL } } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] [MemberData(nameof(FormatsAndLevels))] public void WriteCore_MessageWithNullException(ConsoleLoggerFormat format, LogLevel level) { @@ -967,7 +967,7 @@ public void WriteCore_MessageWithNullException(ConsoleLoggerFormat format, LogLe } } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] [MemberData(nameof(Levels))] public void WriteCore_NullMessageWithNullException(LogLevel level) { @@ -985,7 +985,7 @@ public void WriteCore_NullMessageWithNullException(LogLevel level) Assert.Empty(sink.Writes); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] public void LogAfterDisposeWritesLog() { // Arrange @@ -1004,7 +1004,7 @@ public void LogAfterDisposeWritesLog() Assert.True(sink.Writes.Count == 2); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] public static void IsEnabledReturnsCorrectValue() { var logger = SetUp().Logger; @@ -1018,7 +1018,7 @@ public static void IsEnabledReturnsCorrectValue() Assert.True(logger.IsEnabled(LogLevel.Trace)); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] public void ConsoleLoggerOptions_DisableColors_IsAppliedToLoggers() { // Arrange @@ -1033,6 +1033,7 @@ public void ConsoleLoggerOptions_DisableColors_IsAppliedToLoggers() } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/38337", TestPlatforms.Browser)] public void ConsoleLoggerOptions_DisableColors_IsReadFromLoggingConfiguration() { var configuration = new ConfigurationBuilder().AddInMemoryCollection(new[] { new KeyValuePair("Console:DisableColors", "true") }).Build(); @@ -1049,7 +1050,7 @@ public void ConsoleLoggerOptions_DisableColors_IsReadFromLoggingConfiguration() Assert.True(logger.Options.DisableColors); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] public void ConsoleLoggerOptions_TimeStampFormat_IsReloaded() { // Arrange @@ -1064,6 +1065,7 @@ public void ConsoleLoggerOptions_TimeStampFormat_IsReloaded() } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/38337", TestPlatforms.Browser)] public void ConsoleLoggerOptions_TimeStampFormat_IsReadFromLoggingConfiguration() { var configuration = new ConfigurationBuilder().AddInMemoryCollection(new[] { new KeyValuePair("Console:TimeStampFormat", "yyyyMMddHHmmss") }).Build(); @@ -1080,7 +1082,7 @@ public void ConsoleLoggerOptions_TimeStampFormat_IsReadFromLoggingConfiguration( Assert.Equal("yyyyMMddHHmmss", logger.Options.TimestampFormat); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] public void ConsoleLoggerOptions_TimeStampFormat_MultipleReloads() { var monitor = new TestOptionsMonitor(new ConsoleLoggerOptions()); @@ -1094,7 +1096,7 @@ public void ConsoleLoggerOptions_TimeStampFormat_MultipleReloads() Assert.Equal("yyyyMMddHHmmss", logger.Options.TimestampFormat); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] public void ConsoleLoggerOptions_IncludeScopes_IsAppliedToLoggers() { // Arrange @@ -1109,6 +1111,7 @@ public void ConsoleLoggerOptions_IncludeScopes_IsAppliedToLoggers() } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/38337", TestPlatforms.Browser)] public void ConsoleLoggerOptions_LogAsErrorLevel_IsReadFromLoggingConfiguration() { var configuration = new ConfigurationBuilder().AddInMemoryCollection(new[] { new KeyValuePair("Console:LogToStandardErrorThreshold", "Warning") }).Build(); @@ -1125,7 +1128,7 @@ public void ConsoleLoggerOptions_LogAsErrorLevel_IsReadFromLoggingConfiguration( Assert.Equal(LogLevel.Warning, logger.Options.LogToStandardErrorThreshold); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] public void ConsoleLoggerOptions_LogAsErrorLevel_IsAppliedToLoggers() { // Arrange @@ -1139,7 +1142,7 @@ public void ConsoleLoggerOptions_LogAsErrorLevel_IsAppliedToLoggers() Assert.Equal(LogLevel.Error, logger.Options.LogToStandardErrorThreshold); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] public void ConsoleLoggerOptions_UseUtcTimestamp_IsAppliedToLoggers() { // Arrange @@ -1154,6 +1157,7 @@ public void ConsoleLoggerOptions_UseUtcTimestamp_IsAppliedToLoggers() } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/38337", TestPlatforms.Browser)] public void ConsoleLoggerOptions_IncludeScopes_IsReadFromLoggingConfiguration() { var configuration = new ConfigurationBuilder().AddInMemoryCollection(new[] { new KeyValuePair("Console:IncludeScopes", "true") }).Build(); diff --git a/src/libraries/Microsoft.Extensions.Logging/tests/Common/LoggerFactoryTest.cs b/src/libraries/Microsoft.Extensions.Logging/tests/Common/LoggerFactoryTest.cs index 21d0f04f4b2..9fced601e70 100644 --- a/src/libraries/Microsoft.Extensions.Logging/tests/Common/LoggerFactoryTest.cs +++ b/src/libraries/Microsoft.Extensions.Logging/tests/Common/LoggerFactoryTest.cs @@ -199,6 +199,7 @@ public void TestActivityIds(ActivityTrackingOptions options) } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/38337", TestPlatforms.Browser)] public void TestInvalidActivityTrackingOptions() { Assert.Throws(() =>