Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions src/libraries/System.IO.Pipelines/tests/PipeWriterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,33 +228,35 @@ public async Task WritesUsingGetMemoryWorks()
pipe.Reader.Complete();
}

[Fact]
[SkipOnPlatform(TestPlatforms.Browser, "allocates too much memory")]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
public async Task CompleteWithLargeWriteThrows()
{
var completeDelay = TimeSpan.FromMilliseconds(10);
var testTimeout = TimeSpan.FromMilliseconds(10000);
var pipe = new Pipe();
pipe.Reader.Complete();

var task = Task.Run(async () =>
{
await Task.Delay(10);
await Task.Delay(completeDelay);
pipe.Writer.Complete();
});

try
// Complete while writing
await Assert.ThrowsAsync<InvalidOperationException>(async () =>
{
for (int i = 0; i < 1000; i++)
var testStartTime = DateTime.UtcNow;
var buffer = new byte[10000000];
ulong i = 0;
while (true)
{
var buffer = new byte[10000000];
await pipe.Writer.WriteAsync(buffer);
}
}
catch (InvalidOperationException)
{
// Complete while writing
}

await task;
// abort test if we're executing for more than the testTimeout (check every 10000th iteration)
if (i++ % 10000 == 0 && DateTime.UtcNow - testStartTime > testTimeout)
break;
}
});
}

[Fact]
Expand Down