I've got a base level function in xunit looks sort of like:
async Task LimitTestTo( Timespan maxTime, Task theTest )
{
await Task.WaitAny( theTest, Task.Delay( timespan ));
if (theTest.IsCompletedSuccessfully) return;
// ?
throw Exception(f"Test timed out after {maxTime}"});
}
And this works fine. However, it just tells me the thing failed - it doesn't tell me why. What I want is to use debugging sort of functionality where I have a ? to
- if the other task is actually doing something
- figure out what thread it's running on
- pause that thread
- get the stack trace
- display it in the test output
- terminate that thread
- otherwise
- explain why it's not - ie what it's waiting on or whatever
now obviously - cancellationtoken or anything can't work as a) I've got no knowledge of or control over the test passed in... b) it requires cooperation - by definition this will only ever occur in a time when a programmer has screwed up - it's probably waiting on a lock or something - so relying on the task to be nice and well behaved is pretty pointless.
I'm playing with dte.debugger.Localprocesses attach, but I'm hoping there's a way to do it from inside the app
bottom line - what I want to capture is why a test is hanging on the build machine... I couldn't care less if the rest of the program is now in a bad, unknown or corrupted state