Command.Result blocks indefinitely in xunit
See original GitHub issueI have been debugging this for a while and finally found a cause of my tests blocking on xunit.
I’ve been writing a simple xunit test:
using Medallion.Shell;
namespace TestProject1;
public class UnitTest1
{
[Fact]
public void Test1()
{
const string consoleAppPath = @"T:\Temp\ConsoleApp99";
const string consoleAppProjectFileName = @"ConsoleApp99.csproj";
Console.WriteLine(
Command.Run("dotnet", new[] { "build", "--configuration", "Release", Path.Combine(
consoleAppPath, consoleAppProjectFileName) }, o=> o.WorkingDirectory(consoleAppPath)).Result.StandardOutput
);
}
}
This blocks indefinitely on Result
(not on StandardOutput
!), even if I kill dotnet build
and all the child processes manually.
xunit is known for its sync context, so probably there’s a ConfigureAwait(false)
missing somewhere.
(I wouldn’t ask for this in general, but it’s a good idea to use that if you provide a synchronous API.)
Issue Analytics
- State:
- Created 2 months ago
- Reactions:1
- Comments:14 (5 by maintainers)
Top Results From Across the Web
Some unit tests runs indefinitely
In a solution, I have 600 unit tests splitted in various libraries, and 450 of them are present in a single library. When...
Read more >Crispy DRY Tests in xUnit/C# - Blog - Pavel Sapehin
This article explains how to write DRY unit tests for the xUnit framework. ... allows you to nest beforeEach/beforeAll blocks indefinitely, ...
Read more >VS runner hangs on Run All · Issue #611 · xunit/xunit
VS is essentially calling the command line and interpreting the results, so it should run on the cmd line successfully.
Read more >Capturing Output
When xUnit.net v2 shipped with parallelization turned on by default, this output capture mechanism was no longer appropriate; it is impossible to know...
Read more >Out of memory error seems to causes test runner to wait ...
I have some tests that are pushing the boundary with x86 tests and sometimes they cause the xunit runner to give an out...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
At least I’ve figured out that this issue is definitely unrelated to MedallionShell, so I’ve posted it to .NET SDK issue tracker: https://github.com/dotnet/sdk/issues/34653
Still no idea whatever happens there, but let’s at least free MedallionShell of this burden for now.
Earlier, I was testing on .NET 8, but just found that .NET 7 is also affected.
And this is unlikely to be a bug in Medallion.Shell. But I have no repro without it, and thus will investigate further.
Reproduces on
async
test as well 😱