From 3b5b882d3fe9cddd6812ae3d7987268f07ea70cf Mon Sep 17 00:00:00 2001 From: Mitchell Hwang Date: Mon, 6 Jul 2020 15:51:41 -0400 Subject: [PATCH 1/2] [wasm] Enable System.Threading.Channels.Tests and skip hangs --- .../tests/BoundedChannelTests.cs | 16 ++--- .../tests/ChannelTestBase.cs | 72 +++++++++---------- .../tests/ChannelTestBase.netcoreapp.cs | 14 ++-- .../tests/ChannelTests.cs | 6 +- .../tests/UnboundedChannelTests.cs | 6 +- 5 files changed, 57 insertions(+), 57 deletions(-) diff --git a/src/libraries/System.Threading.Channels/tests/BoundedChannelTests.cs b/src/libraries/System.Threading.Channels/tests/BoundedChannelTests.cs index 914eb12e2ae9ef..19c28a248fc8e6 100644 --- a/src/libraries/System.Threading.Channels/tests/BoundedChannelTests.cs +++ b/src/libraries/System.Threading.Channels/tests/BoundedChannelTests.cs @@ -177,7 +177,7 @@ public void WriteAsync_TryRead_Many_DropNewest(int bufferedCapacity) Assert.Equal(0, result); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task TryWrite_DropNewest_WrappedAroundInternalQueue() { var c = Channel.CreateBounded(new BoundedChannelOptions(3) { FullMode = BoundedChannelFullMode.DropNewest }); @@ -249,7 +249,7 @@ public void WriteAsync_TryRead_Many_Ignore(int bufferedCapacity) Assert.Equal(0, result); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task CancelPendingWrite_Reading_DataTransferredFromCorrectWriter() { var c = Channel.CreateBounded(1); @@ -288,7 +288,7 @@ public void TryWrite_TryRead_OneAtATime(int bufferedCapacity) } } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Theory] [InlineData(1)] [InlineData(10)] [InlineData(10000)] @@ -314,7 +314,7 @@ public void SingleProducerConsumer_ConcurrentReadWrite_WithBufferedCapacity_Succ })); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Theory] [InlineData(1)] [InlineData(10)] [InlineData(10000)] @@ -371,7 +371,7 @@ public void ManyProducerConsumer_ConcurrentReadWrite_WithBufferedCapacity_Succes Assert.Equal((NumItems * (NumItems + 1L)) / 2, readTotal); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task WaitToWriteAsync_AfterFullThenRead_ReturnsTrue() { var c = Channel.CreateBounded(1); @@ -389,7 +389,7 @@ public async Task WaitToWriteAsync_AfterFullThenRead_ReturnsTrue() Assert.True(await write2); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Theory] [MemberData(nameof(ThreeBools))] public void AllowSynchronousContinuations_Reading_ContinuationsInvokedAccordingToSetting(bool allowSynchronousContinuations, bool cancelable, bool waitToReadAsync) { @@ -409,7 +409,7 @@ public void AllowSynchronousContinuations_Reading_ContinuationsInvokedAccordingT r.GetAwaiter().GetResult(); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Theory] [InlineData(false)] [InlineData(true)] public void AllowSynchronousContinuations_CompletionTask_ContinuationsInvokedAccordingToSetting(bool allowSynchronousContinuations) @@ -427,7 +427,7 @@ public void AllowSynchronousContinuations_CompletionTask_ContinuationsInvokedAcc r.GetAwaiter().GetResult(); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task TryWrite_NoBlockedReaders_WaitingReader_WaiterNotified() { Channel c = CreateChannel(); diff --git a/src/libraries/System.Threading.Channels/tests/ChannelTestBase.cs b/src/libraries/System.Threading.Channels/tests/ChannelTestBase.cs index e28a58604c4827..ed88b1bed9fcc2 100644 --- a/src/libraries/System.Threading.Channels/tests/ChannelTestBase.cs +++ b/src/libraries/System.Threading.Channels/tests/ChannelTestBase.cs @@ -67,7 +67,7 @@ public void Completion_Idempotent() Assert.Equal(TaskStatus.RanToCompletion, completion.Status); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task Complete_AfterEmpty_NoWaiters_TriggersCompletion() { Channel c = CreateChannel(); @@ -75,7 +75,7 @@ public async Task Complete_AfterEmpty_NoWaiters_TriggersCompletion() await c.Reader.Completion; } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task Complete_AfterEmpty_WaitingReader_TriggersCompletion() { Channel c = CreateChannel(); @@ -85,7 +85,7 @@ public async Task Complete_AfterEmpty_WaitingReader_TriggersCompletion() await Assert.ThrowsAnyAsync(() => r); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task Complete_BeforeEmpty_WaitingReaders_TriggersCompletion() { Channel c = CreateChannel(); @@ -112,7 +112,7 @@ public void TryComplete_Twice_ReturnsTrueThenFalse() Assert.False(c.Writer.TryComplete()); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task TryComplete_ErrorsPropage() { Channel c; @@ -145,7 +145,7 @@ public void Count_ThrowsIfUnsupported() } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public void SingleProducerConsumer_ConcurrentReadWrite_Success() { Channel c = CreateChannel(); @@ -168,7 +168,7 @@ public void SingleProducerConsumer_ConcurrentReadWrite_Success() })); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public void SingleProducerConsumer_PingPong_Success() { Channel c1 = CreateChannel(); @@ -194,7 +194,7 @@ public void SingleProducerConsumer_PingPong_Success() })); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Theory] [InlineData(1, 1)] [InlineData(1, 10)] [InlineData(10, 1)] @@ -326,7 +326,7 @@ public void WaitToWriteAsync_EmptyChannel_SynchronouslyCompletes() Assert.True(write.Result); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task WaitToWriteAsync_ManyConcurrent_SatisifedByReaders() { if (RequiresSingleReader || RequiresSingleWriter) @@ -375,7 +375,7 @@ public void TryWrite_AfterComplete_ReturnsFalse() Assert.False(c.Writer.TryWrite(42)); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task WriteAsync_AfterComplete_ThrowsException() { Channel c = CreateChannel(); @@ -383,7 +383,7 @@ public async Task WriteAsync_AfterComplete_ThrowsException() await Assert.ThrowsAnyAsync(async () => await c.Writer.WriteAsync(42)); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task Complete_WithException_PropagatesToCompletion() { Channel c = CreateChannel(); @@ -392,7 +392,7 @@ public async Task Complete_WithException_PropagatesToCompletion() Assert.Same(exc, await Assert.ThrowsAsync(() => c.Reader.Completion)); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task Complete_WithCancellationException_PropagatesToCompletion() { Channel c = CreateChannel(); @@ -407,7 +407,7 @@ public async Task Complete_WithCancellationException_PropagatesToCompletion() await AssertCanceled(c.Reader.Completion, cts.Token); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task Complete_WithException_PropagatesToExistingWriter() { Channel c = CreateFullChannel(); @@ -420,7 +420,7 @@ public async Task Complete_WithException_PropagatesToExistingWriter() } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task Complete_WithException_PropagatesToNewWriter() { Channel c = CreateChannel(); @@ -430,7 +430,7 @@ public async Task Complete_WithException_PropagatesToNewWriter() Assert.Same(exc, (await Assert.ThrowsAsync(async () => await write)).InnerException); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task Complete_WithException_PropagatesToExistingWaitingReader() { Channel c = CreateChannel(); @@ -440,7 +440,7 @@ public async Task Complete_WithException_PropagatesToExistingWaitingReader() await Assert.ThrowsAsync(async () => await read); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task Complete_WithException_PropagatesToNewWaitingReader() { Channel c = CreateChannel(); @@ -450,7 +450,7 @@ public async Task Complete_WithException_PropagatesToNewWaitingReader() await Assert.ThrowsAsync(async () => await read); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task Complete_WithException_PropagatesToNewWaitingWriter() { Channel c = CreateChannel(); @@ -524,7 +524,7 @@ public void Precancellation_WaitToReadAsync_ReturnsImmediately(bool dataAvailabl Assert.True(waitTask.IsCanceled); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Theory] [InlineData(false)] [InlineData(true)] public async Task WaitToReadAsync_DataWritten_CompletesSuccessfully(bool cancelable) @@ -540,7 +540,7 @@ public async Task WaitToReadAsync_DataWritten_CompletesSuccessfully(bool cancela Assert.True(await read); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task WaitToReadAsync_NoDataWritten_Canceled_CompletesAsCanceled() { Channel c = CreateChannel(); @@ -552,7 +552,7 @@ public async Task WaitToReadAsync_NoDataWritten_Canceled_CompletesAsCanceled() await Assert.ThrowsAnyAsync(async () => await read); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task ReadAsync_ThenWriteAsync_Succeeds() { Channel c = CreateChannel(); @@ -566,7 +566,7 @@ public async Task ReadAsync_ThenWriteAsync_Succeeds() Assert.Equal(42, await r); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task WriteAsync_ReadAsync_Succeeds() { Channel c = CreateChannel(); @@ -594,7 +594,7 @@ public void Precancellation_ReadAsync_ReturnsImmediately(bool dataAvailable) Assert.True(readTask.IsCanceled); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task ReadAsync_Canceled_CanceledAsynchronously() { Channel c = CreateChannel(); @@ -613,7 +613,7 @@ public async Task ReadAsync_Canceled_CanceledAsynchronously() } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task ReadAsync_WriteAsync_ManyConcurrentReaders_SerializedWriters_Success() { if (RequiresSingleReader) @@ -633,7 +633,7 @@ public async Task ReadAsync_WriteAsync_ManyConcurrentReaders_SerializedWriters_S Assert.Equal((Items * (Items - 1)) / 2, Enumerable.Sum(await Task.WhenAll(readers.Select(r => r.AsTask())))); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task ReadAsync_TryWrite_ManyConcurrentReaders_SerializedWriters_Success() { if (RequiresSingleReader) @@ -658,7 +658,7 @@ public async Task ReadAsync_TryWrite_ManyConcurrentReaders_SerializedWriters_Suc Assert.Equal((Items * (Items - 1)) / 2, Enumerable.Sum(await Task.WhenAll(readers))); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task ReadAsync_AlreadyCompleted_Throws() { Channel c = CreateChannel(); @@ -666,7 +666,7 @@ public async Task ReadAsync_AlreadyCompleted_Throws() await Assert.ThrowsAsync(() => c.Reader.ReadAsync().AsTask()); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task ReadAsync_SubsequentlyCompleted_Throws() { Channel c = CreateChannel(); @@ -676,7 +676,7 @@ public async Task ReadAsync_SubsequentlyCompleted_Throws() await Assert.ThrowsAsync(() => r); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task ReadAsync_AfterFaultedChannel_Throws() { Channel c = CreateChannel(); @@ -689,7 +689,7 @@ public async Task ReadAsync_AfterFaultedChannel_Throws() Assert.Same(e, cce.InnerException); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task ReadAsync_AfterCanceledChannel_Throws() { Channel c = CreateChannel(); @@ -701,7 +701,7 @@ public async Task ReadAsync_AfterCanceledChannel_Throws() await Assert.ThrowsAnyAsync(() => c.Reader.ReadAsync().AsTask()); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task ReadAsync_Canceled_WriteAsyncCompletesNextReader() { Channel c = CreateChannel(); @@ -722,7 +722,7 @@ public async Task ReadAsync_Canceled_WriteAsyncCompletesNextReader() } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task ReadAsync_ConsecutiveReadsSucceed() { Channel c = CreateChannel(); @@ -734,7 +734,7 @@ public async Task ReadAsync_ConsecutiveReadsSucceed() } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task WaitToReadAsync_ConsecutiveReadsSucceed() { Channel c = CreateChannel(); @@ -832,7 +832,7 @@ public void ReadAsync_MultipleContinuations_Throws(bool onCompleted, bool? conti } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task WaitToReadAsync_AwaitThenGetResult_Throws() { Channel c = CreateChannel(); @@ -845,7 +845,7 @@ public async Task WaitToReadAsync_AwaitThenGetResult_Throws() Assert.Throws(() => read.GetAwaiter().GetResult()); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task ReadAsync_AwaitThenGetResult_Throws() { Channel c = CreateChannel(); @@ -858,7 +858,7 @@ public async Task ReadAsync_AwaitThenGetResult_Throws() Assert.Throws(() => read.GetAwaiter().GetResult()); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task WaitToWriteAsync_AwaitThenGetResult_Throws() { Channel c = CreateFullChannel(); @@ -875,7 +875,7 @@ public async Task WaitToWriteAsync_AwaitThenGetResult_Throws() Assert.Throws(() => write.GetAwaiter().GetResult()); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task WriteAsync_AwaitThenGetResult_Throws() { Channel c = CreateFullChannel(); @@ -992,7 +992,7 @@ public static IEnumerable Reader_ContinuesOnCurrentContextIfDesired_Me from setNonDefaultTaskScheduler in new[] { true, false } select new object[] { readOrWait, completeBeforeOnCompleted, flowExecutionContext, continueOnCapturedContext, setNonDefaultTaskScheduler }; - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Theory] [MemberData(nameof(Reader_ContinuesOnCurrentContextIfDesired_MemberData))] public async Task Reader_ContinuesOnCurrentSynchronizationContextIfDesired( bool readOrWait, bool completeBeforeOnCompleted, bool flowExecutionContext, bool? continueOnCapturedContext, bool setNonDefaultTaskScheduler) @@ -1088,7 +1088,7 @@ public static IEnumerable Reader_ContinuesOnCurrentSchedulerIfDesired_ from setDefaultSyncContext in new[] { true, false } select new object[] { readOrWait, completeBeforeOnCompleted, flowExecutionContext, continueOnCapturedContext, setDefaultSyncContext }; - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Theory] [MemberData(nameof(Reader_ContinuesOnCurrentSchedulerIfDesired_MemberData))] public async Task Reader_ContinuesOnCurrentTaskSchedulerIfDesired( bool readOrWait, bool completeBeforeOnCompleted, bool flowExecutionContext, bool? continueOnCapturedContext, bool setDefaultSyncContext) diff --git a/src/libraries/System.Threading.Channels/tests/ChannelTestBase.netcoreapp.cs b/src/libraries/System.Threading.Channels/tests/ChannelTestBase.netcoreapp.cs index 15be0c74920eae..88e3a1cb524eb9 100644 --- a/src/libraries/System.Threading.Channels/tests/ChannelTestBase.netcoreapp.cs +++ b/src/libraries/System.Threading.Channels/tests/ChannelTestBase.netcoreapp.cs @@ -22,7 +22,7 @@ public void ReadAllAsync_NotIdempotent() Assert.NotSame(e, c.Reader.ReadAllAsync()); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Theory] [InlineData(false)] [InlineData(true)] public async Task ReadAllAsync_UseMoveNextAsyncAfterCompleted_ReturnsFalse(bool completeWhilePending) @@ -76,7 +76,7 @@ public void ReadAllAsync_AvailableDataCompletesSynchronously() } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task ReadAllAsync_UnavailableDataCompletesAsynchronously() { Channel c = CreateChannel(); @@ -102,7 +102,7 @@ public async Task ReadAllAsync_UnavailableDataCompletesAsynchronously() } } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Theory] [InlineData(0)] [InlineData(1)] [InlineData(128)] @@ -140,7 +140,7 @@ await Task.WhenAll( Assert.Equal(producedTotal, consumedTotal); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task ReadAllAsync_MultipleEnumerationsToEnd() { Channel c = CreateChannel(); @@ -193,7 +193,7 @@ public void ReadAllAsync_MultipleSingleElementEnumerations_AllItemsEnumerated(bo } } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Theory] [InlineData(false)] [InlineData(true)] public async Task ReadAllAsync_DualConcurrentEnumeration_AllItemsEnumerated(bool sameEnumerable) @@ -238,7 +238,7 @@ public async Task ReadAllAsync_DualConcurrentEnumeration_AllItemsEnumerated(bool Assert.Equal(producerTotal, consumerTotal); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Theory] [InlineData(false)] [InlineData(true)] public async Task ReadAllAsync_CanceledBeforeMoveNextAsync_Throws(bool dataAvailable) @@ -260,7 +260,7 @@ public async Task ReadAllAsync_CanceledBeforeMoveNextAsync_Throws(bool dataAvail Assert.Equal(cts.Token, oce.CancellationToken); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task ReadAllAsync_CanceledAfterMoveNextAsync_Throws() { Channel c = CreateChannel(); diff --git a/src/libraries/System.Threading.Channels/tests/ChannelTests.cs b/src/libraries/System.Threading.Channels/tests/ChannelTests.cs index 1c8ee4b8077045..2ea2610b233b49 100644 --- a/src/libraries/System.Threading.Channels/tests/ChannelTests.cs +++ b/src/libraries/System.Threading.Channels/tests/ChannelTests.cs @@ -113,7 +113,7 @@ public void DefaultCompletion_NeverCompletes() Assert.False(t.IsCompleted); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task DefaultWriteAsync_CatchesTryWriteExceptions() { var w = new TryWriteThrowingWriter(); @@ -122,7 +122,7 @@ public async Task DefaultWriteAsync_CatchesTryWriteExceptions() await Assert.ThrowsAsync(async () => await t); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task DefaultReadAsync_CatchesTryWriteExceptions() { var r = new TryReadThrowingReader(); @@ -131,7 +131,7 @@ public async Task DefaultReadAsync_CatchesTryWriteExceptions() await Assert.ThrowsAsync(() => t); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public async Task TestBaseClassReadAsync() { WrapperChannel channel = new WrapperChannel(10); diff --git a/src/libraries/System.Threading.Channels/tests/UnboundedChannelTests.cs b/src/libraries/System.Threading.Channels/tests/UnboundedChannelTests.cs index 3e8c837da514ac..707ff1511effcd 100644 --- a/src/libraries/System.Threading.Channels/tests/UnboundedChannelTests.cs +++ b/src/libraries/System.Threading.Channels/tests/UnboundedChannelTests.cs @@ -137,7 +137,7 @@ public async Task WriteMany_ThenComplete_SuccessfullyReadAll(int readMode) await c.Reader.Completion; } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public void AllowSynchronousContinuations_WaitToReadAsync_ContinuationsInvokedAccordingToSetting() { Channel c = CreateChannel(); @@ -153,7 +153,7 @@ public void AllowSynchronousContinuations_WaitToReadAsync_ContinuationsInvokedAc r.GetAwaiter().GetResult(); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public void AllowSynchronousContinuations_CompletionTask_ContinuationsInvokedAccordingToSetting() { Channel c = CreateChannel(); @@ -208,7 +208,7 @@ public async Task MultipleReaders_CancelsPreviousReader() Assert.Equal(42, await t2); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] + [Fact] public void Stress_TryWrite_TryRead() { const int NumItems = 3000000; From 99365556c0d30dfe214f32a3df6fbd489edccdc6 Mon Sep 17 00:00:00 2001 From: Mitchell Hwang Date: Tue, 7 Jul 2020 00:09:48 -0400 Subject: [PATCH 2/2] [wasm] Skip failing tests in System.Threading.Channels.Tests --- .../tests/BoundedChannelTests.cs | 14 ++++++++++---- .../tests/ChannelTestBase.cs | 6 +++--- .../tests/UnboundedChannelTests.cs | 6 +++--- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/libraries/System.Threading.Channels/tests/BoundedChannelTests.cs b/src/libraries/System.Threading.Channels/tests/BoundedChannelTests.cs index 19c28a248fc8e6..0b4e10099d1152 100644 --- a/src/libraries/System.Threading.Channels/tests/BoundedChannelTests.cs +++ b/src/libraries/System.Threading.Channels/tests/BoundedChannelTests.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Threading.Tasks; +using Microsoft.DotNet.XUnitExtensions; using Xunit; namespace System.Threading.Channels.Tests @@ -288,7 +289,7 @@ public void TryWrite_TryRead_OneAtATime(int bufferedCapacity) } } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] [InlineData(1)] [InlineData(10)] [InlineData(10000)] @@ -314,7 +315,7 @@ public void SingleProducerConsumer_ConcurrentReadWrite_WithBufferedCapacity_Succ })); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] [InlineData(1)] [InlineData(10)] [InlineData(10000)] @@ -389,7 +390,7 @@ public async Task WaitToWriteAsync_AfterFullThenRead_ReturnsTrue() Assert.True(await write2); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] [MemberData(nameof(ThreeBools))] public void AllowSynchronousContinuations_Reading_ContinuationsInvokedAccordingToSetting(bool allowSynchronousContinuations, bool cancelable, bool waitToReadAsync) { @@ -409,11 +410,16 @@ public void AllowSynchronousContinuations_Reading_ContinuationsInvokedAccordingT r.GetAwaiter().GetResult(); } - [Theory] + [ConditionalTheory] [InlineData(false)] [InlineData(true)] public void AllowSynchronousContinuations_CompletionTask_ContinuationsInvokedAccordingToSetting(bool allowSynchronousContinuations) { + if (!allowSynchronousContinuations && !PlatformDetection.IsThreadingSupported) + { + throw new SkipTestException(nameof(PlatformDetection.IsThreadingSupported)); + } + var c = Channel.CreateBounded(new BoundedChannelOptions(1) { AllowSynchronousContinuations = allowSynchronousContinuations }); int expectedId = Environment.CurrentManagedThreadId; diff --git a/src/libraries/System.Threading.Channels/tests/ChannelTestBase.cs b/src/libraries/System.Threading.Channels/tests/ChannelTestBase.cs index ed88b1bed9fcc2..926705b87905b6 100644 --- a/src/libraries/System.Threading.Channels/tests/ChannelTestBase.cs +++ b/src/libraries/System.Threading.Channels/tests/ChannelTestBase.cs @@ -145,7 +145,7 @@ public void Count_ThrowsIfUnsupported() } } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] public void SingleProducerConsumer_ConcurrentReadWrite_Success() { Channel c = CreateChannel(); @@ -168,7 +168,7 @@ public void SingleProducerConsumer_ConcurrentReadWrite_Success() })); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] public void SingleProducerConsumer_PingPong_Success() { Channel c1 = CreateChannel(); @@ -194,7 +194,7 @@ public void SingleProducerConsumer_PingPong_Success() })); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] [InlineData(1, 1)] [InlineData(1, 10)] [InlineData(10, 1)] diff --git a/src/libraries/System.Threading.Channels/tests/UnboundedChannelTests.cs b/src/libraries/System.Threading.Channels/tests/UnboundedChannelTests.cs index 707ff1511effcd..3e8c837da514ac 100644 --- a/src/libraries/System.Threading.Channels/tests/UnboundedChannelTests.cs +++ b/src/libraries/System.Threading.Channels/tests/UnboundedChannelTests.cs @@ -137,7 +137,7 @@ public async Task WriteMany_ThenComplete_SuccessfullyReadAll(int readMode) await c.Reader.Completion; } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] public void AllowSynchronousContinuations_WaitToReadAsync_ContinuationsInvokedAccordingToSetting() { Channel c = CreateChannel(); @@ -153,7 +153,7 @@ public void AllowSynchronousContinuations_WaitToReadAsync_ContinuationsInvokedAc r.GetAwaiter().GetResult(); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] public void AllowSynchronousContinuations_CompletionTask_ContinuationsInvokedAccordingToSetting() { Channel c = CreateChannel(); @@ -208,7 +208,7 @@ public async Task MultipleReaders_CancelsPreviousReader() Assert.Equal(42, await t2); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] public void Stress_TryWrite_TryRead() { const int NumItems = 3000000;