From 2d39967b9f2fd86e5a914d576b84ef226badd3c2 Mon Sep 17 00:00:00 2001 From: E M <5089238+emizzle@users.noreply.github.com> Date: Mon, 4 May 2026 17:02:50 +1000 Subject: [PATCH] oops, amend to previous commit --- Tests/DistTestCore/Global.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Tests/DistTestCore/Global.cs b/Tests/DistTestCore/Global.cs index ce6746c2..1c29674a 100644 --- a/Tests/DistTestCore/Global.cs +++ b/Tests/DistTestCore/Global.cs @@ -8,6 +8,7 @@ namespace DistTestCore public class Global { public const string TestNamespacePrefix = "storage-"; + public static readonly string TestResultsFile = Path.Combine(Path.GetTempPath(), "test-results.jsonl"); public Configuration Configuration { get; } = new Configuration(); public Assembly[] TestAssemblies { get; } @@ -32,10 +33,16 @@ namespace DistTestCore public void Setup() { - // Console.Out is block-buffered when stdout is non-interactive (e.g. in a container). - // Replace it with an auto-flushing wrapper so the NUnit runner's own "Passed/Failed" - // progress lines are written to pod stdout immediately after each test completes, - // rather than batching until process exit. + // At process exit, write accumulated test-result JSON lines to stdout. + // ProcessExit fires after NUnit is completely done (no more output capture), + // so writes here go directly to the real stdout pipe and appear in Cloud Logging. + AppDomain.CurrentDomain.ProcessExit += (_, _) => + { + if (!File.Exists(TestResultsFile)) return; + var raw = new StreamWriter(Console.OpenStandardOutput(), leaveOpen: true) { AutoFlush = true }; + raw.Write(File.ReadAllText(TestResultsFile)); + }; + Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = true }); try