Correzione: la prova da capo a fondo del server non perde più la prima sessione
«Tempo scaduto: tre file di marta.prova scaricati» era un difetto della prova: l'orologio compresso sommava le attese dei lavori di sottofondo (circa 34 volte invece di 10, a salti) e consumava in un attimo i limiti delle pagine vere e la prima sessione; inoltre il motore apriva la sua sessione a «Ho finito», prima di «Controlla ora», con luca.prova per primo. Finita la sessione, i file aspettavano la prossima: 120 secondi veri, più dei 90 della prova. Ora le composizioni intere usano ScaledClock (attese sovrapposte = stesso tempo, 5 volte), la sola sessione è quella chiesta con «Controlla ora», e un'attesa scaduta dice che cosa faceva Febe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6d66cf96d3
commit
66a3873554
12 files changed
+242
-83
No files matched your search
@@ -1,57 +1,7 @@
|
||||
using Febe.Core.Abstractions;
|
||||
using Febe.Desktop.Core;
|
||||
|
||||
namespace Febe.Tests.Windows.Support;
|
||||
|
||||
/// <summary>
|
||||
/// A clock that compresses time, like the one of the Linux suite: <see cref="Delay"/> waits for real only a fraction
|
||||
/// of the requested time and <see cref="Now"/> moves on by the whole of it, so the engine keeps its order of events
|
||||
/// while a session lasts minutes instead of hours.
|
||||
/// </summary>
|
||||
internal sealed class CompressedClock(double factor, TimeZoneInfo zone) : IClock
|
||||
{
|
||||
private readonly Lock _gate = new();
|
||||
private TimeSpan _offset;
|
||||
|
||||
public TimeZoneInfo LocalZone { get; } = zone;
|
||||
|
||||
public DateTimeOffset Now
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
return DateTimeOffset.UtcNow + _offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Delay(TimeSpan time, CancellationToken ct)
|
||||
{
|
||||
if (time <= TimeSpan.Zero)
|
||||
{
|
||||
ct.ThrowIfCancellationRequested();
|
||||
return;
|
||||
}
|
||||
|
||||
var real = TimeSpan.FromTicks((long)(time.Ticks / factor));
|
||||
if (real >= TimeSpan.FromMilliseconds(1))
|
||||
{
|
||||
await Task.Delay(real, ct).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ct.ThrowIfCancellationRequested();
|
||||
await Task.Yield();
|
||||
}
|
||||
|
||||
lock (_gate)
|
||||
{
|
||||
_offset += time - real;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static class TestZones
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -8,6 +8,7 @@ using Febe.Desktop;
|
||||
using Febe.Desktop.Browser;
|
||||
using Febe.Desktop.Core;
|
||||
using Febe.SitoDiProva;
|
||||
using Febe.Tests.Support;
|
||||
using Febe.Web.Native;
|
||||
|
||||
namespace Febe.Tests.Windows.Support;
|
||||
@@ -15,14 +16,14 @@ namespace Febe.Tests.Windows.Support;
|
||||
/// <summary>
|
||||
/// The shared composition (<see cref="FebeApp"/>) as Febe.exe composes it — <see cref="DesktopPlatform"/>,
|
||||
/// <c>DesktopShell</c>, the window «Browser di Febe» on a WPF UI thread — against its own test site, in temporary
|
||||
/// folders, on a clock ten times faster and in a zone where it is noon. The interface is asked like the main window asks
|
||||
/// folders, on a clock five times faster (<see cref="ScaledClock"/>) and in a zone where it is noon. The interface is asked like the main window asks
|
||||
/// it: with the token of this start and the Origin of the interface.
|
||||
/// </summary>
|
||||
internal sealed class DesktopBed : IAsyncDisposable
|
||||
{
|
||||
private readonly HttpClient _client;
|
||||
|
||||
private DesktopBed(TestSite site, TestFolder folder, UiThread ui, LogLines lines, CompressedClock clock, DesktopPlatform platform, FebeApp app)
|
||||
private DesktopBed(TestSite site, TestFolder folder, UiThread ui, LogLines lines, ScaledClock clock, DesktopPlatform platform, FebeApp app)
|
||||
{
|
||||
Site = site;
|
||||
Folder = folder;
|
||||
@@ -47,7 +48,7 @@ internal sealed class DesktopBed : IAsyncDisposable
|
||||
/// <summary>What Febe wrote in its log.</summary>
|
||||
public LogLines Lines { get; }
|
||||
|
||||
public CompressedClock Clock { get; }
|
||||
public ScaledClock Clock { get; }
|
||||
|
||||
public DesktopPlatform Platform { get; }
|
||||
|
||||
@@ -69,10 +70,13 @@ internal sealed class DesktopBed : IAsyncDisposable
|
||||
{
|
||||
var lines = new LogLines();
|
||||
var data = folder.Combine("dati");
|
||||
|
||||
// «--prima-sessione» at its maximum, an hour (twelve minutes of real time): the only session start is the one
|
||||
// a test asks for with «Controlla ora», as in the Linux suite (ServerTestBed).
|
||||
List<string> arguments =
|
||||
[
|
||||
"--dati", data, "--libreria", folder.Combine("libreria"),
|
||||
"--sito-di-prova", site.SiteUrl, "--cdn-di-prova", site.CdnUrl, "--prima-sessione", "1",
|
||||
"--sito-di-prova", site.SiteUrl, "--cdn-di-prova", site.CdnUrl, "--prima-sessione", "3600",
|
||||
];
|
||||
if (autoLogin)
|
||||
{
|
||||
@@ -87,7 +91,7 @@ internal sealed class DesktopBed : IAsyncDisposable
|
||||
}
|
||||
|
||||
var zone = TestZones.Noon();
|
||||
var clock = new CompressedClock(10, zone);
|
||||
var clock = new ScaledClock(5, zone);
|
||||
var shell = new DesktopShell(ui.Dispatcher, null, BrowserShell.Instance);
|
||||
var platform = new DesktopPlatform(options, shell, new MemoryLocations(), dataFolderFixed: true);
|
||||
var appOptions = options.AppOptions(data, new DesktopFolders(folder.Combine("AppData"), folder.Combine("Immagini"))) with { Zone = zone, ZoneId = zone.Id };
|
||||
|
||||
Reference in new issue
Block a user