using System.Security; using Febe.Tests.Desktop.Support; using Febe.Tests.Support; namespace Febe.Tests.Packaging; /// /// The summary of the test results (.gitea/scripts/riepilogo-prove.sh), run on .trx files written here: the CI allows no /// skipped test, and the only inconclusive results that do not count as skipped are the «da fare» ones of /// H264ConformanceTests.FeaturesStillToDo, whose reason starts with «da fare: » right after the frame MSTest puts around /// it (in English or in Italian). /// public sealed partial class PipelineTests { private const string FeaturesStillToDo = "FeaturesStillToDo (\"SVCBST-19\",\"SVC, scalabilità spaziale\")"; [TestMethod] [Timeout(120_000, CooperativeCancellation = true)] public async Task OnlyTheToDoConformanceStreamsMaySkipInTheCi() { var bash = RequireBash(); // The frames of MSTest, old and new, English and Italian: all «da fare», none skipped. var toDo = await RunSummaryAsync(bash, ("Passed", "AnythingElse", null), ("NotExecuted", FeaturesStillToDo, "Assert.Inconclusive. da fare: SVC, scalabilità spaziale"), ("NotExecuted", FeaturesStillToDo, "Assert.Inconclusive failed. da fare: MVC, due viste, confronto bit per bit"), ("NotExecuted", FeaturesStillToDo, "Assert.Inconclusive non riuscito. da fare: MVC, tre viste"), ("Inconclusive", FeaturesStillToDo, "Assert.Inconclusive. da fare: SVC & ")); Assert.AreEqual(0, toDo.Code, toDo.Report); StringAssert.Contains(toDo.Output, "totale 5 · superate 1 · fallite 0 · saltate 0 · da fare 4", toDo.Report); StringAssert.Contains(toDo.Output, " - da fare: SVC & ", toDo.Report); // Anything else inconclusive is a skipped test, and turns the verification red: another reason in // FeaturesStillToDo, «da fare: » not at the start of the reason, the same reason in another test. (string Name, string Message)[] skipped = [ (FeaturesStillToDo, "Assert.Inconclusive. da verificare: MVC, due viste"), (FeaturesStillToDo, "Assert.Inconclusive. Manca Chromium; da fare: installarlo"), ("ChromiumStartsInTheSandbox", "Assert.Inconclusive. da fare: niente"), ("FeaturesStillToDoLater", "Assert.Inconclusive. da fare: niente"), ]; foreach (var (name, message) in skipped) { var run = await RunSummaryAsync(bash, ("Passed", "AnythingElse", null), ("NotExecuted", name, message)); Assert.AreEqual(1, run.Code, $"{name}: {message}\n{run.Report}"); StringAssert.Contains(run.Output, "totale 2 · superate 1 · fallite 0 · saltate 1 · da fare 0", run.Report); StringAssert.Contains(run.Errors, "Prove saltate: 1, più delle 0 ammesse.", run.Report); } // The H.264 conformance tests write no other inconclusive reason: every Assert.Inconclusive there starts with it. var source = Read(Repository.PathOf("tests", "Febe.Tests", "Media", "H264", "H264ConformanceTests.cs")); var reasons = System.Text.RegularExpressions.Regex.Matches(source, @"Assert\.Inconclusive\(\$?""(?[^""]*)"""); Assert.IsGreaterThanOrEqualTo(3, reasons.Count); foreach (System.Text.RegularExpressions.Match reason in reasons) { StringAssert.StartsWith(reason.Groups["reason"].Value, "da fare: ", reason.Value); } } /// riepilogo-prove.sh with no skipped test allowed, on one .trx file of the given results. private async Task<(int Code, string Output, string Errors, string Report)> RunSummaryAsync(string bash, params (string Outcome, string Name, string? Message)[] results) { using var folder = new TempFolder("febe-riepilogo"); var trx = new System.Text.StringBuilder("\n\n \n"); var id = 0; foreach (var (outcome, name, message) in results) { trx.Append($" "); if (message is not null) { trx.Append($"\n \n \n {SecurityElement.Escape(message)}\n \n \n "); } trx.Append("\n"); id++; } trx.Append(" \n\n"); await File.WriteAllTextAsync(folder.Combine("prove.trx"), trx.ToString(), TestContext.CancellationToken); var run = await RunProcessAsync(bash, ["--noprofile", "--norc", ".gitea/scripts/riepilogo-prove.sh", folder.Path.Replace('\\', '/'), "0"], start => { start.Environment.Remove("GITHUB_STEP_SUMMARY"); start.Environment.Remove("PROVE_SALTATE_AMMESSE"); }); return (run.Code, run.Output, run.Errors, $"codice {run.Code}\n{run.Output}\n{run.Errors}"); } }