public static async Task ExecuteAsync(this AppRunner runner, Func <Task> func) { try { await runner.StartAsync(CommonTestTimeouts.StartProcess); await runner.SendStartScenarioAsync(CommonTestTimeouts.SendCommand); await func(); await runner.SendEndScenarioAsync(CommonTestTimeouts.SendCommand); // This gives the app time to send out any remaining stdout/stderr messages, // exit properly, and delete its diagnostic pipe. await runner.WaitForExitAsync(CommonTestTimeouts.WaitForExit); } catch (Exception) { // If an exception is thrown, give app some time to send out any remaining // stdout/stderr messages. await Task.Delay(ExceptionTimeout); throw; } finally { await runner.DisposeAsync(); } }
public static async Task <int> WaitForExitAsync(this AppRunner runner, TimeSpan timeout) { using CancellationTokenSource cancellation = new(timeout); return(await runner.WaitForExitAsync(cancellation.Token).ConfigureAwait(false)); }
public static Task <int> WaitForExitAsync(this AppRunner runner) { return(runner.WaitForExitAsync(CommonTestTimeouts.WaitForExit)); }