diff --git a/eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml b/eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml index 12981837609c36..6e9adb3aac7c5a 100644 --- a/eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml +++ b/eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml @@ -130,8 +130,6 @@ jobs: # Always run for runtime-wasm because tests are not run in runtime alwaysRun: ${{ parameters.isWasmOnlyBuild }} - # NOTE - Since threading is experimental, we don't want to block mainline work - shouldContinueOnError: true scenarios: - WasmTestOnBrowser #- WasmTestOnNodeJS - this is not supported yet, https://github.com/dotnet/runtime/issues/85592 diff --git a/src/libraries/Common/tests/WasmTestRunner/WasmTestRunner.cs b/src/libraries/Common/tests/WasmTestRunner/WasmTestRunner.cs index 9fb129d825d742..f89d3a3adf55a3 100644 --- a/src/libraries/Common/tests/WasmTestRunner/WasmTestRunner.cs +++ b/src/libraries/Common/tests/WasmTestRunner/WasmTestRunner.cs @@ -24,6 +24,7 @@ public static async Task Main(string[] args) var includedClasses = new List(); var includedMethods = new List(); var backgroundExec = false; + var untilFailed = false; for (int i = 1; i < args.Length; i++) { @@ -53,6 +54,9 @@ public static async Task Main(string[] args) case "-backgroundExec": backgroundExec = true; break; + case "-untilFailed": + untilFailed = true; + break; default: throw new ArgumentException($"Invalid argument '{option}'."); } @@ -72,10 +76,21 @@ public static async Task Main(string[] args) { await Task.Yield(); } - if (backgroundExec) + + var res = 0; + do { - return await Task.Run(() => runner.Run()); + if (backgroundExec) + { + res = await Task.Run(() => runner.Run()); + } + else + { + res = await runner.Run(); + } } - return await runner.Run(); + while(res == 0 && untilFailed); + + return res; } } diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleFormatterTests.cs b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleFormatterTests.cs index 573006673d8889..10b2c6432d6c75 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleFormatterTests.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleFormatterTests.cs @@ -27,7 +27,43 @@ protected string GetMessage(List contexts) return string.Join("", contexts.Select(c => c.Message)); } - internal static (ConsoleLogger Logger, ConsoleSink Sink, ConsoleSink ErrorSink, Func GetLevelPrefix, int WritesPerMsg) SetUp( + internal class SetupDisposeHelper : IDisposable + { + public ConsoleLogger Logger; + public ConsoleSink Sink; + public ConsoleSink ErrorSink; + public Func GetLevelPrefix; + public int WritesPerMsg; + public TestLoggerProcessor LoggerProcessor; + public SetupDisposeHelper(ConsoleLogger logger, ConsoleSink sink, ConsoleSink errorSink, Func getLevelPrefix, int writesPerMsg, TestLoggerProcessor loggerProcessor) + { + Logger = logger; + Sink = sink; + ErrorSink = errorSink; + GetLevelPrefix = getLevelPrefix; + WritesPerMsg = writesPerMsg; + LoggerProcessor = loggerProcessor; + } + + private bool _isDisposed; + + protected virtual void Dispose(bool disposing) + { + if (!_isDisposed) + { + LoggerProcessor.Dispose(); + _isDisposed = true; + } + } + + public void Dispose() + { + Dispose(disposing: true); + GC.SuppressFinalize(this); + } + } + + internal static SetupDisposeHelper SetUp( ConsoleLoggerOptions options = null, SimpleConsoleFormatterOptions simpleOptions = null, ConsoleFormatterOptions systemdOptions = null, @@ -70,16 +106,15 @@ internal static (ConsoleLogger Logger, ConsoleSink Sink, ConsoleSink ErrorSink, } var logger = new ConsoleLogger(_loggerName, consoleLoggerProcessor, formatter, new LoggerExternalScopeProvider(), loggerOptions); - return (logger, sink, errorSink, levelAsString, writesPerMsg); + return new SetupDisposeHelper(logger, sink, errorSink, levelAsString, writesPerMsg, consoleLoggerProcessor); } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void ConsoleLoggerOptions_TimeStampFormat_IsReloaded() { // Arrange var monitor = new TestOptionsMonitor(new ConsoleLoggerOptions() { FormatterName = "NonExistentFormatter" }); - var loggerProvider = new ConsoleLoggerProvider(monitor, ConsoleLoggerTest.GetFormatters()); + using var loggerProvider = new ConsoleLoggerProvider(monitor, ConsoleLoggerTest.GetFormatters()); var logger = (ConsoleLogger)loggerProvider.CreateLogger("Name"); // Act & Assert @@ -88,12 +123,11 @@ public void ConsoleLoggerOptions_TimeStampFormat_IsReloaded() } [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] [MemberData(nameof(FormatterNames))] public void InvalidLogLevel_Throws(string formatterName) { // Arrange - var t = SetUp( + using var t = SetUp( new ConsoleLoggerOptions { FormatterName = formatterName } ); var logger = (ILogger)t.Logger; @@ -103,12 +137,11 @@ public void InvalidLogLevel_Throws(string formatterName) } [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] [MemberData(nameof(FormatterNamesAndLevels))] public void NoMessageOrException_Noop(string formatterName, LogLevel level) { // Arrange - var t = SetUp(new ConsoleLoggerOptions { FormatterName = formatterName }); + using var t = SetUp(new ConsoleLoggerOptions { FormatterName = formatterName }); var levelPrefix = t.GetLevelPrefix(level); var logger = t.Logger; var sink = t.Sink; @@ -123,12 +156,11 @@ public void NoMessageOrException_Noop(string formatterName, LogLevel level) } [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] [MemberData(nameof(FormatterNamesAndLevels))] public void Log_LogsCorrectTimestamp(string formatterName, LogLevel level) { // Arrange - var t = SetUp( + using var t = SetUp( new ConsoleLoggerOptions { FormatterName = formatterName }, new SimpleConsoleFormatterOptions { TimestampFormat = "yyyy-MM-ddTHH:mm:sszz ", UseUtcTimestamp = false, ColorBehavior = LoggerColorBehavior.Enabled }, new ConsoleFormatterOptions { TimestampFormat = "yyyy-MM-ddTHH:mm:sszz ", UseUtcTimestamp = false }, diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleLoggerProcessorTests.cs b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleLoggerProcessorTests.cs index dfc7eaae8fe24c..1ded891d402c04 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleLoggerProcessorTests.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleLoggerProcessorTests.cs @@ -20,7 +20,7 @@ public void LogAfterDisposeWritesLog() // Arrange var sink = new ConsoleSink(); var console = new TestConsole(sink); - var processor = new ConsoleLoggerProcessor(console, null!, ConsoleLoggerQueueFullMode.Wait, 1024); + using var processor = new ConsoleLoggerProcessor(console, null!, ConsoleLoggerQueueFullMode.Wait, 1024); var logger = new ConsoleLogger(_loggerName, loggerProcessor: processor, new SimpleConsoleFormatter(new TestFormatterOptionsMonitor(new SimpleConsoleFormatterOptions())), @@ -42,7 +42,7 @@ public void LogsFlushedAfterDispose() // Arrange var sink = new ConsoleSink(); var console = new TestConsole(sink); - var processor = new ConsoleLoggerProcessor(console, null!, ConsoleLoggerQueueFullMode.Wait, 1024); + using var processor = new ConsoleLoggerProcessor(console, null!, ConsoleLoggerQueueFullMode.Wait, 1024); var logger = new ConsoleLogger(_loggerName, loggerProcessor: processor, new SimpleConsoleFormatter(new TestFormatterOptionsMonitor(new SimpleConsoleFormatterOptions())), @@ -70,7 +70,7 @@ public static void MaxQueueLength_SetInvalid_Throws(int invalidMaxQueueLength) // Arrange var sink = new ConsoleSink(); var console = new TestConsole(sink); - var processor = new ConsoleLoggerProcessor(console, null!, ConsoleLoggerQueueFullMode.Wait, 1024); + using var processor = new ConsoleLoggerProcessor(console, null!, ConsoleLoggerQueueFullMode.Wait, 1024); // Act & Assert Assert.Throws(() => processor.MaxQueueLength = invalidMaxQueueLength); @@ -82,7 +82,7 @@ public static void FullMode_SetInvalid_Throws() // Arrange var sink = new ConsoleSink(); var console = new TestConsole(sink); - var processor = new ConsoleLoggerProcessor(console, null!, ConsoleLoggerQueueFullMode.Wait, 1024); + using var processor = new ConsoleLoggerProcessor(console, null!, ConsoleLoggerQueueFullMode.Wait, 1024); // Act & Assert Assert.Throws(() => processor.FullMode = (ConsoleLoggerQueueFullMode)10); @@ -100,7 +100,7 @@ public void CheckForNotificationWhenQueueIsFull(bool okToDrop) var errorConsole = new TimesWriteCalledConsole(); string queueName = nameof(CheckForNotificationWhenQueueIsFull) + (okToDrop ? "InDropWriteMode" : "InWaitMode"); var fullMode = okToDrop ? ConsoleLoggerQueueFullMode.DropWrite : ConsoleLoggerQueueFullMode.Wait; - var processor = new ConsoleLoggerProcessor(console, errorConsole, fullMode, maxQueueLength: 1); + using var processor = new ConsoleLoggerProcessor(console, errorConsole, fullMode, maxQueueLength: 1); var formatter = new SimpleConsoleFormatter(new TestFormatterOptionsMonitor( new SimpleConsoleFormatterOptions())); @@ -150,7 +150,7 @@ public void ThrowDuringProcessLog_ShutsDownGracefully() { var console = new TimesWriteCalledConsole(); var writeThrowingConsole = new WriteThrowingConsole(); - var processor = new ConsoleLoggerProcessor( + using var processor = new ConsoleLoggerProcessor( console, writeThrowingConsole, ConsoleLoggerQueueFullMode.Wait, diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleLoggerTest.cs b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleLoggerTest.cs index f0ef3d6cd7e1d1..c960c1dbb90baf 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleLoggerTest.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/ConsoleLoggerTest.cs @@ -40,7 +40,43 @@ internal static IEnumerable GetFormatters( return formatters; } - private static (ConsoleLogger Logger, ConsoleSink Sink, ConsoleSink ErrorSink, Func GetLevelPrefix, int WritesPerMsg) SetUp(ConsoleLoggerOptions options = null) + internal class SetupDisposeHelper : IDisposable + { + public ConsoleLogger Logger; + public ConsoleSink Sink; + public ConsoleSink ErrorSink; + public Func GetLevelPrefix; + public int WritesPerMsg; + public TestLoggerProcessor LoggerProcessor; + public SetupDisposeHelper(ConsoleLogger logger, ConsoleSink sink, ConsoleSink errorSink, Func getLevelPrefix, int writesPerMsg, TestLoggerProcessor loggerProcessor) + { + Logger= logger; + Sink= sink; + ErrorSink= errorSink; + GetLevelPrefix = getLevelPrefix; + WritesPerMsg = writesPerMsg; + LoggerProcessor = loggerProcessor; + } + + private bool _isDisposed; + + protected virtual void Dispose(bool disposing) + { + if (!_isDisposed) + { + LoggerProcessor.Dispose(); + _isDisposed = true; + } + } + + public void Dispose() + { + Dispose(disposing: true); + GC.SuppressFinalize(this); + } + } + + private static SetupDisposeHelper SetUp(ConsoleLoggerOptions options = null) { // Arrange var sink = new ConsoleSink(); @@ -74,7 +110,7 @@ private static (ConsoleLogger Logger, ConsoleSink Sink, ConsoleSink ErrorSink, F UpdateFormatterOptions(logger.Formatter, logger.Options); VerifyDeprecatedPropertiesUsedOnNullFormatterName(logger); - return (logger, sink, errorSink, levelAsString, writesPerMsg); + return new SetupDisposeHelper(logger, sink, errorSink, levelAsString, writesPerMsg, consoleLoggerProcessor); } private static void VerifyDeprecatedPropertiesUsedOnNullFormatterName(ConsoleLogger logger) @@ -174,11 +210,10 @@ internal static string GetJsonLogLevelString(LogLevel logLevel) } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void LogsWhenMessageIsNotProvided() { // Arrange - var t = SetUp(); + using var t = SetUp(); var logger = (ILogger)t.Logger; var sink = t.Sink; var exception = new InvalidOperationException("Invalid value"); @@ -207,11 +242,10 @@ public void LogsWhenMessageIsNotProvided() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void DoesNotLog_NewLine_WhenNoExceptionIsProvided() { // Arrange - var t = SetUp(); + using var t = SetUp(); var logger = (ILogger)t.Logger; var sink = t.Sink; var logMessage = "Route with name 'Simple' was not found."; @@ -236,7 +270,6 @@ public void DoesNotLog_NewLine_WhenNoExceptionIsProvided() } [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] [InlineData(null, 0)] [InlineData(null, 1)] [InlineData("missingFormatter", 0)] @@ -247,7 +280,7 @@ public void Options_FormatterNameNull_UsesDeprecatedProperties(string formatterN ConsoleLoggerFormat format = (ConsoleLoggerFormat)formatNumber; var options = new ConsoleLoggerOptions() { FormatterName = formatterName }; var monitor = new TestOptionsMonitor(options); - var loggerProvider = new ConsoleLoggerProvider(monitor, GetFormatters()); + using var loggerProvider = new ConsoleLoggerProvider(monitor, GetFormatters()); var logger = (ConsoleLogger)loggerProvider.CreateLogger("Name"); // Act @@ -275,16 +308,14 @@ public void Options_FormatterNameNull_UsesDeprecatedProperties(string formatterN default: throw new ArgumentOutOfRangeException(nameof(format)); } - loggerProvider?.Dispose(); } [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] [InlineData("Route with name 'Simple' was not found.")] public void Writes_NewLine_WhenExceptionIsProvided(string message) { // Arrange - var t = SetUp(); + using var t = SetUp(); var logger = (ILogger)t.Logger; var sink = t.Sink; var eventId = 10; @@ -304,11 +335,10 @@ public void Writes_NewLine_WhenExceptionIsProvided(string message) } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void ThrowsException_WhenNoFormatterIsProvided() { // Arrange - var t = SetUp(); + using var t = SetUp(); var logger = (ILogger)t.Logger; // Act & Assert @@ -316,11 +346,10 @@ public void ThrowsException_WhenNoFormatterIsProvided() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void LogsWhenNullFilterGiven() { // Arrange - var t = SetUp(); + using var t = SetUp(); var logger = t.Logger; var sink = t.Sink; var expectedHeader = CreateHeader(ConsoleLoggerFormat.Default) + Environment.NewLine; @@ -338,11 +367,10 @@ public void LogsWhenNullFilterGiven() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void WriteCritical_LogsCorrectColors() { // Arrange - var t = SetUp(); + using var t = SetUp(); var logger = t.Logger; var sink = t.Sink; @@ -360,11 +388,10 @@ public void WriteCritical_LogsCorrectColors() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void WriteError_LogsCorrectColors() { // Arrange - var t = SetUp(); + using var t = SetUp(); var logger = t.Logger; var sink = t.Sink; @@ -382,11 +409,10 @@ public void WriteError_LogsCorrectColors() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void WriteWarning_LogsCorrectColors() { // Arrange - var t = SetUp(); + using var t = SetUp(); var logger = t.Logger; var sink = t.Sink; @@ -404,11 +430,10 @@ public void WriteWarning_LogsCorrectColors() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void WriteInformation_LogsCorrectColors() { // Arrange - var t = SetUp(); + using var t = SetUp(); var logger = t.Logger; var sink = t.Sink; @@ -456,11 +481,10 @@ public void AddConsole_IsOutputRedirected_ColorDisabled() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void WriteDebug_LogsCorrectColors() { // Arrange - var t = SetUp(); + using var t = SetUp(); var logger = t.Logger; var sink = t.Sink; @@ -478,11 +502,10 @@ public void WriteDebug_LogsCorrectColors() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void WriteTrace_LogsCorrectColors() { // Arrange - var t = SetUp(); + using var t = SetUp(); var logger = t.Logger; var sink = t.Sink; @@ -500,11 +523,10 @@ public void WriteTrace_LogsCorrectColors() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void WriteAllLevelsDisabledColors_LogsNoColors() { // Arrange - var t = SetUp(new ConsoleLoggerOptions { DisableColors = true }); + using var t = SetUp(new ConsoleLoggerOptions { DisableColors = true }); var logger = t.Logger; var sink = t.Sink; @@ -525,12 +547,11 @@ public void WriteAllLevelsDisabledColors_LogsNoColors() } [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] [MemberData(nameof(FormatsAndLevels))] public void Log_LogsCorrectTimestamp(ConsoleLoggerFormat format, LogLevel level) { // Arrange - var t = SetUp(new ConsoleLoggerOptions { TimestampFormat = "yyyy-MM-ddTHH:mm:sszz ", Format = format, UseUtcTimestamp = false }); + using var t = SetUp(new ConsoleLoggerOptions { TimestampFormat = "yyyy-MM-ddTHH:mm:sszz ", Format = format, UseUtcTimestamp = false }); var levelPrefix = t.GetLevelPrefix(level); var logger = t.Logger; var sink = t.Sink; @@ -567,12 +588,11 @@ public void Log_LogsCorrectTimestamp(ConsoleLoggerFormat format, LogLevel level) } [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] [MemberData(nameof(FormatsAndLevels))] public void WriteCore_LogsCorrectTimestampInUtc(ConsoleLoggerFormat format, LogLevel level) { // Arrange - var t = SetUp(new ConsoleLoggerOptions { TimestampFormat = "yyyy-MM-ddTHH:mm:sszz ", Format = format, UseUtcTimestamp = true }); + using var t = SetUp(new ConsoleLoggerOptions { TimestampFormat = "yyyy-MM-ddTHH:mm:sszz ", Format = format, UseUtcTimestamp = true }); var levelPrefix = t.GetLevelPrefix(level); var logger = t.Logger; var sink = t.Sink; @@ -609,12 +629,11 @@ public void WriteCore_LogsCorrectTimestampInUtc(ConsoleLoggerFormat format, LogL } [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] [MemberData(nameof(FormatsAndLevels))] public void WriteCore_LogsCorrectMessages(ConsoleLoggerFormat format, LogLevel level) { // Arrange - var t = SetUp(new ConsoleLoggerOptions { Format = format }); + using var t = SetUp(new ConsoleLoggerOptions { Format = format }); var levelPrefix = t.GetLevelPrefix(level); var logger = t.Logger; var sink = t.Sink; @@ -654,11 +673,10 @@ public void WriteCore_LogsCorrectMessages(ConsoleLoggerFormat format, LogLevel l } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void NoLogScope_DoesNotWriteAnyScopeContentToOutput() { // Arrange - var t = SetUp(new ConsoleLoggerOptions { IncludeScopes = true }); + using var t = SetUp(new ConsoleLoggerOptions { IncludeScopes = true }); var logger = t.Logger; var sink = t.Sink; @@ -676,11 +694,10 @@ public void NoLogScope_DoesNotWriteAnyScopeContentToOutput() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void WritingScopes_LogsWithCorrectColors() { // Arrange - var t = SetUp(new ConsoleLoggerOptions { IncludeScopes = true }); + using var t = SetUp(new ConsoleLoggerOptions { IncludeScopes = true }); var logger = t.Logger; var sink = t.Sink; var id = Guid.NewGuid(); @@ -703,12 +720,11 @@ public void WritingScopes_LogsWithCorrectColors() } [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] [MemberData(nameof(Formats))] public void WritingScopes_LogsExpectedMessage(ConsoleLoggerFormat format) { // Arrange - var t = SetUp(new ConsoleLoggerOptions { IncludeScopes = true, Format = format }); + using var t = SetUp(new ConsoleLoggerOptions { IncludeScopes = true, Format = format }); var logger = t.Logger; var sink = t.Sink; var level = LogLevel.Information; @@ -755,12 +771,11 @@ public void WritingScopes_LogsExpectedMessage(ConsoleLoggerFormat format) } [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] [MemberData(nameof(Formats))] public void WritingNestedScope_LogsNullScopeName(ConsoleLoggerFormat format) { // Arrange - var t = SetUp(new ConsoleLoggerOptions { IncludeScopes = true, Format = format }); + using var t = SetUp(new ConsoleLoggerOptions { IncludeScopes = true, Format = format }); var logger = t.Logger; var sink = t.Sink; var level = LogLevel.Information; @@ -805,12 +820,11 @@ public void WritingNestedScope_LogsNullScopeName(ConsoleLoggerFormat format) } [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] [MemberData(nameof(Formats))] public void WritingNestedScopes_LogsExpectedMessage(ConsoleLoggerFormat format) { // Arrange - var t = SetUp(new ConsoleLoggerOptions { IncludeScopes = true, Format = format }); + using var t = SetUp(new ConsoleLoggerOptions { IncludeScopes = true, Format = format }); var logger = t.Logger; var sink = t.Sink; var level = LogLevel.Information; @@ -864,12 +878,11 @@ public void WritingNestedScopes_LogsExpectedMessage(ConsoleLoggerFormat format) } [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] [MemberData(nameof(Formats))] public void WritingMultipleScopes_LogsExpectedMessage(ConsoleLoggerFormat format) { // Arrange - var t = SetUp(new ConsoleLoggerOptions { IncludeScopes = true, Format = format }); + using var t = SetUp(new ConsoleLoggerOptions { IncludeScopes = true, Format = format }); var logger = t.Logger; var sink = t.Sink; var level = LogLevel.Information; @@ -934,11 +947,10 @@ public void WritingMultipleScopes_LogsExpectedMessage(ConsoleLoggerFormat format } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void CallingBeginScopeOnLogger_AlwaysReturnsNewDisposableInstance() { // Arrange - var t = SetUp(new ConsoleLoggerOptions { IncludeScopes = true }); + using var t = SetUp(new ConsoleLoggerOptions { IncludeScopes = true }); var logger = t.Logger; var sink = t.Sink; @@ -953,11 +965,10 @@ public void CallingBeginScopeOnLogger_AlwaysReturnsNewDisposableInstance() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void CallingBeginScopeOnLogger_ReturnsNonNullableInstance() { // Arrange - var t = SetUp(); + using var t = SetUp(); var logger = t.Logger; var sink = t.Sink; @@ -969,12 +980,11 @@ public void CallingBeginScopeOnLogger_ReturnsNonNullableInstance() } [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] [MemberData(nameof(Formats))] public void ConsoleLoggerLogsToError_WhenOverErrorLevel(ConsoleLoggerFormat format) { // Arrange - var t = SetUp(new ConsoleLoggerOptions { LogToStandardErrorThreshold = LogLevel.Warning, Format = format }); + using var t = SetUp(new ConsoleLoggerOptions { LogToStandardErrorThreshold = LogLevel.Warning, Format = format }); var logger = t.Logger; var sink = t.Sink; var errorSink = t.ErrorSink; @@ -1020,12 +1030,11 @@ public void ConsoleLoggerLogsToError_WhenOverErrorLevel(ConsoleLoggerFormat form } [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] [MemberData(nameof(FormatsAndLevels))] public void WriteCore_NullMessageWithException(ConsoleLoggerFormat format, LogLevel level) { // Arrange - var t = SetUp(new ConsoleLoggerOptions { Format = format }); + using var t = SetUp(new ConsoleLoggerOptions { Format = format }); var levelPrefix = t.GetLevelPrefix(level); var logger = t.Logger; var sink = t.Sink; @@ -1065,12 +1074,11 @@ public void WriteCore_NullMessageWithException(ConsoleLoggerFormat format, LogLe } [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] [MemberData(nameof(FormatsAndLevels))] public void WriteCore_EmptyMessageWithException(ConsoleLoggerFormat format, LogLevel level) { // Arrange - var t = SetUp(new ConsoleLoggerOptions { Format = format }); + using var t = SetUp(new ConsoleLoggerOptions { Format = format }); var levelPrefix = t.GetLevelPrefix(level); var logger = t.Logger; var sink = t.Sink; @@ -1109,12 +1117,11 @@ public void WriteCore_EmptyMessageWithException(ConsoleLoggerFormat format, LogL } [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] [MemberData(nameof(FormatsAndLevels))] public void WriteCore_MessageWithNullException(ConsoleLoggerFormat format, LogLevel level) { // Arrange - var t = SetUp(new ConsoleLoggerOptions { Format = format }); + using var t = SetUp(new ConsoleLoggerOptions { Format = format }); var levelPrefix = t.GetLevelPrefix(level); var logger = t.Logger; var sink = t.Sink; @@ -1150,12 +1157,11 @@ public void WriteCore_MessageWithNullException(ConsoleLoggerFormat format, LogLe } [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] [MemberData(nameof(Levels))] public void WriteCore_NullMessageWithNullException(LogLevel level) { // Arrange - var t = SetUp(); + using var t = SetUp(); var logger = t.Logger; var sink = t.Sink; Exception ex = null; @@ -1169,7 +1175,6 @@ public void WriteCore_NullMessageWithNullException(LogLevel level) } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public static void IsEnabledReturnsCorrectValue() { var logger = SetUp().Logger; @@ -1184,12 +1189,11 @@ public static void IsEnabledReturnsCorrectValue() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void ConsoleLoggerOptions_DisableColors_IsAppliedToLoggers() { // Arrange var monitor = new TestOptionsMonitor(new ConsoleLoggerOptions() { DisableColors = true }); - var loggerProvider = new ConsoleLoggerProvider(monitor); + using var loggerProvider = new ConsoleLoggerProvider(monitor); var logger = (ConsoleLogger)loggerProvider.CreateLogger("Name"); // Act & Assert @@ -1219,7 +1223,6 @@ public void ConsoleLoggerOptions_SetInvalidBufferMode_Throws() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void ConsoleLoggerOptions_DisableColors_IsReadFromLoggingConfiguration() { var configuration = new ConfigurationBuilder().AddInMemoryCollection(new[] { new KeyValuePair("Console:DisableColors", "true") }).Build(); @@ -1237,12 +1240,11 @@ public void ConsoleLoggerOptions_DisableColors_IsReadFromLoggingConfiguration() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void ConsoleLoggerOptions_TimeStampFormat_IsReloaded() { // Arrange var monitor = new TestOptionsMonitor(new ConsoleLoggerOptions()); - var loggerProvider = new ConsoleLoggerProvider(monitor); + using var loggerProvider = new ConsoleLoggerProvider(monitor); var logger = (ConsoleLogger)loggerProvider.CreateLogger("Name"); // Act & Assert @@ -1252,7 +1254,6 @@ public void ConsoleLoggerOptions_TimeStampFormat_IsReloaded() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void ConsoleLoggerOptions_TimeStampFormat_IsReadFromLoggingConfiguration() { var configuration = new ConfigurationBuilder().AddInMemoryCollection(new[] { new KeyValuePair("Console:TimeStampFormat", "yyyyMMddHHmmss") }).Build(); @@ -1270,11 +1271,10 @@ public void ConsoleLoggerOptions_TimeStampFormat_IsReadFromLoggingConfiguration( } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void ConsoleLoggerOptions_TimeStampFormat_MultipleReloads() { var monitor = new TestOptionsMonitor(new ConsoleLoggerOptions()); - var loggerProvider = new ConsoleLoggerProvider(monitor); + using var loggerProvider = new ConsoleLoggerProvider(monitor); var logger = (ConsoleLogger)loggerProvider.CreateLogger("Name"); Assert.Null(logger.Options.TimestampFormat); @@ -1285,12 +1285,11 @@ public void ConsoleLoggerOptions_TimeStampFormat_MultipleReloads() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void ConsoleLoggerOptions_IncludeScopes_IsAppliedToLoggers() { // Arrange var monitor = new TestOptionsMonitor(new ConsoleLoggerOptions() { IncludeScopes = true }); - var loggerProvider = new ConsoleLoggerProvider(monitor); + using var loggerProvider = new ConsoleLoggerProvider(monitor); var logger = (ConsoleLogger)loggerProvider.CreateLogger("Name"); // Act & Assert @@ -1300,7 +1299,6 @@ public void ConsoleLoggerOptions_IncludeScopes_IsAppliedToLoggers() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void ConsoleLoggerOptions_LogAsErrorLevel_IsReadFromLoggingConfiguration() { var configuration = new ConfigurationBuilder().AddInMemoryCollection(new[] { new KeyValuePair("Console:LogToStandardErrorThreshold", "Warning") }).Build(); @@ -1318,12 +1316,11 @@ public void ConsoleLoggerOptions_LogAsErrorLevel_IsReadFromLoggingConfiguration( } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void ConsoleLoggerOptions_LogAsErrorLevel_IsAppliedToLoggers() { // Arrange var monitor = new TestOptionsMonitor(new ConsoleLoggerOptions()); - var loggerProvider = new ConsoleLoggerProvider(monitor); + using var loggerProvider = new ConsoleLoggerProvider(monitor); var logger = (ConsoleLogger)loggerProvider.CreateLogger("Name"); // Act & Assert @@ -1333,12 +1330,11 @@ public void ConsoleLoggerOptions_LogAsErrorLevel_IsAppliedToLoggers() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void ConsoleLoggerOptions_UpdateQueueOptions_UpdatesConsoleLoggerProcessorProperties() { // Arrange var monitor = new TestOptionsMonitor(new ConsoleLoggerOptions()); - var loggerProvider = new ConsoleLoggerProvider(monitor); + using var loggerProvider = new ConsoleLoggerProvider(monitor); var logger = (ConsoleLogger)loggerProvider.CreateLogger("Name"); // Act & Assert @@ -1353,12 +1349,11 @@ public void ConsoleLoggerOptions_UpdateQueueOptions_UpdatesConsoleLoggerProcesso } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void ConsoleLoggerOptions_UseUtcTimestamp_IsAppliedToLoggers() { // Arrange var monitor = new TestOptionsMonitor(new ConsoleLoggerOptions()); - var loggerProvider = new ConsoleLoggerProvider(monitor); + using var loggerProvider = new ConsoleLoggerProvider(monitor); var logger = (ConsoleLogger)loggerProvider.CreateLogger("Name"); // Act & Assert @@ -1368,7 +1363,6 @@ public void ConsoleLoggerOptions_UseUtcTimestamp_IsAppliedToLoggers() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] 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.Console/tests/Microsoft.Extensions.Logging.Console.Tests/JsonConsoleFormatterTests.cs b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/JsonConsoleFormatterTests.cs index 0ef491abbc1723..de4703bf0ffcd2 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/JsonConsoleFormatterTests.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/JsonConsoleFormatterTests.cs @@ -55,7 +55,7 @@ public void NoLogScope_DoesNotWriteAnyScopeContentToOutput_Json() public void Log_TimestampFormatSet_ContainsTimestamp() { // Arrange - var t = SetUp( + using var t = SetUp( new ConsoleLoggerOptions { FormatterName = ConsoleFormatterNames.Json }, simpleOptions: null, systemdOptions: null, @@ -82,7 +82,7 @@ public void Log_TimestampFormatSet_ContainsTimestamp() public void Log_NullMessage_LogsWhenMessageIsNotProvided() { // Arrange - var t = SetUp( + using var t = SetUp( new ConsoleLoggerOptions { FormatterName = ConsoleFormatterNames.Json }, simpleOptions: null, systemdOptions: null, @@ -126,7 +126,7 @@ public void Log_NullMessage_LogsWhenMessageIsNotProvided() public void Log_ExceptionWithMessage_ExtractsInfo() { // Arrange - var t = SetUp( + using var t = SetUp( new ConsoleLoggerOptions { FormatterName = ConsoleFormatterNames.Json }, simpleOptions: null, systemdOptions: null, @@ -180,7 +180,7 @@ public void Log_ExceptionWithMessage_ExtractsInfo() public void Log_IncludeScopes_ContainsDuplicateNamedPropertiesInScope_AcceptableJson() { // Arrange - var t = SetUp( + using var t = SetUp( new ConsoleLoggerOptions { FormatterName = ConsoleFormatterNames.Json }, simpleOptions: null, systemdOptions: null, @@ -213,7 +213,7 @@ public void Log_IncludeScopes_ContainsDuplicateNamedPropertiesInScope_Acceptable public void Log_StateAndScopeAreCollections_IncludesMessageAndCollectionValues() { // Arrange - var t = SetUp( + using var t = SetUp( new ConsoleLoggerOptions { FormatterName = ConsoleFormatterNames.Json }, simpleOptions: null, systemdOptions: null, @@ -249,7 +249,7 @@ public void Log_StateAndScopeAreCollections_IncludesMessageAndCollectionValues() public void Log_StateAndScopeContainsSpecialCaseValue_SerializesValueAsExpected(object value, string expectedJsonValue) { // Arrange - var t = SetUp( + using var t = SetUp( new ConsoleLoggerOptions { FormatterName = ConsoleFormatterNames.Json }, simpleOptions: null, systemdOptions: null, @@ -279,7 +279,7 @@ public void Log_StateAndScopeContainsSpecialCaseValue_SerializesValueAsExpected( public void Log_StateAndScopeContainsFloatingPointType_SerializesValue(object value) { // Arrange - var t = SetUp( + using var t = SetUp( new ConsoleLoggerOptions { FormatterName = ConsoleFormatterNames.Json }, simpleOptions: null, systemdOptions: null, @@ -317,7 +317,7 @@ static void AssertMessageValue(string message, string propertyName) public void Log_StateAndScopeContainsNullValue_SerializesNull() { // Arrange - var t = SetUp( + using var t = SetUp( new ConsoleLoggerOptions { FormatterName = ConsoleFormatterNames.Json }, simpleOptions: null, systemdOptions: null, @@ -346,7 +346,7 @@ public void Log_StateAndScopeContainsNullValue_SerializesNull() public void Log_ScopeIsIEnumerable_SerializesKeyValuePair() { // Arrange - var t = SetUp( + using var t = SetUp( new ConsoleLoggerOptions { FormatterName = ConsoleFormatterNames.Json }, simpleOptions: null, systemdOptions: null, diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/Microsoft.Extensions.Logging.Console.Tests.csproj b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/Microsoft.Extensions.Logging.Console.Tests.csproj index c38ae483cf00de..28964799cece21 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/Microsoft.Extensions.Logging.Console.Tests.csproj +++ b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/Microsoft.Extensions.Logging.Console.Tests.csproj @@ -6,6 +6,10 @@ true true + + + $(WasmXHarnessMonoArgs) --setenv=XHARNESS_LOG_TEST_START=true + diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/SimpleConsoleFormatterTests.cs b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/SimpleConsoleFormatterTests.cs index 26bd40775bb371..5e5c03839f0bc6 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/SimpleConsoleFormatterTests.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Console/tests/Microsoft.Extensions.Logging.Console.Tests/SimpleConsoleFormatterTests.cs @@ -10,14 +10,14 @@ namespace Microsoft.Extensions.Logging.Console.Test public class SimpleConsoleFormatterTests : ConsoleFormatterTests { [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] [InlineData(LoggerColorBehavior.Default)] [InlineData(LoggerColorBehavior.Enabled)] [InlineData(LoggerColorBehavior.Disabled)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/97382", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void Log_WritingScopes_LogsWithCorrectColorsWhenColorEnabled(LoggerColorBehavior colorBehavior) { // Arrange - var t = SetUp( + using var t = SetUp( new ConsoleLoggerOptions { FormatterName = ConsoleFormatterNames.Simple }, new SimpleConsoleFormatterOptions { IncludeScopes = true, ColorBehavior = colorBehavior } ); @@ -55,11 +55,10 @@ public void Log_WritingScopes_LogsWithCorrectColorsWhenColorEnabled(LoggerColorB } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void Log_NoLogScope_DoesNotWriteAnyScopeContentToOutput() { // Arrange - var t = SetUp( + using var t = SetUp( new ConsoleLoggerOptions { FormatterName = ConsoleFormatterNames.Simple }, new SimpleConsoleFormatterOptions { IncludeScopes = true, ColorBehavior = LoggerColorBehavior.Enabled } ); @@ -83,7 +82,7 @@ public void Log_NoLogScope_DoesNotWriteAnyScopeContentToOutput() public void Log_SingleLine_LogsWhenMessageIsNotProvided() { // Arrange - var t = SetUp( + using var t = SetUp( new ConsoleLoggerOptions { FormatterName = ConsoleFormatterNames.Simple }, new SimpleConsoleFormatterOptions { SingleLine = true, ColorBehavior = LoggerColorBehavior.Enabled } ); @@ -111,11 +110,10 @@ public void Log_SingleLine_LogsWhenMessageIsNotProvided() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void Log_SingleLine_LogsWhenBothMessageAndExceptionProvided() { // Arrange - var t = SetUp( + using var t = SetUp( new ConsoleLoggerOptions { FormatterName = ConsoleFormatterNames.Simple }, new SimpleConsoleFormatterOptions { SingleLine = true, ColorBehavior = LoggerColorBehavior.Enabled } ); diff --git a/src/libraries/System.Collections.Concurrent/tests/ProducerConsumerCollectionTests.cs b/src/libraries/System.Collections.Concurrent/tests/ProducerConsumerCollectionTests.cs index f7a9c219aceb56..7aae42fcae3eca 100644 --- a/src/libraries/System.Collections.Concurrent/tests/ProducerConsumerCollectionTests.cs +++ b/src/libraries/System.Collections.Concurrent/tests/ProducerConsumerCollectionTests.cs @@ -483,7 +483,6 @@ public void ICollectionCopyTo_InvalidArgs_Throws() [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] [InlineData(100, 1, 10)] [InlineData(4, 100000, 10)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void BlockingCollection_WrappingCollection_ExpectedElementsTransferred(int numThreadsPerConsumerProducer, int numItemsPerThread, int producerSpin) { var bc = new BlockingCollection(CreateProducerConsumerCollection()); diff --git a/src/libraries/System.IO.Compression.ZipFile/tests/System.IO.Compression.ZipFile.Tests.csproj b/src/libraries/System.IO.Compression.ZipFile/tests/System.IO.Compression.ZipFile.Tests.csproj index e07ea71438a4fd..69e4dbd3294c69 100644 --- a/src/libraries/System.IO.Compression.ZipFile/tests/System.IO.Compression.ZipFile.Tests.csproj +++ b/src/libraries/System.IO.Compression.ZipFile/tests/System.IO.Compression.ZipFile.Tests.csproj @@ -3,6 +3,7 @@ true true $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser + $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) diff --git a/src/libraries/System.IO.Compression/tests/System.IO.Compression.Tests.csproj b/src/libraries/System.IO.Compression/tests/System.IO.Compression.Tests.csproj index 7715606fcfdd4d..aaf09ff3af9f04 100644 --- a/src/libraries/System.IO.Compression/tests/System.IO.Compression.Tests.csproj +++ b/src/libraries/System.IO.Compression/tests/System.IO.Compression.Tests.csproj @@ -3,6 +3,7 @@ $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser true true + $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) diff --git a/src/libraries/System.IO.FileSystem.DriveInfo/tests/System.IO.FileSystem.DriveInfo.Tests.csproj b/src/libraries/System.IO.FileSystem.DriveInfo/tests/System.IO.FileSystem.DriveInfo.Tests.csproj index cc4756c4483abe..b5fdcf1902884e 100644 --- a/src/libraries/System.IO.FileSystem.DriveInfo/tests/System.IO.FileSystem.DriveInfo.Tests.csproj +++ b/src/libraries/System.IO.FileSystem.DriveInfo/tests/System.IO.FileSystem.DriveInfo.Tests.csproj @@ -1,6 +1,7 @@ $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser + $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) diff --git a/src/libraries/System.IO.MemoryMappedFiles/tests/System.IO.MemoryMappedFiles.Tests.csproj b/src/libraries/System.IO.MemoryMappedFiles/tests/System.IO.MemoryMappedFiles.Tests.csproj index 15406d7bdf6227..7eda1233a40190 100644 --- a/src/libraries/System.IO.MemoryMappedFiles/tests/System.IO.MemoryMappedFiles.Tests.csproj +++ b/src/libraries/System.IO.MemoryMappedFiles/tests/System.IO.MemoryMappedFiles.Tests.csproj @@ -3,6 +3,7 @@ true true $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser + $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) diff --git a/src/libraries/System.IO.Pipelines/tests/PipeWriterTests.cs b/src/libraries/System.IO.Pipelines/tests/PipeWriterTests.cs index 2913efbe3cdf6c..85070e1534a8ee 100644 --- a/src/libraries/System.IO.Pipelines/tests/PipeWriterTests.cs +++ b/src/libraries/System.IO.Pipelines/tests/PipeWriterTests.cs @@ -294,7 +294,6 @@ public async Task WritesUsingGetMemoryWorks() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91547", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public async Task CompleteWithLargeWriteThrows() { var completeDelay = TimeSpan.FromMilliseconds(10); diff --git a/src/libraries/System.Linq.Parallel/tests/ExchangeTests.cs b/src/libraries/System.Linq.Parallel/tests/ExchangeTests.cs index 5c36f46c5d2073..6dcaffbf60a5a5 100644 --- a/src/libraries/System.Linq.Parallel/tests/ExchangeTests.cs +++ b/src/libraries/System.Linq.Parallel/tests/ExchangeTests.cs @@ -90,7 +90,6 @@ public static IEnumerable AllMergeOptions_Multiple() [ConditionalTheory] [MemberData(nameof(PartitioningData), new[] { 0, 1, 2, 16, 1024 })] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91541", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public static void Partitioning_Default(Labeled> labeled, int count, int partitions) { if (partitions > 1 && !PlatformDetection.IsThreadingSupported) diff --git a/src/libraries/System.Net.NameResolution/tests/PalTests/System.Net.NameResolution.Pal.Tests.csproj b/src/libraries/System.Net.NameResolution/tests/PalTests/System.Net.NameResolution.Pal.Tests.csproj index 6e08a5f973e096..1c9361f593a407 100644 --- a/src/libraries/System.Net.NameResolution/tests/PalTests/System.Net.NameResolution.Pal.Tests.csproj +++ b/src/libraries/System.Net.NameResolution/tests/PalTests/System.Net.NameResolution.Pal.Tests.csproj @@ -4,6 +4,7 @@ ../../src/Resources/Strings.resx $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser true + $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) diff --git a/src/libraries/System.Net.Primitives/tests/PalTests/System.Net.Primitives.Pal.Tests.csproj b/src/libraries/System.Net.Primitives/tests/PalTests/System.Net.Primitives.Pal.Tests.csproj index 90fbc1e3d31bab..71f45ac2e64fb9 100644 --- a/src/libraries/System.Net.Primitives/tests/PalTests/System.Net.Primitives.Pal.Tests.csproj +++ b/src/libraries/System.Net.Primitives/tests/PalTests/System.Net.Primitives.Pal.Tests.csproj @@ -3,6 +3,7 @@ true ../../src/Resources/Strings.resx $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser + $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) + $(WasmXHarnessMonoArgs) --setenv=XHARNESS_LOG_TEST_START=true + + 01:15:00 + + diff --git a/src/libraries/System.Numerics.Tensors/tests/System.Numerics.Tensors.Tests.csproj b/src/libraries/System.Numerics.Tensors/tests/System.Numerics.Tensors.Tests.csproj index 4a508197cae5e0..65975d9bc6c9f5 100644 --- a/src/libraries/System.Numerics.Tensors/tests/System.Numerics.Tensors.Tests.csproj +++ b/src/libraries/System.Numerics.Tensors/tests/System.Numerics.Tensors.Tests.csproj @@ -5,6 +5,13 @@ true + + + $(WasmXHarnessMonoArgs) --setenv=XHARNESS_LOG_TEST_START=true + + 01:15:00 + + false diff --git a/src/libraries/System.Private.Xml/tests/XmlReader/Tests/AsyncReaderLateInitTests.cs b/src/libraries/System.Private.Xml/tests/XmlReader/Tests/AsyncReaderLateInitTests.cs index 05fd83798861d7..85f2fd9fdf7f10 100644 --- a/src/libraries/System.Private.Xml/tests/XmlReader/Tests/AsyncReaderLateInitTests.cs +++ b/src/libraries/System.Private.Xml/tests/XmlReader/Tests/AsyncReaderLateInitTests.cs @@ -69,7 +69,6 @@ public static void ReadAfterInitializationWithTextReaderOnAsyncReaderDoesNotThro } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91541", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public static void ReadAsyncAfterInitializationWithUriThrows() { using (XmlReader reader = XmlReader.Create("http://test.test/test.html", new XmlReaderSettings() { Async = true })) @@ -79,7 +78,6 @@ public static void ReadAsyncAfterInitializationWithUriThrows() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91541", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public static void ReadAfterInitializationWithUriOnAsyncReaderTrows() { using (XmlReader reader = XmlReader.Create("http://test.test/test.html", new XmlReaderSettings() { Async = true })) @@ -89,7 +87,6 @@ public static void ReadAfterInitializationWithUriOnAsyncReaderTrows() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91541", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public static void InitializationWithUriOnNonAsyncReaderThrows() { Assert.Throws(() => XmlReader.Create("http://test.test/test.html", new XmlReaderSettings() { Async = false })); diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateMisc.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateMisc.cs index c594669aaaec60..1e9fb3a25599a9 100644 --- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateMisc.cs +++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateMisc.cs @@ -419,7 +419,6 @@ public TCValidateAfterAddInvalidSchema(ITestOutputHelper output) : base(output) [InlineData("SCHEMA", "schB1_a.xsd", 1, 3, 3)] [InlineData("SCHEMA", "schM2_a.xsd", 1, 3, 3)] [InlineData("SCHEMA", "schH2_a.xsd", 1, 3, 3)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/75132", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public void AddValid_Import_Include_Redefine(string testDir, string testFile, int expCount, int expCountGT, int expCountGE) { string xsd = Path.Combine(path, testDir, testFile); diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System.Runtime.InteropServices.JavaScript.Tests.csproj b/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System.Runtime.InteropServices.JavaScript.Tests.csproj index 90b2454d6e375f..3c805f267237b6 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System.Runtime.InteropServices.JavaScript.Tests.csproj +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System.Runtime.InteropServices.JavaScript.Tests.csproj @@ -18,7 +18,6 @@ false - $(WasmXHarnessMonoArgs) --setenv=XHARNESS_LOG_TEST_START=true diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/WebWorkerTest.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/WebWorkerTest.cs index c0c03addd6bb87..cf3d97207ba9e1 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/WebWorkerTest.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/WebWorkerTest.cs @@ -11,6 +11,7 @@ using System.Net.WebSockets; using System.Text; using System.Linq; +using System.Runtime.CompilerServices; namespace System.Runtime.InteropServices.JavaScript.Tests { @@ -48,12 +49,14 @@ public async Task InitializeAsync() #region Executors - private CancellationTokenSource CreateTestCaseTimeoutSource() + private CancellationTokenSource CreateTestCaseTimeoutSource([CallerMemberName] string memberName = "") { + var start = DateTime.Now; var cts = new CancellationTokenSource(TimeoutMilliseconds); cts.Token.Register(() => { - Console.WriteLine($"Unexpected test case timeout at {DateTime.Now.ToString("u")} ManagedThreadId:{Environment.CurrentManagedThreadId}"); + var end = DateTime.Now; + Console.WriteLine($"Unexpected test case {memberName} timeout after {end - start} ManagedThreadId:{Environment.CurrentManagedThreadId}"); }); return cts; } @@ -247,11 +250,11 @@ public async Task JSSynchronizationContext_Send_Post_To_Canceled() Assert.False(shouldNotHitPost); } +#if !DEBUG [Fact] + // this will say something like `JSSynchronizationContext is still installed on worker 0x4ff0030.` in the console during shutdown. public async Task JSWebWorker_Abandon_Running() { - var cts = new CancellationTokenSource(); - TaskCompletionSource never = new TaskCompletionSource(); TaskCompletionSource ready = new TaskCompletionSource(); @@ -261,7 +264,7 @@ public async Task JSWebWorker_Abandon_Running() { ready.SetResult(); return never.Task; - }, cts.Token); + }, CancellationToken.None); #pragma warning restore CS4014 await ready.Task; @@ -273,10 +276,9 @@ public async Task JSWebWorker_Abandon_Running() } [Fact] + // this will say something like `JSSynchronizationContext is still installed on worker 0x4ff0030.` in the console during shutdown. public async Task JSWebWorker_Abandon_Running_JS() { - var cts = new CancellationTokenSource(); - TaskCompletionSource ready = new TaskCompletionSource(); #pragma warning disable CS4014 @@ -287,7 +289,7 @@ public async Task JSWebWorker_Abandon_Running_JS() var never = WebWorkerTestHelper.JSDelay(int.MaxValue); ready.SetResult(); await never; - }, cts.Token); + }, CancellationToken.None); #pragma warning restore CS4014 await ready.Task; @@ -297,11 +299,13 @@ public async Task JSWebWorker_Abandon_Running_JS() // it should not prevent mono and the test suite from exiting } +#endif + [Theory, MemberData(nameof(GetTargetThreads))] public async Task Executor_Propagates(Executor executor) { - var cts = CreateTestCaseTimeoutSource(); + using var cts = CreateTestCaseTimeoutSource(); bool hit = false; var failedTask = executor.Execute(() => { @@ -321,7 +325,7 @@ public async Task Executor_Propagates(Executor executor) [Theory, MemberData(nameof(GetTargetThreads))] public async Task ManagedConsole(Executor executor) { - var cts = CreateTestCaseTimeoutSource(); + using var cts = CreateTestCaseTimeoutSource(); await executor.Execute(() => { Console.WriteLine("C# Hello from ManagedThreadId: " + Environment.CurrentManagedThreadId); @@ -332,7 +336,7 @@ await executor.Execute(() => [Theory, MemberData(nameof(GetTargetThreads))] public async Task JSConsole(Executor executor) { - var cts = CreateTestCaseTimeoutSource(); + using var cts = CreateTestCaseTimeoutSource(); await executor.Execute(() => { WebWorkerTestHelper.Log("JS Hello from ManagedThreadId: " + Environment.CurrentManagedThreadId + " NativeThreadId: " + WebWorkerTestHelper.NativeThreadId); @@ -343,7 +347,7 @@ await executor.Execute(() => [Theory, MemberData(nameof(GetTargetThreads))] public async Task NativeThreadId(Executor executor) { - var cts = CreateTestCaseTimeoutSource(); + using var cts = CreateTestCaseTimeoutSource(); await executor.Execute(async () => { await executor.StickyAwait(WebWorkerTestHelper.InitializeAsync(), cts.Token); @@ -367,7 +371,7 @@ await executor.Execute(async () => public async Task ThreadingTimer(Executor executor) { var hit = false; - var cts = CreateTestCaseTimeoutSource(); + using var cts = CreateTestCaseTimeoutSource(); await executor.Execute(async () => { TaskCompletionSource tcs = new TaskCompletionSource(); @@ -389,7 +393,7 @@ await executor.Execute(async () => [Theory, MemberData(nameof(GetTargetThreads))] public async Task JSDelay_ContinueWith(Executor executor) { - var cts = CreateTestCaseTimeoutSource(); + using var cts = CreateTestCaseTimeoutSource(); await executor.Execute(async () => { await executor.StickyAwait(WebWorkerTestHelper.CreateDelay(), cts.Token); @@ -405,7 +409,7 @@ await WebWorkerTestHelper.JSDelay(10).ContinueWith(_ => [Theory, MemberData(nameof(GetTargetThreads))] public async Task JSDelay_ConfigureAwait_True(Executor executor) { - var cts = CreateTestCaseTimeoutSource(); + using var cts = CreateTestCaseTimeoutSource(); await executor.Execute(async () => { await executor.StickyAwait(WebWorkerTestHelper.CreateDelay(), cts.Token); @@ -420,7 +424,7 @@ await executor.Execute(async () => public async Task ManagedDelay_ContinueWith(Executor executor) { var hit = false; - var cts = CreateTestCaseTimeoutSource(); + using var cts = CreateTestCaseTimeoutSource(); await executor.Execute(async () => { await Task.Delay(10, cts.Token).ContinueWith(_ => @@ -434,7 +438,7 @@ await Task.Delay(10, cts.Token).ContinueWith(_ => [Theory, MemberData(nameof(GetTargetThreads))] public async Task ManagedDelay_ConfigureAwait_True(Executor executor) { - var cts = CreateTestCaseTimeoutSource(); + using var cts = CreateTestCaseTimeoutSource(); await executor.Execute(async () => { await Task.Delay(10, cts.Token).ConfigureAwait(true); @@ -446,7 +450,7 @@ await executor.Execute(async () => [Theory, MemberData(nameof(GetTargetThreads))] public async Task ManagedYield(Executor executor) { - var cts = CreateTestCaseTimeoutSource(); + using var cts = CreateTestCaseTimeoutSource(); await executor.Execute(async () => { await Task.Yield(); @@ -463,23 +467,37 @@ private async Task ActionsInDifferentThreads(Executor executor1, Executor exe { TaskCompletionSource readyTCS = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); TaskCompletionSource doneTCS = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); - + var e1Done = false; + var e2Done = false; var e1 = executor1.Execute(async () => { - await e1Job(doneTCS.Task, readyTCS); - if (!readyTCS.Task.IsCompleted) + try { - readyTCS.SetResult(default); + await e1Job(doneTCS.Task, readyTCS); + if (!readyTCS.Task.IsCompleted) + { + readyTCS.SetResult(default); + } + await doneTCS.Task; + } + finally + { + e1Done = true; } - await doneTCS.Task; }, cts.Token); var r1 = await readyTCS.Task.ConfigureAwait(true); var e2 = executor2.Execute(async () => { - await e2Job(r1); - + try + { + await e2Job(r1); + } + finally + { + e2Done = true; + } }, cts.Token); try @@ -488,9 +506,18 @@ private async Task ActionsInDifferentThreads(Executor executor1, Executor exe doneTCS.SetResult(); await e1; } - catch (Exception) + catch (Exception ex) { - cts.Cancel(); + if (ex is OperationCanceledException oce && cts.Token.IsCancellationRequested) + { + throw; + } + Console.WriteLine("ActionsInDifferentThreads failed with: \n" + ex); + if (!e1Done || !e2Done) + { + Console.WriteLine("ActionsInDifferentThreads canceling!"); + cts.Cancel(); + } throw; } } @@ -498,7 +525,7 @@ private async Task ActionsInDifferentThreads(Executor executor1, Executor exe [Theory, MemberData(nameof(GetTargetThreads2x))] public async Task JSObject_CapturesAffinity(Executor executor1, Executor executor2) { - var cts = CreateTestCaseTimeoutSource(); + using var cts = CreateTestCaseTimeoutSource(); var e1Job = async (Task e2done, TaskCompletionSource e1State) => { @@ -533,7 +560,7 @@ public async Task JSObject_CapturesAffinity(Executor executor1, Executor executo [Theory, MemberData(nameof(GetTargetThreads))] public async Task WebSocketClient_ContentInSameThread(Executor executor) { - var cts = CreateTestCaseTimeoutSource(); + using var cts = CreateTestCaseTimeoutSource(); var uri = new Uri(WebWorkerTestHelper.LocalWsEcho + "?guid=" + Guid.NewGuid()); var message = "hello"; @@ -556,9 +583,9 @@ await executor.Execute(async () => [Theory, MemberData(nameof(GetTargetThreads2x))] - public Task WebSocketClient_ResponseCloseInDifferentThread(Executor executor1, Executor executor2) + public async Task WebSocketClient_ResponseCloseInDifferentThread(Executor executor1, Executor executor2) { - var cts = CreateTestCaseTimeoutSource(); + using var cts = CreateTestCaseTimeoutSource(); var uri = new Uri(WebWorkerTestHelper.LocalWsEcho + "?guid=" + Guid.NewGuid()); var message = "hello"; @@ -587,13 +614,13 @@ public Task WebSocketClient_ResponseCloseInDifferentThread(Executor executor1, E await client.CloseAsync(WebSocketCloseStatus.NormalClosure, "bye", CancellationToken.None); }; - return ActionsInDifferentThreads(executor1, executor2, e1Job, e2Job, cts); + await ActionsInDifferentThreads(executor1, executor2, e1Job, e2Job, cts); } [Theory, MemberData(nameof(GetTargetThreads2x))] - public Task WebSocketClient_CancelInDifferentThread(Executor executor1, Executor executor2) + public async Task WebSocketClient_CancelInDifferentThread(Executor executor1, Executor executor2) { - var cts = new CancellationTokenSource(); + using var cts = CreateTestCaseTimeoutSource(); var uri = new Uri(WebWorkerTestHelper.LocalWsEcho + "?guid=" + Guid.NewGuid()); var message = ".delay5sec"; // this will make the loopback server slower @@ -620,7 +647,7 @@ public Task WebSocketClient_CancelInDifferentThread(Executor executor1, Executor Assert.Equal(cts2.Token, ex.CancellationToken); }; - return ActionsInDifferentThreads(executor1, executor2, e1Job, e2Job, cts); + await ActionsInDifferentThreads(executor1, executor2, e1Job, e2Job, cts); } #endregion @@ -630,7 +657,7 @@ public Task WebSocketClient_CancelInDifferentThread(Executor executor1, Executor [Theory, MemberData(nameof(GetTargetThreads))] public async Task HttpClient_ContentInSameThread(Executor executor) { - var cts = CreateTestCaseTimeoutSource(); + using var cts = CreateTestCaseTimeoutSource(); var uri = WebWorkerTestHelper.GetOriginUrl() + "/_framework/blazor.boot.json"; await executor.Execute(async () => @@ -648,9 +675,9 @@ await executor.Execute(async () => private static string HelloJson = "{'hello':'world'}".Replace('\'', '"'); private static string EchoStart = "{\"Method\":\"POST\",\"Url\":\"/Echo.ashx"; - private Task HttpClient_ActionInDifferentThread(string url, Executor executor1, Executor executor2, Func e2Job) + private async Task HttpClient_ActionInDifferentThread(string url, Executor executor1, Executor executor2, Func e2Job) { - var cts = CreateTestCaseTimeoutSource(); + using var cts = CreateTestCaseTimeoutSource(); var e1Job = async (Task e2done, TaskCompletionSource e1State) => { @@ -669,7 +696,7 @@ private Task HttpClient_ActionInDifferentThread(string url, Executor executor1, await e2done; }; - return ActionsInDifferentThreads(executor1, executor2, e1Job, e2Job, cts); + await ActionsInDifferentThreads(executor1, executor2, e1Job, e2Job, cts); } [Theory, MemberData(nameof(GetTargetThreads2x))] diff --git a/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System.Runtime.InteropServices.Tests.csproj b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System.Runtime.InteropServices.Tests.csproj index 31369aaca2a4a3..9ffc16e149c68b 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System.Runtime.InteropServices.Tests.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System.Runtime.InteropServices.Tests.csproj @@ -4,6 +4,7 @@ $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser true true + $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) diff --git a/src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/System.IO.FileSystem.Tests.csproj b/src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/System.IO.FileSystem.Tests.csproj index 738960903f5045..4a17a866e5d7b3 100644 --- a/src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/System.IO.FileSystem.Tests.csproj +++ b/src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/System.IO.FileSystem.Tests.csproj @@ -3,6 +3,7 @@ true true $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser + $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) --working-dir=/test-dir diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System.Runtime.Extensions.Tests.csproj b/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System.Runtime.Extensions.Tests.csproj index bf090364567c53..76c35499c95c49 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System.Runtime.Extensions.Tests.csproj +++ b/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System.Runtime.Extensions.Tests.csproj @@ -13,6 +13,10 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) $(DefineConstants);Unix + + + $(WasmXHarnessMonoArgs) --setenv=XHARNESS_LOG_TEST_START=true + diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System.Runtime.Tests.csproj b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System.Runtime.Tests.csproj index 6514d08c8f284f..88b4507b2812e4 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System.Runtime.Tests.csproj +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System.Runtime.Tests.csproj @@ -16,6 +16,7 @@ true true + $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) + $(WasmXHarnessMonoArgs) --setenv=XHARNESS_LOG_TEST_START=true + diff --git a/src/libraries/System.Threading.Thread/ref/System.Threading.Thread.csproj b/src/libraries/System.Threading.Thread/ref/System.Threading.Thread.csproj index d5723a09d9b9f1..b99f5a149ac0a6 100644 --- a/src/libraries/System.Threading.Thread/ref/System.Threading.Thread.csproj +++ b/src/libraries/System.Threading.Thread/ref/System.Threading.Thread.csproj @@ -1,6 +1,7 @@ $(NetCoreAppCurrent) + $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) true $(DefineConstants);FEATURE_WASM_THREADS diff --git a/src/libraries/System.Threading/ref/System.Threading.csproj b/src/libraries/System.Threading/ref/System.Threading.csproj index 7a2cbac20a48ef..393390136ec882 100644 --- a/src/libraries/System.Threading/ref/System.Threading.csproj +++ b/src/libraries/System.Threading/ref/System.Threading.csproj @@ -1,6 +1,7 @@ $(NetCoreAppCurrent) + $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) true $(DefineConstants);FEATURE_WASM_THREADS diff --git a/src/libraries/System.Threading/tests/MonitorTests.cs b/src/libraries/System.Threading/tests/MonitorTests.cs index ca8ebe9544be1c..13cb675cef34ae 100644 --- a/src/libraries/System.Threading/tests/MonitorTests.cs +++ b/src/libraries/System.Threading/tests/MonitorTests.cs @@ -447,6 +447,7 @@ public static void WaitTest() Monitor.Pulse(obj); } Monitor.Exit(obj); + t.Join(500); } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] diff --git a/src/libraries/System.Threading/tests/MutexTests.cs b/src/libraries/System.Threading/tests/MutexTests.cs index ab2527db0f16df..6b06baeb760344 100644 --- a/src/libraries/System.Threading/tests/MutexTests.cs +++ b/src/libraries/System.Threading/tests/MutexTests.cs @@ -421,7 +421,6 @@ public static IEnumerable AbandonExisting_MemberData() } [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91547", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] [MemberData(nameof(AbandonExisting_MemberData))] public void AbandonExisting( string name, diff --git a/src/libraries/System.Threading/tests/ReaderWriterLockSlimTests.cs b/src/libraries/System.Threading/tests/ReaderWriterLockSlimTests.cs index d4569737e35078..bf4fdd72cc6fdd 100644 --- a/src/libraries/System.Threading/tests/ReaderWriterLockSlimTests.cs +++ b/src/libraries/System.Threading/tests/ReaderWriterLockSlimTests.cs @@ -446,6 +446,8 @@ public static void ReleaseReadersWhenWaitingWriterTimesOut() // Typical order of execution: 7 writeWaiterThread.Join(); + readerThreads[0].Join(); + readerThreads[1].Join(); } } diff --git a/src/libraries/System.Threading/tests/SemaphoreSlimTests.cs b/src/libraries/System.Threading/tests/SemaphoreSlimTests.cs index 4c2c5cc53a5249..7aabd01c39f1e2 100644 --- a/src/libraries/System.Threading/tests/SemaphoreSlimTests.cs +++ b/src/libraries/System.Threading/tests/SemaphoreSlimTests.cs @@ -72,7 +72,6 @@ public static void RunSemaphoreSlimTest1_Wait_NegativeCases() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91541", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public static void RunSemaphoreSlimTest1_WaitAsync() { // Infinite timeout @@ -91,7 +90,6 @@ public static void RunSemaphoreSlimTest1_WaitAsync() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91541", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] public static void RunSemaphoreSlimTest1_WaitAsync_NegativeCases() { // Invalid timeout @@ -464,7 +462,6 @@ private static void RunSemaphoreSlimTest7_AvailableWaitHandle_Helper(int initial /// The final semaphore count /// True if the test succeeded, false otherwise [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91538", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] [InlineData(5, 1000, 50, 50, 50, 0, 5, 1000)] [InlineData(0, 1000, 50, 25, 25, 25, 0, 500)] [InlineData(0, 1000, 50, 0, 0, 50, 0, 100)] @@ -531,7 +528,6 @@ public static void RunSemaphoreSlimTest8_ConcWaitAndRelease(int initial, int max /// The final semaphore count /// True if the test succeeded, false otherwise [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/91541", typeof(PlatformDetection), nameof(PlatformDetection.IsWasmThreadingSupported))] [InlineData(5, 1000, 50, 50, 50, 0, 5, 500)] [InlineData(0, 1000, 50, 25, 25, 25, 0, 500)] [InlineData(0, 1000, 50, 0, 0, 50, 0, 100)] diff --git a/src/libraries/System.Threading/tests/System.Threading.Tests.csproj b/src/libraries/System.Threading/tests/System.Threading.Tests.csproj index e938db9863da3d..b54013032dbcdb 100644 --- a/src/libraries/System.Threading/tests/System.Threading.Tests.csproj +++ b/src/libraries/System.Threading/tests/System.Threading.Tests.csproj @@ -7,6 +7,10 @@ true + + + $(WasmXHarnessMonoArgs) --setenv=XHARNESS_LOG_TEST_START=true + diff --git a/src/libraries/sendtohelix-browser.targets b/src/libraries/sendtohelix-browser.targets index f710cb8893df73..3cccb3fb641b8f 100644 --- a/src/libraries/sendtohelix-browser.targets +++ b/src/libraries/sendtohelix-browser.targets @@ -239,6 +239,8 @@ 01:20:00 01:20:00 01:20:00 + 01:20:00 + 01:20:00 @@ -266,6 +268,8 @@ 01:20:00 01:20:00 01:20:00 + 01:20:00 + 01:20:00 diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index 2d3d56e60caefd..8e5486f62cf642 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -395,10 +395,6 @@ - - - - @@ -605,14 +601,9 @@ - -