Skip to content
Open
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
4 changes: 2 additions & 2 deletions src/Microsoft.DotNet.XHarness.iOS.Shared/TestReporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class TestReporter : ITestReporter

public bool ResultsUseXml => _xmlJargon != XmlResultJargon.Missing;

private bool TestExecutionStarted => _listener.ConnectedTask.IsCompleted && _listener.ConnectedTask.Result;
private bool TestExecutionStarted => _listener.ConnectedTask.IsCompletedSuccessfully && _listener.ConnectedTask.Result;

public TestReporter(
IMlaunchProcessManager processManager,
Expand Down Expand Up @@ -136,7 +136,7 @@ private async Task<int> GetPidFromRunLog()
if (reader.Peek() == -1)
{
// Empty file! If the app never connected to our listener, it probably never launched
if (!_listener.ConnectedTask.IsCompleted || !_listener.ConnectedTask.Result)
if (!_listener.ConnectedTask.IsCompletedSuccessfully || !_listener.ConnectedTask.Result)
{
_launchFailure = true;
}
Comment on lines +139 to 142
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a unit test covering the scenario this change fixes: when ConnectedTask is canceled (e.g., due to a timeout) and the run log is empty, GetPidFromRunLog/CollectSimulatorResult should not throw and should treat it as a launch failure. This will prevent regressions where accessing ConnectedTask.Result reintroduces TaskCanceledException.

Suggested change
if (!_listener.ConnectedTask.IsCompletedSuccessfully || !_listener.ConnectedTask.Result)
{
_launchFailure = true;
}
var connectedTask = _listener.ConnectedTask;
// If the task never completed, or if accessing the result throws (e.g. due to cancellation),
// treat this as a launch failure instead of surfacing TaskCanceledException.
if (!connectedTask.IsCompleted)
{
_launchFailure = true;
}
else
{
bool connected = false;
try
{
connected = connectedTask.Result;
}
catch (AggregateException ae) when (ae.InnerException is TaskCanceledException)
{
connected = false;
}
catch (TaskCanceledException)
{
connected = false;
}
if (!connected)
{
_launchFailure = true;
}
}

Copilot uses AI. Check for mistakes.
Expand Down
Loading