Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/Changelog-Platform.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)

* Align the CTRF reporter with specification 0.2.0 by emitting native final-attempt identities, retaining legacy retry identity support, and keeping compatible mixed-version merges correctly versioned and identified.
* Graduate `Microsoft.Testing.Extensions.CtrfReport` to stable, align its package version with Microsoft.Testing.Platform, and remove the experimental registration API warning. The producer remains pinned to CTRF 0.2.0 and stays opt-in in MSTest.Sdk.
* Increase the default non-cursor progress heartbeat silence threshold from 30 to 60 seconds and measure it from visible reporter output, so hidden test results no longer postpone heartbeats. `MTP_PROGRESS_SILENCE_SECONDS` still overrides the interval, and `0` disables the heartbeat.

## <a name="2.5.2" />[2.5.2] - 2026-10-27

Expand Down
276 changes: 276 additions & 0 deletions docs/decisions/ci-terminal-progress-summaries.md

Large diffs are not rendered by default.

19 changes: 16 additions & 3 deletions docs/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,16 +498,29 @@ A sealed class (`Microsoft.VisualStudio.TestTools.UnitTesting.PlannedTest`, curr

### --progress

An MTP terminal-reporter command-line option that controls whether animated progress output is shown during a test run. Accepts three values:
An MTP terminal-reporter command-line option that controls progress output during a test run. Accepts three values:

| Value | Behavior |
| --- | --- |
| `auto` (default) | Show progress unless the terminal cannot update in place (non-ANSI/simple terminal), or the session is a test-host controller, `--list-tests`, or server mode |
| `on` | Same as `auto` (a dedicated heartbeat renderer for non-cursor modes is tracked separately) |
| `auto` (default) | Update progress in place on cursor-capable terminals; emit bounded durable progress on non-cursor terminals. Test-host controllers, `--list-tests`, and server mode do not render progress. |
| `on` | Same as `auto` |
| `off` | Suppress all progress output |

Introduced in [PR #9145](https://github.com/microsoft/testfx/pull/9145) as a replacement for the former `--no-progress` flag. `--no-progress` continues to work as a deprecated alias that routes to `--progress off`; outside of CI it emits a one-per-process deprecation warning on stderr. The warning is suppressed in CI environments, where it would be invisible noise and where build infrastructure (such as the Arcade SDK test runner) passes `--no-progress` unconditionally. `--progress` always wins when both are supplied.

On CI, piped, and redirected non-cursor terminals, a progress line is emitted after
60 seconds without visible reporter output. Hidden passing results do not postpone
it. The line reports cumulative completed/failed counts, active modules, and the
age of the last test completion (or that no test has completed yet); a heartbeat
does not imply that work completed. `MTP_PROGRESS_SILENCE_SECONDS` overrides this
interval and `0` disables it. Slow-test notices retain their independent
`MTP_PROGRESS_SLOW_TEST_SECONDS` threshold and exponential backoff.

Non-cursor run summaries place the verdict, aggregate counts, and failures before
artifact paths. Successful module results already printed at completion are not
repeated in the final summary. Artifact paths and failure diagnostics remain
available in full; cursor-capable interactive output is unchanged.

### PropertyBag

An MTP class (`Microsoft.Testing.Platform.Extensions.Messages.PropertyBag`) that holds a typed collection of `IProperty` instances attached to a [TestNode](#testnode). Extension authors populate a `PropertyBag` with properties such as `TimingProperty`, `TestFileLocationProperty`, and `TestMetadataProperty` to communicate rich metadata about a test to the platform and to other extensions. A `PropertyBag` enforces that at most one `TestNodeStateProperty` may be present at a time.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ namespace Microsoft.Testing.Platform.OutputDevice.Terminal;
/// run goes silent or a test runs slowly (used for <see cref="AnsiMode.SimpleAnsi"/> and
/// <see cref="AnsiMode.NoAnsi"/>, e.g. CI / piped / redirected output).</description></item>
/// </list>
/// All members are invoked by <see cref="TestProgressStateAwareTerminal"/> while it holds the terminal lock,
/// except <see cref="OnTestCompleted"/> which may be called from the message pump and MUST be thread-safe.
/// <see cref="OnWrite"/> and <see cref="OnTick"/> are invoked by <see cref="TestProgressStateAwareTerminal"/>
/// while it holds the terminal lock. <see cref="OnStart"/> runs during initialization, before the rendering
/// thread starts, without that lock. <see cref="TickInterval"/> is read by the rendering thread without the
/// lock. <see cref="OnTestCompleted"/> may be called from the message pump without the lock and MUST be
/// thread-safe.
/// </remarks>
[UnsupportedOSPlatform("browser")]
[Embedded]
Expand Down Expand Up @@ -52,7 +55,8 @@ void OnWrite(
TerminalProgressMessageState[]? messages = null);

/// <summary>
/// Notifies the renderer that a test completed. Used by the heartbeat renderer to reset its silence timer.
/// Notifies the renderer that a test completed. Used by the heartbeat renderer to report completion age,
/// independently of whether that result produced visible output.
/// MUST be thread-safe.
/// </summary>
void OnTestCompleted();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ namespace Microsoft.Testing.Platform.OutputDevice.Terminal;
/// i.e. CI / piped / file-redirected output). Instead of redrawing a progress block in place, it emits
/// single, durable scrollback lines and only when there is a reason to:
/// <list type="number">
/// <item><description>E1 silence heartbeat — one summary line when no test completed for the silence threshold.</description></item>
/// <item><description>E1 silence heartbeat — one summary line when no visible output was written for the silence threshold.</description></item>
/// <item><description>E2 slow-test surfacing — one line per test that exceeds the slow-test threshold, with exponential backoff.</description></item>
/// </list>
/// A healthy fast suite emits zero heartbeat lines.
/// Hidden test results do not postpone visible progress.
/// </summary>
[UnsupportedOSPlatform("browser")]
[Embedded]
Expand All @@ -23,6 +23,7 @@ internal sealed class SilenceDrivenHeartbeatRenderer : IProgressRenderer
private readonly TimeSpan _silenceThreshold;
private readonly TimeSpan _slowTestThreshold;
private readonly Func<IStopwatch> _createStopwatch;
private readonly Func<IEnumerable<TestProgressState>>? _getTestRuns;

// Per running-test backoff state: test detail id -> next elapsed threshold at which to emit.
// Only touched from the single rendering thread inside OnTick.
Expand All @@ -35,15 +36,23 @@ internal sealed class SilenceDrivenHeartbeatRenderer : IProgressRenderer

private IStopwatch? _clock;

// Ticks (on _clock's timeline) of the last activity (test completion) or last heartbeat emission.
// Read/written from multiple threads, so guarded with Interlocked.
private long _lastActivityTicks;
// Initialized in OnStart before the rendering thread starts. OnWrite and OnTick accesses are protected
// by TestProgressStateAwareTerminal's lock; OnTestCompleted does not access this field.
private long _lastVisibleOutputTicks;
Comment thread
Evangelink marked this conversation as resolved.
Resolved

public SilenceDrivenHeartbeatRenderer(TimeSpan silenceThreshold, TimeSpan slowTestThreshold, Func<IStopwatch> createStopwatch)
// Completion notifications arrive outside the rendering lock. -1 means no completion in this run.
private long _lastCompletionTicks = -1;
Comment thread
Evangelink marked this conversation as resolved.
Resolved

public SilenceDrivenHeartbeatRenderer(
TimeSpan silenceThreshold,
TimeSpan slowTestThreshold,
Func<IStopwatch> createStopwatch,
Func<IEnumerable<TestProgressState>>? getTestRuns = null)
{
_silenceThreshold = silenceThreshold;
_slowTestThreshold = slowTestThreshold;
_createStopwatch = createStopwatch;
_getTestRuns = getTestRuns;
}

// The heartbeat rules only need second-level granularity, so we tick once per second instead of the
Expand All @@ -61,19 +70,23 @@ public void OnStart()
_slowTestThresholdStates.Clear();
IStopwatch clock = _createStopwatch();
Volatile.Write(ref _clock, clock);
Interlocked.Exchange(ref _lastActivityTicks, clock.Elapsed.Ticks);
_lastVisibleOutputTicks = clock.Elapsed.Ticks;
Interlocked.Exchange(ref _lastCompletionTicks, -1);
}

public void OnTestCompleted()
=> Interlocked.Exchange(ref _lastActivityTicks, NowTicks);
=> Interlocked.Exchange(ref _lastCompletionTicks, NowTicks);

public void OnWrite(
ITerminal terminal,
TestProgressState?[] progressItems,
Action<ITerminal> write,
TerminalProgressMessageState[]? messages = null)
{
// Heartbeat lines are durable scrollback; a user write does not need to erase or re-render any progress.
=> write(terminal);
write(terminal);
_lastVisibleOutputTicks = NowTicks;
}

public void OnTick(ITerminal terminal, TestProgressState?[] progressItems, TerminalProgressMessageState[]? messages = null)
{
Expand All @@ -89,19 +102,24 @@ private void EmitSilenceHeartbeat(ITerminal terminal, TestProgressState?[] progr
}

long now = NowTicks;
long last = Interlocked.Read(ref _lastActivityTicks);
if (now - last < _silenceThreshold.Ticks)
if (now - _lastVisibleOutputTicks < _silenceThreshold.Ticks)
{
return;
}

// Reset the baseline so that, during a prolonged silence, the heartbeat repeats once per threshold interval.
Interlocked.Exchange(ref _lastActivityTicks, now);
_lastVisibleOutputTicks = now;

int completed = 0;
int failed = 0;
string? activeTest = null;
foreach (TestProgressState? item in progressItems)
// The reporter retains completed assemblies after their worker slots are freed.
IEnumerable<TestProgressState?> testRuns = progressItems;
if (_getTestRuns is not null)
{
testRuns = _getTestRuns();
}

foreach (TestProgressState? item in testRuns)
{
if (item is null)
{
Expand All @@ -110,7 +128,18 @@ private void EmitSilenceHeartbeat(ITerminal terminal, TestProgressState?[] progr

completed += item.TotalTests;
failed += item.FailedTests;
}

int activeModules = 0;
string? activeTest = null;
foreach (TestProgressState? item in progressItems)
{
if (item is null)
{
continue;
}

activeModules++;
if (activeTest is null)
{
TestDetailState? active = item.TestNodeResultsState?.GetSingleActiveOrSummaryTask();
Expand All @@ -121,7 +150,14 @@ private void EmitSilenceHeartbeat(ITerminal terminal, TestProgressState?[] progr
}
}

string line = string.Format(CultureInfo.CurrentCulture, TerminalResources.TerminalProgressHeartbeat, completed, failed);
string line = string.Format(CultureInfo.CurrentCulture, TerminalResources.TerminalProgressHeartbeat, completed, failed, activeModules);
Comment thread
Evangelink marked this conversation as resolved.
Resolved
long lastCompletion = Interlocked.Read(ref _lastCompletionTicks);
line += lastCompletion < 0
? TerminalResources.TerminalProgressHeartbeatNoCompletionSuffix
: string.Format(
CultureInfo.CurrentCulture,
TerminalResources.TerminalProgressHeartbeatLastCompletionSuffix,
HumanReadableDurationFormatter.Render(TimeSpan.FromTicks(Math.Max(0, now - lastCompletion)), wrapInParentheses: false));
Comment thread
Evangelink marked this conversation as resolved.
Resolved
if (activeTest is not null)
{
line += string.Format(CultureInfo.CurrentCulture, TerminalResources.TerminalProgressHeartbeatActiveSuffix, activeTest);
Expand Down Expand Up @@ -175,6 +211,7 @@ private void EmitSlowTests(ITerminal terminal, TestProgressState?[] progressItem
// tick (GC pause, debugger break, CPU starvation) does not under-report the runtime.
string duration = HumanReadableDurationFormatter.Render(elapsed, wrapInParentheses: false);
terminal.AppendLine(string.Format(CultureInfo.CurrentCulture, TerminalResources.TerminalProgressSlowTest, duration, BuildSlowTestDescription(item, detail)));
_lastVisibleOutputTicks = NowTicks;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ internal static partial class TerminalResources

internal static string @TerminalProgressHeartbeatActiveSuffix => GetResourceString("TerminalProgressHeartbeatActiveSuffix");

internal static string @TerminalProgressHeartbeatLastCompletionSuffix => GetResourceString("TerminalProgressHeartbeatLastCompletionSuffix");

internal static string @TerminalProgressHeartbeatNoCompletionSuffix => GetResourceString("TerminalProgressHeartbeatNoCompletionSuffix");

internal static string @TerminalProgressOptionDescription => GetResourceString("TerminalProgressOptionDescription");

internal static string @TerminalProgressOptionInvalidArgument => GetResourceString("TerminalProgressOptionInvalidArgument");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,15 @@ This option takes precedence over the deprecated --no-progress flag.</value>
<comment>{Locked="--progress"}{Locked="auto"}{Locked="on"}{Locked="true"}{Locked="enable"}{Locked="1"}{Locked="off"}{Locked="false"}{Locked="disable"}{Locked="0"}</comment>
</data>
<data name="TerminalProgressHeartbeat" xml:space="preserve">
<value>running... {0} completed, {1} failed</value>
<comment>Heartbeat line emitted on non-cursor terminals when the run goes silent. {0} is the number of completed tests, {1} is the number of failed tests.</comment>
<value>running... {0} completed, {1} failed, active modules: {2}</value>
<comment>Progress line emitted after visible-output silence on non-cursor terminals. {0} is the cumulative number of completed tests, {1} is the number of failed tests, {2} is the number of active test modules.</comment>
</data>
<data name="TerminalProgressHeartbeatLastCompletionSuffix" xml:space="preserve">
<value> | last completion: {0} ago</value>
<comment>Suffix for a progress line. {0} is the elapsed duration since the last test completion, not since the last progress line.</comment>
</data>
<data name="TerminalProgressHeartbeatNoCompletionSuffix" xml:space="preserve">
<value> | no tests completed yet</value>
</data>
<data name="TerminalProgressHeartbeatActiveSuffix" xml:space="preserve">
<value> | active: {0}</value>
Expand Down
Loading
Loading