mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-24 04:02:50 +08:00
Fix intermittent test failure
When running on .NET Framework, the `Should_Report_Max_Remaining_Time_For_Extremely_Small_Progress` would intermittently fail with the following error: ``` task.RemainingTime should be 10675199.02:48:05.4775807 but was null ``` This is because it's possible that the two increment share the same timestamp thus making the `RemainingTime` null. To ensure the two increments don't share the same timestamp, we sleep for one millisecond. Although I have only observed this issue on .NET Framework it would be possible that it occasionally also occur on .NET Core.
This commit is contained in:
parent
e081593012
commit
ffd24ec451
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Shouldly;
|
using Shouldly;
|
||||||
using Spectre.Console.Testing;
|
using Spectre.Console.Testing;
|
||||||
@ -261,6 +262,9 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
{
|
{
|
||||||
task = ctx.AddTask("foo");
|
task = ctx.AddTask("foo");
|
||||||
task.Increment(double.Epsilon);
|
task.Increment(double.Epsilon);
|
||||||
|
// Make sure that at least one millisecond has elapsed between the increments else the RemainingTime is null
|
||||||
|
// when the last timestamp is equal to the first timestamp of the samples.
|
||||||
|
Thread.Sleep(1);
|
||||||
task.Increment(double.Epsilon);
|
task.Increment(double.Epsilon);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user