From f7237145aaea71a3e2df1c3740ab754b82406504 Mon Sep 17 00:00:00 2001 From: Alberto Balbo Date: Tue, 20 Oct 2026 10:22:48 +0200 Subject: [PATCH] Prove: il seme del mondo sintetico si sceglie con FEBE_SEME_PROVA MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le prove avviano il sito di prova solo da SyntheticSite, che legge il seme da FEBE_SEME_PROVA e usa 13 quando manca: senza la variabile non cambia nulla. Le classi che lo avviano stanno nella categoria SitoDiProva, così la CI può rifarle con un seme diverso a ogni esecuzione senza raddoppiare tutta la suite, e il seme finisce nell'output della prova per rifare un errore. Nuove prove senza browser: la forma del mondo su cui contano le prove d'insieme vale per 300 semi, i lettori leggono pagina dopo pagina ciò che il sito serve con il seme dell'esecuzione, e nessuna prova avvia il sito per altre vie o resta fuori dalla categoria. Co-Authored-By: Claude Opus 5.5 --- docs/decisioni.md | 1 + .../Collection/ProbeIntegrationTests.cs | 4 +- .../Collection/RecipeIntegrationTests.cs | 2 + .../StopAndDownloadIntegrationTests.cs | 2 + .../Collection/Support/CollectionHarness.cs | 2 +- .../Collection/SyntheticSiteSeedTests.cs | 245 ++++++++++++++++++ .../Febe.Tests/Server/ServerEndToEndTests.cs | 2 + .../Server/Support/ServerTestBed.cs | 2 +- tests/Febe.Tests/Support/SyntheticSite.cs | 46 ++++ tools/Febe.SitoDiProva/LEGGIMI.md | 6 +- 10 files changed, 307 insertions(+), 5 deletions(-) create mode 100644 tests/Febe.Tests/Collection/SyntheticSiteSeedTests.cs create mode 100644 tests/Febe.Tests/Support/SyntheticSite.cs diff --git a/docs/decisioni.md b/docs/decisioni.md index be3e037..5d83e70 100644 --- a/docs/decisioni.md +++ b/docs/decisioni.md @@ -226,3 +226,4 @@ Ogni scelta tecnica presa strada facendo, con data e motivo (specifica §15). | 2026-10-13 | Prove dell'interfaccia in un Chromium senza finestra guidato col protocollo DevTools diretto (`UiBrowser`, solo 127.0.0.1), inconcludenti senza Chromium | Come `tools/schermate`; il client CDP di Febe accetta solo letture | | 2026-10-14 | Revisione avversaria di tutto il codice (7 aree, ogni rilievo verificato da un secondo revisore indipendente): 54 rilievi confermati e corretti con prove di regressione, 2 smentiti, 3 incerti corretti dove il rimedio era sicuro | §14, regola 14: resoconti onesti | | 2026-10-14 | Restano noti e accettati: «Tieni il più grande» scrive con il proprio SafeFileWriter e non passa dal lucchetto per account di `LibraryIngest` (un'importazione e uno scaricamento con gli stessi byte nello stesso istante potrebbero entrare entrambi); le prove d'interfaccia con browser vero aspettano fino a 30 s | Finestra rarissima, nessuna perdita di dati: al più un doppione esatto da togliere a mano | +| 2026-10-20 | Il seme del mondo sintetico del sito di prova si sceglie con la variabile `FEBE_SEME_PROVA` (13 se manca), letta da `SyntheticSite` (`tests/Febe.Tests/Support`), l'unico modo in cui le prove avviano il sito; le classi che lo avviano stanno nella categoria `SitoDiProva`, e una prova controlla che nessuna lo avvii per altre vie o resti fuori dalla categoria. `SyntheticSiteSeedTests` controlla senza browser, per 300 semi, la forma del mondo su cui contano le prove d'insieme e i lettori sulle pagine servite | La CI rifà quelle prove con un seme diverso a ogni esecuzione, scritto nel registro, senza raddoppiare la durata di tutta la suite; senza la variabile non cambia nulla; un errore si rifà con lo stesso seme | diff --git a/tests/Febe.Tests/Collection/ProbeIntegrationTests.cs b/tests/Febe.Tests/Collection/ProbeIntegrationTests.cs index 9a2ce6d..e5310ff 100644 --- a/tests/Febe.Tests/Collection/ProbeIntegrationTests.cs +++ b/tests/Febe.Tests/Collection/ProbeIntegrationTests.cs @@ -4,7 +4,6 @@ using Febe.Browser.Cdp; using Febe.Browser.Gestures; using Febe.Core.Abstractions; using Febe.Core.Collection; -using Febe.SitoDiProva; using Febe.Sonda; using Febe.Tests.Collection.Support; using Febe.Tests.Support; @@ -16,6 +15,7 @@ namespace Febe.Tests.Collection; /// the probe only listens. Then the whole M0 path: raw samples, cleaning, verification. /// [TestClass] +[TestCategory(SyntheticSite.Category)] [DoNotParallelize] public sealed class ProbeIntegrationTests { @@ -53,7 +53,7 @@ public sealed class ProbeIntegrationTests Assert.Inconclusive(s_unavailable); } - await using var site = await TestSite.StartAsync(); + await using var site = await SyntheticSite.StartAsync(); using var temp = new TempFolder("sonda"); var raw = temp.Combine("grezzi"); var hosts = new HostClassifier([site.SiteHost], [site.CdnHost]); diff --git a/tests/Febe.Tests/Collection/RecipeIntegrationTests.cs b/tests/Febe.Tests/Collection/RecipeIntegrationTests.cs index 3f6a8f8..33a16ea 100644 --- a/tests/Febe.Tests/Collection/RecipeIntegrationTests.cs +++ b/tests/Febe.Tests/Collection/RecipeIntegrationTests.cs @@ -5,6 +5,7 @@ using Febe.Core.Engine; using Febe.Core.Storage; using Febe.SitoDiProva; using Febe.Tests.Collection.Support; +using Febe.Tests.Support; namespace Febe.Tests.Collection; @@ -13,6 +14,7 @@ namespace Febe.Tests.Collection; /// Instagram. Time is compressed (a 2.2 s wait lasts about 0.2 s); the browser is shared and the tests run one at a time. /// [TestClass] +[TestCategory(SyntheticSite.Category)] [DoNotParallelize] public sealed class RecipeIntegrationTests { diff --git a/tests/Febe.Tests/Collection/StopAndDownloadIntegrationTests.cs b/tests/Febe.Tests/Collection/StopAndDownloadIntegrationTests.cs index a249095..770064c 100644 --- a/tests/Febe.Tests/Collection/StopAndDownloadIntegrationTests.cs +++ b/tests/Febe.Tests/Collection/StopAndDownloadIntegrationTests.cs @@ -7,6 +7,7 @@ using Febe.Core.Library; using Febe.Core.Storage; using Febe.SitoDiProva; using Febe.Tests.Collection.Support; +using Febe.Tests.Support; namespace Febe.Tests.Collection; @@ -14,6 +15,7 @@ namespace Febe.Tests.Collection; /// Stop signals (spec §7.6) and the download queue (spec §6.5) against the local test site with a real Chromium. /// [TestClass] +[TestCategory(SyntheticSite.Category)] [DoNotParallelize] public sealed class StopAndDownloadIntegrationTests { diff --git a/tests/Febe.Tests/Collection/Support/CollectionHarness.cs b/tests/Febe.Tests/Collection/Support/CollectionHarness.cs index f438f3a..b236511 100644 --- a/tests/Febe.Tests/Collection/Support/CollectionHarness.cs +++ b/tests/Febe.Tests/Collection/Support/CollectionHarness.cs @@ -129,7 +129,7 @@ internal sealed class CollectionHarness : IAsyncDisposable public static async Task CreateAsync(SharedChromium chromium, RecipeOptions? options = null, double factor = 10) { - var site = await TestSite.StartAsync(new TestSiteOptions()); + var site = await SyntheticSite.StartAsync(); var temp = new TempFolder("raccolta"); var library = await TestLibrary.CreateAsync(temp); var clock = new CompressedClock(factor, TestZones.Rome); diff --git a/tests/Febe.Tests/Collection/SyntheticSiteSeedTests.cs b/tests/Febe.Tests/Collection/SyntheticSiteSeedTests.cs new file mode 100644 index 0000000..2c43a0b --- /dev/null +++ b/tests/Febe.Tests/Collection/SyntheticSiteSeedTests.cs @@ -0,0 +1,245 @@ +using System.Globalization; +using System.Text.RegularExpressions; +using Febe.Core.Collection.Readers; +using Febe.Core.Domain; +using Febe.SitoDiProva; +using Febe.Tests.Desktop.Support; +using Febe.Tests.Support; + +namespace Febe.Tests.Collection; + +/// +/// The synthetic world of the test site and its seed (), without a browser, so they run +/// everywhere: what the integration tests take for granted holds for every seed, and the readers of +/// lettori.prova.json read what the site serves with the seed of this run, page after page. Never Instagram: +/// the site is on 127.0.0.1. +/// +[TestClass] +[TestCategory(SyntheticSite.Category)] +public sealed partial class SyntheticSiteSeedTests +{ + private static readonly ShapeReader Reader = new(ReaderVocabulary.LoadTestSite()); + + private static readonly string[] StoryBarOrder = ["marta.prova", "nadia.prova", "luca.prova", "giulia.prova"]; + + public TestContext TestContext { get; set; } = null!; + + [TestMethod] + public void TheSeedComesFromTheVariableAndIsThirteenWithoutIt() + { + Assert.AreEqual(13, SyntheticSite.ParseSeed(null)); + Assert.AreEqual(13, SyntheticSite.ParseSeed(" ")); + Assert.AreEqual(4242, SyntheticSite.ParseSeed("4242")); + Assert.AreEqual(-7, SyntheticSite.ParseSeed(" -7 ")); + Assert.ThrowsExactly(() => SyntheticSite.ParseSeed("tredici")); + Assert.ThrowsExactly(() => SyntheticSite.ParseSeed("99999999999")); + } + + [TestMethod] + public void EveryTestThatStartsTheSiteTakesTheSeedOfTheRunAndIsInItsCategory() + { + var tests = Repository.PathOf("tests", "Febe.Tests"); + var direct = new List(); + var outside = new List(); + foreach (var file in Directory.EnumerateFiles(tests, "*.cs", SearchOption.AllDirectories)) + { + var name = Path.GetRelativePath(tests, file).Replace('\\', '/'); + if (name.StartsWith("bin/", StringComparison.Ordinal) || name.StartsWith("obj/", StringComparison.Ordinal)) + { + continue; + } + + var text = File.ReadAllText(file); + if (name != "Support/SyntheticSite.cs" && DirectStart().IsMatch(text)) + { + direct.Add(name); + } + + if (SiteStart().IsMatch(text) && text.Contains("[TestClass]", StringComparison.Ordinal) + && !text.Contains("[TestCategory(SyntheticSite.Category)]", StringComparison.Ordinal)) + { + outside.Add(name); + } + } + + Assert.IsEmpty(direct, "The site starts through SyntheticSite.StartAsync, which reads FEBE_SEME_PROVA: " + string.Join(", ", direct)); + Assert.IsEmpty(outside, "The CI runs these tests again with the seed of the run only through their category: " + string.Join(", ", outside)); + } + + [TestMethod] + public void EverySeedGivesTheWorldTheIntegrationTestsRelyOn() + { + var now = new DateTimeOffset(2026, 10, 20, 9, 30, 0, TimeSpan.Zero); + int[] extremes = [SyntheticSite.Seed, int.MinValue, -1, 0, int.MaxValue]; + foreach (var seed in extremes.Concat(Enumerable.Range(1, 300)).Distinct()) + { + var world = World.Generate(seed, now); + var context = "seme " + seed.ToString(CultureInfo.InvariantCulture); + Assert.AreEqual(seed, world.Seed, context); + Assert.AreEqual("alberto.prova", world.Viewer.Username, context); + Assert.HasCount(31, world.Accounts, context); + Assert.HasCount(28, world.Following, context); + + var counts = new Dictionary + { + ["alberto.prova"] = 4, + ["marta.prova"] = 18, + ["luca.prova"] = 40, + ["giulia.prova"] = 6, + ["nadia.prova"] = 3, + ["paolo.prova"] = 8, + ["riservato.prova"] = 5, + }; + foreach (var (username, count) in counts) + { + Assert.HasCount(count, world.FindByUsername(username)!.Posts, $"{context}: {username}"); + } + + foreach (var account in world.Accounts) + { + if (account.Username.StartsWith("amico", StringComparison.Ordinal)) + { + Assert.IsTrue(account.Posts.Count is 1 or 2, $"{context}: {account.Username}"); + } + + // Newest first, strictly: «known content at the top» and the cursors rely on it. + for (var i = 1; i < account.Posts.Count; i++) + { + Assert.IsTrue(account.Posts[i - 1].PublishedAt > account.Posts[i].PublishedAt, $"{context}: {account.Username} #{i}"); + } + } + + var posts = world.Accounts.SelectMany(a => a.Posts).ToList(); + Assert.HasCount(posts.Count, posts.Select(p => p.Code).Distinct(StringComparer.Ordinal), $"{context}: codes are unique"); + Assert.HasCount(posts.Count, posts.Select(p => p.Id).Distinct(StringComparer.Ordinal), $"{context}: identifiers are unique"); + Assert.IsTrue(posts.All(p => p.Code.Length == 7 && p.PublishedAt <= now), context); + + var feed = world.Feed(); + for (var i = 1; i < feed.Count; i++) + { + Assert.IsTrue(feed[i - 1].PublishedAt >= feed[i].PublishedAt, $"{context}: feed #{i}"); + } + + CollectionAssert.AreEqual(StoryBarOrder, world.StoryBar(now).Select(a => a.Username).ToArray(), context); + var marta = world.FindByUsername("marta.prova")!; + var active = marta.Stories.Where(s => s.ExpiresAt > now).ToList(); + Assert.HasCount(4, active, context); + Assert.AreEqual(1, active.Count(s => s.File.IsVideo), context); + Assert.HasCount(3, world.FindByUsername("nadia.prova")!.Stories.Where(s => s.ExpiresAt > now), context); + Assert.HasCount(2, world.FindByUsername("luca.prova")!.Stories.Where(s => s.ExpiresAt > now), context); + Assert.HasCount(5, world.FindByUsername("giulia.prova")!.Stories.Where(s => s.ExpiresAt > now), context); + + var grid = world.Grid(marta, ProfileTab.Posts); + Assert.IsTrue(grid.Take(2).All(p => p.Pinned) && grid.Count(p => p.Pinned) == 2, $"{context}: two pinned posts on top"); + Assert.IsTrue(grid.Take(DataApi.GridPageSize).Any(p => p.Files.Count == 3), $"{context}: a series on the first page"); + Assert.HasCount(3, world.Grid(marta, ProfileTab.Tagged), context); + CollectionAssert.AreEqual(new[] { "Estate", "Viaggi" }, marta.Highlights.Select(h => h.Title).ToArray(), context); + Assert.IsTrue(marta.Highlights[0].Items.Any(i => i.Id == marta.Stories[1].Id), $"{context}: a story also in «Estate» (H9)"); + } + } + + [TestMethod] + [Timeout(60_000, CooperativeCancellation = true)] + public async Task TheReadersReadWhatTheSiteServesWithTheSeedOfThisRun() + { + await using var site = await SyntheticSite.StartAsync(); + TestContext.WriteLine($"Seme del mondo sintetico: {site.World.Seed.ToString(CultureInfo.InvariantCulture)}"); + Assert.AreEqual(SyntheticSite.Seed, site.World.Seed); + + string[] feed, firstFeedPageSeries, martaFirstPage, lucaGrid, martaStories, following; + string seriesCode, sharedStory, summerId; + lock (site.World.Gate) + { + var world = site.World; + var marta = world.FindByUsername("marta.prova")!; + feed = [.. world.Feed().Select(p => p.Id)]; + firstFeedPageSeries = [.. world.Feed().Take(DataApi.FeedPageSize).Where(p => p.Files.Count > 1).Select(p => p.Id)]; + martaFirstPage = [.. world.Grid(marta, ProfileTab.Posts).Take(DataApi.GridPageSize).Select(p => p.Id)]; + seriesCode = world.Grid(marta, ProfileTab.Posts).First(p => p.Files.Count == 3).Code; + lucaGrid = [.. world.Grid(world.FindByUsername("luca.prova")!, ProfileTab.Posts).Select(p => p.Id)]; + martaStories = [.. marta.Stories.Select(s => s.Id)]; + sharedStory = marta.Stories[1].Id; + summerId = marta.Highlights[0].Id; + following = [.. world.Following.Select(a => a.Username)]; + } + + // The home: the connected account, the stories bar, then the whole feed page by page, as the recipe scrolls it. + var home = await ReadAsync(site, "/dati/inizio"); + Assert.AreEqual(ReadShape.Recognized, home.Shape); + Assert.AreEqual("alberto.prova", home.Viewer?.Username); + CollectionAssert.AreEqual(StoryBarOrder, home.Profiles.Where(p => p.LatestStoryAt is not null).Select(p => p.Username).ToArray()); + CollectionAssert.AreEqual(firstFeedPageSeries, home.Contents.Where(c => !c.IsComplete).Select(c => c.Id).ToArray(), "A series arrives incomplete in the feed."); + Assert.IsTrue(home.Contents.Where(c => !c.IsComplete).All(c => c.Files.Count == 1)); + CollectionAssert.AreEqual(feed, await AllPagesAsync(site, home, "/dati/inizio/altri?dopo=")); + + // Marta's grid: two pinned posts on top, her highlights, her post count. + var profile = await ReadAsync(site, "/dati/profilo/marta.prova?scheda=post"); + CollectionAssert.AreEqual(martaFirstPage, profile.Contents.Select(c => c.Id).ToArray()); + Assert.IsTrue(profile.Contents.Take(2).All(c => c.Pinned) && profile.Contents.Count(c => c.Pinned) == 2); + CollectionAssert.AreEqual(new[] { "Estate", "Viaggi" }, profile.Highlights.Select(h => h.Title).ToArray()); + Assert.AreEqual(18, profile.Profiles.Single(p => p.PostCount is not null).PostCount); + + // Luca's history, page after page (the backfill): every post once, in order. + var luca = await ReadAsync(site, "/dati/profilo/luca.prova?scheda=post"); + CollectionAssert.AreEqual(lucaGrid, await AllPagesAsync(site, luca, "/dati/profilo/luca.prova/altri?scheda=post&dopo=")); + + // A series on its own page: complete, in order, a video in the middle. + var series = (await ReadAsync(site, "/dati/post/" + seriesCode)).Contents.Single(); + Assert.AreEqual(seriesCode, series.Code); + Assert.IsTrue(series.IsComplete); + CollectionAssert.AreEqual(new[] { MediaKind.Photo, MediaKind.Video, MediaKind.Photo }, series.Files.Select(f => f.Kind).ToArray()); + + // Stories and a highlight that shares one of them (H9). + var stories = await ReadAsync(site, "/dati/storie/marta.prova"); + CollectionAssert.AreEqual(martaStories, stories.Contents.Select(c => c.Id).ToArray()); + Assert.AreEqual(1, stories.Contents.Count(c => c.Files[0].Kind == MediaKind.Video)); + var summer = (await ReadAsync(site, "/dati/evidenza/" + summerId)).Highlights.Single(); + Assert.HasCount(3, summer.Items); + Assert.IsTrue(summer.Items.Any(i => i.Id == sharedStory)); + + // The following list, page after page, and a private profile Alberto does not follow. + var first = await ReadAsync(site, "/dati/seguiti"); + var names = first.Profiles.Select(p => p.Username).ToList(); + var page = first.Page; + while (page?.HasMore == true) + { + var next = await ReadAsync(site, "/dati/seguiti?dopo=" + Uri.EscapeDataString(page.Cursor!)); + names.AddRange(next.Profiles.Select(p => p.Username)); + page = next.Page; + } + + CollectionAssert.AreEqual(following, names); + var hidden = await ReadAsync(site, "/dati/profilo/riservato.prova?scheda=post"); + Assert.AreEqual(true, hidden.Profiles.Single().IsPrivate); + Assert.AreEqual(false, hidden.Profiles.Single().IsFollowed); + Assert.IsEmpty(hidden.Contents); + } + + private async Task ReadAsync(TestSite site, string pathAndQuery) + { + var result = Reader.Read(await site.GetDataAsync(pathAndQuery, TestContext.CancellationToken)); + Assert.AreEqual(ReadShape.Recognized, result.Shape, pathAndQuery); + return result; + } + + /// The identifiers of a first page and of every page after it, following the cursors. + private async Task AllPagesAsync(TestSite site, ReadResult first, string nextPath) + { + var ids = first.Contents.Select(c => c.Id).ToList(); + var page = first.Page; + while (page?.HasMore == true) + { + var next = await ReadAsync(site, nextPath + Uri.EscapeDataString(page.Cursor!)); + ids.AddRange(next.Contents.Select(c => c.Id)); + page = next.Page; + } + + return [.. ids]; + } + + [GeneratedRegex(@"\bTestSite\.StartAsync\(")] + private static partial Regex DirectStart(); + + [GeneratedRegex(@"\b(?:SyntheticSite\.StartAsync|CollectionHarness\.CreateAsync|ServerTestBed\.StartAsync)\(")] + private static partial Regex SiteStart(); +} diff --git a/tests/Febe.Tests/Server/ServerEndToEndTests.cs b/tests/Febe.Tests/Server/ServerEndToEndTests.cs index fb69719..392c58b 100644 --- a/tests/Febe.Tests/Server/ServerEndToEndTests.cs +++ b/tests/Febe.Tests/Server/ServerEndToEndTests.cs @@ -9,6 +9,7 @@ using Febe.Core.Storage; using Febe.SitoDiProva; using Febe.Tests.Alerts.Support; using Febe.Tests.Server.Support; +using Febe.Tests.Support; using Febe.Web.Connection; namespace Febe.Tests.Server; @@ -20,6 +21,7 @@ namespace Febe.Tests.Server; /// the remote view. Never Instagram: the browser only sees 127.0.0.1. /// [TestClass] +[TestCategory(SyntheticSite.Category)] [DoNotParallelize] public sealed partial class ServerEndToEndTests { diff --git a/tests/Febe.Tests/Server/Support/ServerTestBed.cs b/tests/Febe.Tests/Server/Support/ServerTestBed.cs index cf3a434..0174618 100644 --- a/tests/Febe.Tests/Server/Support/ServerTestBed.cs +++ b/tests/Febe.Tests/Server/Support/ServerTestBed.cs @@ -60,7 +60,7 @@ internal sealed class ServerTestBed : IAsyncDisposable public static async Task StartAsync(bool autoLogin = false, double factor = 10, HttpMessageHandler? telegram = null, IFreeSpaceProbe? freeSpace = null) { var temp = new TempFolder("server"); - var site = await TestSite.StartAsync(new TestSiteOptions()); + var site = await SyntheticSite.StartAsync(); var zone = NoonZone(); var clock = new CompressedClock(factor, zone); var options = new ServerOptions diff --git a/tests/Febe.Tests/Support/SyntheticSite.cs b/tests/Febe.Tests/Support/SyntheticSite.cs new file mode 100644 index 0000000..d984db7 --- /dev/null +++ b/tests/Febe.Tests/Support/SyntheticSite.cs @@ -0,0 +1,46 @@ +using System.Globalization; +using Febe.SitoDiProva; + +namespace Febe.Tests.Support; + +/// +/// The one way the tests start the local test site (spec §14.2), so that a run can choose the seed of its synthetic +/// world: when it is set, otherwise (nothing changes when it is unset). +/// The CI runs the whole suite with the default seed, then the tests of again with a seed of +/// its own that it prints in the log: a failure is reproduced by setting the same variable. +/// +internal static class SyntheticSite +{ + /// Environment variable with the seed of the synthetic world. + public const string Variable = "FEBE_SEME_PROVA"; + + /// The seed when the variable is not set: the one of the command-line site and of the cleaned samples. + public const int DefaultSeed = 13; + + /// Test category of the tests whose world comes from the seed (the CI runs them with a second seed). + public const string Category = "SitoDiProva"; + + /// The seed of this run. + public static int Seed => ParseSeed(Environment.GetEnvironmentVariable(Variable)); + + /// Starts the test site with the seed of this run, and says which one in the output of the test. + public static Task StartAsync() + { + var seed = Seed; + Console.WriteLine($"Sito di prova con il seme {seed.ToString(CultureInfo.InvariantCulture)} (si cambia con {Variable})."); + return TestSite.StartAsync(new TestSiteOptions { Seed = seed }); + } + + /// The seed written in : the default when it is empty, an error when it is not a number. + public static int ParseSeed(string? value) + { + if (string.IsNullOrWhiteSpace(value)) + { + return DefaultSeed; + } + + return int.TryParse(value.Trim(), NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out var seed) + ? seed + : throw new InvalidOperationException($"{Variable} deve essere un numero intero (fra -2147483648 e 2147483647), non «{value}»."); + } +} diff --git a/tools/Febe.SitoDiProva/LEGGIMI.md b/tools/Febe.SitoDiProva/LEGGIMI.md index c441d91..285ff27 100644 --- a/tools/Febe.SitoDiProva/LEGGIMI.md +++ b/tools/Febe.SitoDiProva/LEGGIMI.md @@ -15,7 +15,11 @@ dotnet run --project tools/Febe.SitoDiProva -- [--porta 8481] [--porta-cdn 8482] del sito non gli arrivano. - I dati sono **sintetici** e si generano da un seme: stesso seme, stessi account, post, codici e didascalie. Le date sono relative al momento dell'avvio (le storie sono attive per 24 ore da lì). -- Le prove automatiche lo avviano dentro il processo con `TestSite.StartAsync(...)` (porte libere scelte da sole). +- Le prove automatiche lo avviano dentro il processo con `SyntheticSite.StartAsync()` (`tests/Febe.Tests/Support`), che + chiama `TestSite.StartAsync(...)` con porte libere scelte da sole e il seme della variabile `FEBE_SEME_PROVA` (13 se + manca). La CI fa girare tutte le prove con il seme 13 e quelle della categoria `SitoDiProva` anche con un seme + diverso a ogni esecuzione, scritto nel registro; per rifare una prova fallita con quel seme: + `FEBE_SEME_PROVA= dotnet test tests/Febe.Tests --filter "TestCategory=SitoDiProva"`. - Campioni grezzi per le prove dei lettori: `dotnet run --project tools/Febe.SitoDiProva -- campioni --cartella ` (poi `febe-sonda ripulisci`, vedi `tests/Febe.Tests/campioni/prova/LEGGIMI.md`).