mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 07:47:54 +01:00
* Initial plan * Implement configurable startup timeout for GuiTestContext - Increase default With.Timeout from 30s to 120s (CI-friendly) - Add timeout parameter to GuiTestContext constructor - Forward With.Timeout to GuiTestContext in both A() overloads - Use configurable timeout for _hardStop CancellationTokenSource - Update boot wait from fixed 10s to use configurable timeout - Update WaitUntil to use instance timeout instead of static With.Timeout Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fix code style - add missing spaces in With.cs Co-authored-by: tig <585482+tig@users.noreply.github.com> * Change timeout back to 30 seconds as requested Co-authored-by: tig <585482+tig@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tig <585482+tig@users.noreply.github.com> Co-authored-by: Tig <tig@users.noreply.github.com>
This commit is contained in:
@@ -13,7 +13,7 @@ namespace TerminalGuiFluentTesting;
|
||||
public class GuiTestContext : IDisposable
|
||||
{
|
||||
private readonly CancellationTokenSource _cts = new ();
|
||||
private readonly CancellationTokenSource _hardStop = new (With.Timeout);
|
||||
private readonly CancellationTokenSource _hardStop;
|
||||
private readonly Task _runTask;
|
||||
private Exception? _ex;
|
||||
private readonly FakeOutput _output = new ();
|
||||
@@ -25,9 +25,12 @@ public class GuiTestContext : IDisposable
|
||||
private readonly TestDriver _driver;
|
||||
private bool _finished;
|
||||
private readonly FakeSizeMonitor _fakeSizeMonitor;
|
||||
private readonly TimeSpan _timeout;
|
||||
|
||||
internal GuiTestContext (Func<Toplevel> topLevelBuilder, int width, int height, TestDriver driver, TextWriter? logWriter = null)
|
||||
internal GuiTestContext (Func<Toplevel> topLevelBuilder, int width, int height, TestDriver driver, TextWriter? logWriter = null, TimeSpan? timeout = null)
|
||||
{
|
||||
_timeout = timeout ?? TimeSpan.FromSeconds (30);
|
||||
_hardStop = new (_timeout);
|
||||
// Remove frame limit
|
||||
Application.MaximumIterationsPerSecond = ushort.MaxValue;
|
||||
|
||||
@@ -104,7 +107,7 @@ public class GuiTestContext : IDisposable
|
||||
_cts.Token);
|
||||
|
||||
// Wait for booting to complete with a timeout to avoid hangs
|
||||
if (!booting.WaitAsync (TimeSpan.FromSeconds (10)).Result)
|
||||
if (!booting.WaitAsync (_timeout).Result)
|
||||
{
|
||||
throw new TimeoutException ("Application failed to start within the allotted time.");
|
||||
}
|
||||
@@ -440,7 +443,7 @@ public class GuiTestContext : IDisposable
|
||||
|
||||
while (!condition ())
|
||||
{
|
||||
if (sw.Elapsed > With.Timeout)
|
||||
if (sw.Elapsed > _timeout)
|
||||
{
|
||||
throw new TimeoutException ("Failed to reach condition within the time limit");
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public static class With
|
||||
/// <returns></returns>
|
||||
public static GuiTestContext A<T> (int width, int height, TestDriver testDriver, TextWriter? logWriter = null) where T : Toplevel, new ()
|
||||
{
|
||||
return new (() => new T (), width, height,testDriver,logWriter);
|
||||
return new (() => new T (), width, height, testDriver, logWriter, Timeout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -29,7 +29,7 @@ public static class With
|
||||
/// <returns></returns>
|
||||
public static GuiTestContext A (Func<Toplevel> toplevelFactory, int width, int height, TestDriver testDriver)
|
||||
{
|
||||
return new (toplevelFactory, width, height, testDriver);
|
||||
return new (toplevelFactory, width, height, testDriver, null, Timeout);
|
||||
}
|
||||
/// <summary>
|
||||
/// The global timeout to allow for any given application to run for before shutting down.
|
||||
|
||||
Reference in New Issue
Block a user