From 88286f6325f11ec2c5519734bdb8bec527fe6fc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Wed, 11 Dec 2024 13:35:01 +0100 Subject: [PATCH] Fix displaying progress in non-ansi terminal (#4320) --- .../OutputDevice/Terminal/NonAnsiTerminal.cs | 8 ++++---- .../OutputDevice/Terminal/TestNodeResultsState.cs | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/NonAnsiTerminal.cs b/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/NonAnsiTerminal.cs index 2da9ab982c..3f91a8a4be 100644 --- a/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/NonAnsiTerminal.cs +++ b/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/NonAnsiTerminal.cs @@ -183,8 +183,6 @@ public void RenderProgress(TestProgressState?[] progress) // Use just ascii here, so we don't put too many restrictions on fonts needing to // properly show unicode, or logs being saved in particular encoding. - TestDetailState? activeTest = p.TestNodeResultsState?.GetFirstRunningTask(); - string? detail = !RoslynString.IsNullOrWhiteSpace(activeTest?.Text) ? $"- {activeTest.Text}" : null; Append('['); SetColor(TerminalColor.DarkGreen); Append('+'); @@ -226,10 +224,12 @@ public void RenderProgress(TestProgressState?[] progress) Append(')'); } - if (!RoslynString.IsNullOrWhiteSpace(detail)) + TestDetailState? activeTest = p.TestNodeResultsState?.GetRunningTasks(1).FirstOrDefault(); + if (!RoslynString.IsNullOrWhiteSpace(activeTest?.Text)) { Append(" - "); - Append(detail); + Append(activeTest.Text); + Append(' '); } Append(durationString); diff --git a/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TestNodeResultsState.cs b/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TestNodeResultsState.cs index d2532fdcd7..d0dc3f4056 100644 --- a/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TestNodeResultsState.cs +++ b/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TestNodeResultsState.cs @@ -28,8 +28,6 @@ public TestNodeResultsState(long id) public void RemoveRunningTestNode(string uid) => _testNodeProgressStates.TryRemove(uid, out _); - public TestDetailState? GetFirstRunningTask() => _testNodeProgressStates.FirstOrDefault().Value; - public IEnumerable GetRunningTasks(int maxCount) { var sortedDetails = _testNodeProgressStates