diff --git a/src/Platform/Microsoft.Testing.Platform/CommandLine/AutoOnOff.cs b/src/Platform/Microsoft.Testing.Platform/CommandLine/AutoOnOff.cs
new file mode 100644
index 0000000000..e1a868d7d2
--- /dev/null
+++ b/src/Platform/Microsoft.Testing.Platform/CommandLine/AutoOnOff.cs
@@ -0,0 +1,25 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+namespace Microsoft.Testing.Platform.CommandLine;
+
+///
+/// Specifies the activation mode for command line options that support auto-detection or explicit on/off states.
+///
+internal enum AutoOnOff
+{
+ ///
+ /// Auto-detect the appropriate setting.
+ ///
+ Auto,
+
+ ///
+ /// Force enable the option.
+ ///
+ On,
+
+ ///
+ /// Force disable the option.
+ ///
+ Off,
+}
diff --git a/src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineOptionArgumentValidator.cs b/src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineOptionArgumentValidator.cs
new file mode 100644
index 0000000000..ced2ce745a
--- /dev/null
+++ b/src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineOptionArgumentValidator.cs
@@ -0,0 +1,84 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+namespace Microsoft.Testing.Platform.CommandLine;
+
+///
+/// Provides validation helpers for command line option arguments.
+///
+internal static class CommandLineOptionArgumentValidator
+{
+ private static readonly string[] DefaultOnValues = ["on", "true", "enable", "1"];
+ private static readonly string[] DefaultOffValues = ["off", "false", "disable", "0"];
+
+ ///
+ /// Validates that an argument is one of the accepted on/off boolean values.
+ ///
+ /// The argument to validate.
+ /// True if the argument is valid; otherwise, false.
+ public static bool IsValidBooleanArgument(string argument)
+ {
+ foreach (string onValue in DefaultOnValues)
+ {
+ if (onValue.Equals(argument, StringComparison.OrdinalIgnoreCase))
+ {
+ return true;
+ }
+ }
+
+ foreach (string offValue in DefaultOffValues)
+ {
+ if (offValue.Equals(argument, StringComparison.OrdinalIgnoreCase))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ ///
+ /// Validates that an argument is one of the accepted on/off/auto values.
+ ///
+ /// The argument to validate.
+ /// True if the argument is valid; otherwise, false.
+ public static bool IsValidBooleanAutoArgument(string argument)
+ => "auto".Equals(argument, StringComparison.OrdinalIgnoreCase)
+ || IsValidBooleanArgument(argument);
+
+ ///
+ /// Determines if an argument represents an "on/enabled" state.
+ ///
+ /// The argument to check.
+ /// True if the argument represents an enabled state; otherwise, false.
+ public static bool IsOnValue(string argument)
+ {
+ foreach (string onValue in DefaultOnValues)
+ {
+ if (onValue.Equals(argument, StringComparison.OrdinalIgnoreCase))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ ///
+ /// Determines if an argument represents an "off/disabled" state.
+ ///
+ /// The argument to check.
+ /// True if the argument represents a disabled state; otherwise, false.
+ public static bool IsOffValue(string argument)
+ {
+ foreach (string offValue in DefaultOffValues)
+ {
+ if (offValue.Equals(argument, StringComparison.OrdinalIgnoreCase))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
diff --git a/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporter.cs b/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporter.cs
index 5bc0b16a85..b0e8593743 100644
--- a/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporter.cs
+++ b/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporter.cs
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+using Microsoft.Testing.Platform.CommandLine;
using Microsoft.Testing.Platform.Helpers;
using Microsoft.Testing.Platform.Resources;
using Microsoft.Testing.Platform.Services;
@@ -86,36 +87,30 @@ public TerminalTestReporter(
_testApplicationCancellationTokenSource = testApplicationCancellationTokenSource;
_options = options;
- Func showProgress = _options.ShowProgress;
- TestProgressStateAwareTerminal terminalWithProgress;
-
// When not writing to ANSI we write the progress to screen and leave it there so we don't want to write it more often than every few seconds.
int nonAnsiUpdateCadenceInMs = 3_000;
// When writing to ANSI we update the progress in place and it should look responsive so we update every half second, because we only show seconds on the screen, so it is good enough.
int ansiUpdateCadenceInMs = 500;
- if (!_options.UseAnsi || _options.ForceAnsi is false)
- {
- terminalWithProgress = new TestProgressStateAwareTerminal(new NonAnsiTerminal(console), showProgress, writeProgressImmediatelyAfterOutput: false, updateEvery: nonAnsiUpdateCadenceInMs);
- }
- else
+
+ (_terminalWithProgress, _originalConsoleMode) = _options.AnsiMode switch
{
- if (_options.UseCIAnsi)
- {
- // We are told externally that we are in CI, use simplified ANSI mode.
- terminalWithProgress = new TestProgressStateAwareTerminal(new SimpleAnsiTerminal(console), showProgress, writeProgressImmediatelyAfterOutput: true, updateEvery: nonAnsiUpdateCadenceInMs);
- }
- else
- {
- // We are not in CI, or in CI non-compatible with simple ANSI, autodetect terminal capabilities
- (bool consoleAcceptsAnsiCodes, bool _, uint? originalConsoleMode) = NativeMethods.QueryIsScreenAndTryEnableAnsiColorCodes();
- _originalConsoleMode = originalConsoleMode;
- terminalWithProgress = consoleAcceptsAnsiCodes || _options.ForceAnsi is true
- ? new TestProgressStateAwareTerminal(new AnsiTerminal(console), showProgress, writeProgressImmediatelyAfterOutput: true, updateEvery: ansiUpdateCadenceInMs)
- : new TestProgressStateAwareTerminal(new NonAnsiTerminal(console), showProgress, writeProgressImmediatelyAfterOutput: false, updateEvery: nonAnsiUpdateCadenceInMs);
- }
- }
+ AutoOnOff.Off => (new TestProgressStateAwareTerminal(new NonAnsiTerminal(console), _options.ShowProgress, writeProgressImmediatelyAfterOutput: false, updateEvery: nonAnsiUpdateCadenceInMs), null),
+ AutoOnOff.On => _options.UseCIAnsi
+ ? (new TestProgressStateAwareTerminal(new SimpleAnsiTerminal(console), _options.ShowProgress, writeProgressImmediatelyAfterOutput: true, updateEvery: nonAnsiUpdateCadenceInMs), null)
+ : (new TestProgressStateAwareTerminal(new AnsiTerminal(console), _options.ShowProgress, writeProgressImmediatelyAfterOutput: true, updateEvery: ansiUpdateCadenceInMs), null),
+ AutoOnOff.Auto => AutoDetectTerminal(console, _options.ShowProgress, nonAnsiUpdateCadenceInMs, ansiUpdateCadenceInMs),
+ _ => throw new NotSupportedException("Unsupported ANSI mode: " + _options.AnsiMode),
+ };
+ }
- _terminalWithProgress = terminalWithProgress;
+ private static (TestProgressStateAwareTerminal Terminal, uint? OriginalConsoleMode) AutoDetectTerminal(IConsole console, Func showProgress, int nonAnsiUpdateCadenceInMs, int ansiUpdateCadenceInMs)
+ {
+ // We are not in CI, or in CI non-compatible with simple ANSI, autodetect terminal capabilities
+ (bool consoleAcceptsAnsiCodes, bool _, uint? originalConsoleMode) = NativeMethods.QueryIsScreenAndTryEnableAnsiColorCodes();
+ TestProgressStateAwareTerminal terminalWithProgress = consoleAcceptsAnsiCodes
+ ? new TestProgressStateAwareTerminal(new AnsiTerminal(console), showProgress, writeProgressImmediatelyAfterOutput: true, updateEvery: ansiUpdateCadenceInMs)
+ : new TestProgressStateAwareTerminal(new NonAnsiTerminal(console), showProgress, writeProgressImmediatelyAfterOutput: false, updateEvery: nonAnsiUpdateCadenceInMs);
+ return (terminalWithProgress, originalConsoleMode);
}
public void TestExecutionStarted(DateTimeOffset testStartTime, int workerCount, bool isDiscovery)
diff --git a/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporterCommandLineOptionsProvider.cs b/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporterCommandLineOptionsProvider.cs
index 5de9570121..6374d792ad 100644
--- a/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporterCommandLineOptionsProvider.cs
+++ b/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporterCommandLineOptionsProvider.cs
@@ -13,6 +13,7 @@ internal sealed class TerminalTestReporterCommandLineOptionsProvider : ICommandL
{
public const string NoProgressOption = "no-progress";
public const string NoAnsiOption = "no-ansi";
+ public const string AnsiOption = "ansi";
public const string OutputOption = "output";
public const string OutputOptionNormalArgument = "normal";
public const string OutputOptionDetailedArgument = "detailed";
@@ -36,7 +37,8 @@ public IReadOnlyCollection GetCommandLineOptions()
=>
[
new(NoProgressOption, PlatformResources.TerminalNoProgressOptionDescription, ArgumentArity.Zero, isHidden: false),
- new(NoAnsiOption, PlatformResources.TerminalNoAnsiOptionDescription, ArgumentArity.Zero, isHidden: false),
+ new(NoAnsiOption, PlatformResources.TerminalNoAnsiOptionDescription, ArgumentArity.Zero, isHidden: false, PlatformResources.TerminalNoAnsiOptionObsoleteMessage),
+ new(AnsiOption, PlatformResources.TerminalAnsiOptionDescription, ArgumentArity.ExactlyOne, isHidden: false),
new(OutputOption, PlatformResources.TerminalOutputOptionDescription, ArgumentArity.ExactlyOne, isHidden: false),
];
@@ -45,6 +47,9 @@ public Task ValidateOptionArgumentsAsync(CommandLineOption com
{
NoProgressOption => ValidationResult.ValidTask,
NoAnsiOption => ValidationResult.ValidTask,
+ AnsiOption => CommandLineOptionArgumentValidator.IsValidBooleanAutoArgument(arguments[0])
+ ? ValidationResult.ValidTask
+ : ValidationResult.InvalidTask(PlatformResources.TerminalAnsiOptionInvalidArgument),
OutputOption => OutputOptionNormalArgument.Equals(arguments[0], StringComparison.OrdinalIgnoreCase) || OutputOptionDetailedArgument.Equals(arguments[0], StringComparison.OrdinalIgnoreCase)
? ValidationResult.ValidTask
: ValidationResult.InvalidTask(PlatformResources.TerminalOutputOptionInvalidArgument),
diff --git a/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporterOptions.cs b/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporterOptions.cs
index b738158389..295ff600d2 100644
--- a/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporterOptions.cs
+++ b/src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporterOptions.cs
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+using Microsoft.Testing.Platform.CommandLine;
+
namespace Microsoft.Testing.Platform.OutputDevice.Terminal;
internal sealed class TerminalTestReporterOptions
@@ -27,19 +29,14 @@ internal sealed class TerminalTestReporterOptions
///
public bool ShowActiveTests { get; init; }
- ///
- /// Gets a value indicating whether we should use ANSI escape codes or disable them. When true the capabilities of the console are autodetected.
- ///
- public bool UseAnsi { get; init; }
-
///
/// Gets a value indicating whether we are running in compatible CI, and should use simplified ANSI renderer, which colors output, but does not move cursor.
- /// Setting to false will disable this option.
+ /// Setting to will disable this option.
///
public bool UseCIAnsi { get; init; }
///
- /// Gets a value indicating whether we should force ANSI escape codes. When true the ANSI is used without auto-detecting capabilities of the console. This is needed only for testing.
+ /// Gets the ANSI mode for the terminal output.
///
- internal /* for testing */ bool? ForceAnsi { get; init; }
+ public AutoOnOff AnsiMode { get; init; } = AutoOnOff.Auto;
}
diff --git a/src/Platform/Microsoft.Testing.Platform/OutputDevice/TerminalOutputDevice.cs b/src/Platform/Microsoft.Testing.Platform/OutputDevice/TerminalOutputDevice.cs
index eeca27f3b9..b29ec0e607 100644
--- a/src/Platform/Microsoft.Testing.Platform/OutputDevice/TerminalOutputDevice.cs
+++ b/src/Platform/Microsoft.Testing.Platform/OutputDevice/TerminalOutputDevice.cs
@@ -121,7 +121,39 @@ await _policiesService.RegisterOnAbortCallbackAsync(
_isListTests = _commandLineOptions.IsOptionSet(PlatformCommandLineProvider.DiscoverTestsOptionKey);
_isServerMode = _commandLineOptions.IsOptionSet(PlatformCommandLineProvider.ServerOptionKey);
- bool noAnsi = _commandLineOptions.IsOptionSet(TerminalTestReporterCommandLineOptionsProvider.NoAnsiOption);
+
+ // Determine ANSI output setting
+ AutoOnOff ansiMode;
+ if (_commandLineOptions.TryGetOptionArgumentList(TerminalTestReporterCommandLineOptionsProvider.AnsiOption, out string[]? ansiArguments) && ansiArguments?.Length > 0)
+ {
+ // New --ansi option takes precedence
+ string ansiValue = ansiArguments[0];
+ if (CommandLineOptionArgumentValidator.IsOnValue(ansiValue))
+ {
+ // Force enable ANSI
+ ansiMode = AutoOnOff.On;
+ }
+ else if (CommandLineOptionArgumentValidator.IsOffValue(ansiValue))
+ {
+ // Force disable ANSI
+ ansiMode = AutoOnOff.Off;
+ }
+ else
+ {
+ // Auto mode - detect capabilities
+ ansiMode = AutoOnOff.Auto;
+ }
+ }
+ else if (_commandLineOptions.IsOptionSet(TerminalTestReporterCommandLineOptionsProvider.NoAnsiOption))
+ {
+ // Backward compatibility with --no-ansi
+ ansiMode = AutoOnOff.Off;
+ }
+ else
+ {
+ // Default is auto mode - detect capabilities
+ ansiMode = AutoOnOff.Auto;
+ }
// TODO: Replace this with proper CI detection that we already have in telemetry. https://github.com/microsoft/testfx/issues/5533#issuecomment-2838893327
bool inCI = string.Equals(_environment.GetEnvironmentVariable("TF_BUILD"), "true", StringComparison.OrdinalIgnoreCase) || string.Equals(_environment.GetEnvironmentVariable("GITHUB_ACTIONS"), "true", StringComparison.OrdinalIgnoreCase);
@@ -158,7 +190,7 @@ await _policiesService.RegisterOnAbortCallbackAsync(
{
ShowPassedTests = showPassed,
MinimumExpectedTests = PlatformCommandLineProvider.GetMinimumExpectedTests(_commandLineOptions),
- UseAnsi = !noAnsi,
+ AnsiMode = ansiMode,
UseCIAnsi = inCI,
ShowActiveTests = true,
ShowProgress = shouldShowProgress,
diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.resx b/src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.resx
index 5236750662..a716dae33d 100644
--- a/src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.resx
+++ b/src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.resx
@@ -599,6 +599,18 @@ Read more about Microsoft Testing Platform telemetry: https://aka.ms/testingplat
Disable outputting ANSI escape characters to screen.
+
+ Use '--ansi off' instead of '--no-ansi'.
+
+
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+
+
+ --ansi expects a single parameter with value 'auto', 'on', or 'off' (also accepts 'true', 'enable', '1', 'false', 'disable', '0').
+
Disable reporting progress to screen.
diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.cs.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.cs.xlf
index ae087ff8b0..9c4fff9024 100644
--- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.cs.xlf
+++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.cs.xlf
@@ -808,11 +808,32 @@ Přečtěte si další informace o telemetrii Microsoft Testing Platform: https:
Zprostředkovatel telemetrie je už nastavený.
+
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+
+
+
+ --ansi expects a single parameter with value 'auto', 'on', or 'off' (also accepts 'true', 'enable', '1', 'false', 'disable', '0').
+ --ansi expects a single parameter with value 'auto', 'on', or 'off' (also accepts 'true', 'enable', '1', 'false', 'disable', '0').
+
+
Disable outputting ANSI escape characters to screen.
Zakažte výstup řídicích znaků ANSI na obrazovku.
+
+ Use '--ansi off' instead of '--no-ansi'.
+ Use '--ansi off' instead of '--no-ansi'.
+
+
Disable reporting progress to screen.
Zakažte zobrazování průběhu vytváření sestav na obrazovce.
diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.de.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.de.xlf
index 40b45cfed1..6d15a33ac0 100644
--- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.de.xlf
+++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.de.xlf
@@ -808,11 +808,32 @@ Weitere Informationen zu Microsoft Testing Platform-Telemetriedaten: https://aka
Der Telemetrieanbieter ist bereits festgelegt
+
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+
+
+
+ --ansi expects a single parameter with value 'auto', 'on', or 'off' (also accepts 'true', 'enable', '1', 'false', 'disable', '0').
+ --ansi expects a single parameter with value 'auto', 'on', or 'off' (also accepts 'true', 'enable', '1', 'false', 'disable', '0').
+
+
Disable outputting ANSI escape characters to screen.
Deaktivieren Sie die Ausgabe von ANSI-Escape-Zeichen auf dem Bildschirm.
+
+ Use '--ansi off' instead of '--no-ansi'.
+ Use '--ansi off' instead of '--no-ansi'.
+
+
Disable reporting progress to screen.
Deaktivieren Sie die Berichterstellung für den Status des Bildschirms.
diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.es.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.es.xlf
index 7318e03aca..b4c820d13c 100644
--- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.es.xlf
+++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.es.xlf
@@ -808,11 +808,32 @@ Más información sobre la telemetría de la Plataforma de pruebas de Microsoft:
El proveedor de telemetría ya está establecido
+
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+
+
+
+ --ansi expects a single parameter with value 'auto', 'on', or 'off' (also accepts 'true', 'enable', '1', 'false', 'disable', '0').
+ --ansi expects a single parameter with value 'auto', 'on', or 'off' (also accepts 'true', 'enable', '1', 'false', 'disable', '0').
+
+
Disable outputting ANSI escape characters to screen.
Deshabilite la salida de caracteres de escape ANSI en la pantalla.
+
+ Use '--ansi off' instead of '--no-ansi'.
+ Use '--ansi off' instead of '--no-ansi'.
+
+
Disable reporting progress to screen.
Deshabilite el progreso de los informes en la pantalla.
diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.fr.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.fr.xlf
index b6de632232..2c656a5202 100644
--- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.fr.xlf
+++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.fr.xlf
@@ -808,11 +808,32 @@ En savoir plus sur la télémétrie de la plateforme de tests Microsoft : https:
Le fournisseur de télémétrie est déjà défini
+
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+
+
+
+ --ansi expects a single parameter with value 'auto', 'on', or 'off' (also accepts 'true', 'enable', '1', 'false', 'disable', '0').
+ --ansi expects a single parameter with value 'auto', 'on', or 'off' (also accepts 'true', 'enable', '1', 'false', 'disable', '0').
+
+
Disable outputting ANSI escape characters to screen.
Désactiver la sortie des caractères d’échappement ANSI à l’écran.
+
+ Use '--ansi off' instead of '--no-ansi'.
+ Use '--ansi off' instead of '--no-ansi'.
+
+
Disable reporting progress to screen.
Désactiver la progression des rapports à l’écran.
diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.it.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.it.xlf
index 39c570328c..cccf3cf971 100644
--- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.it.xlf
+++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.it.xlf
@@ -808,11 +808,32 @@ Altre informazioni sulla telemetria della piattaforma di test Microsoft: https:/
Il provider di telemetria è già impostato
+
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+
+
+
+ --ansi expects a single parameter with value 'auto', 'on', or 'off' (also accepts 'true', 'enable', '1', 'false', 'disable', '0').
+ --ansi expects a single parameter with value 'auto', 'on', or 'off' (also accepts 'true', 'enable', '1', 'false', 'disable', '0').
+
+
Disable outputting ANSI escape characters to screen.
Disabilita l'output dei caratteri di escape ANSI sullo schermo.
+
+ Use '--ansi off' instead of '--no-ansi'.
+ Use '--ansi off' instead of '--no-ansi'.
+
+
Disable reporting progress to screen.
Disabilita la segnalazione dello stato sullo schermo.
diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ja.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ja.xlf
index 75b241626a..a033a7179f 100644
--- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ja.xlf
+++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ja.xlf
@@ -809,11 +809,32 @@ Microsoft Testing Platform テレメトリの詳細: https://aka.ms/testingplatf
テレメトリ プロバイダーは既に設定されています
+
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+
+
+
+ --ansi expects a single parameter with value 'auto', 'on', or 'off' (also accepts 'true', 'enable', '1', 'false', 'disable', '0').
+ --ansi expects a single parameter with value 'auto', 'on', or 'off' (also accepts 'true', 'enable', '1', 'false', 'disable', '0').
+
+
Disable outputting ANSI escape characters to screen.
画面への ANSI エスケープ文字の出力を無効にします。
+
+ Use '--ansi off' instead of '--no-ansi'.
+ Use '--ansi off' instead of '--no-ansi'.
+
+
Disable reporting progress to screen.
画面への進行状況の報告を無効にします。
diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ko.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ko.xlf
index 01a43b26ed..75388b68e1 100644
--- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ko.xlf
+++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ko.xlf
@@ -808,11 +808,32 @@ Microsoft 테스트 플랫폼 원격 분석에 대해 자세히 알아보기: ht
원격 분석 공급자가 이미 설정되어 있습니다.
+
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+
+
+
+ --ansi expects a single parameter with value 'auto', 'on', or 'off' (also accepts 'true', 'enable', '1', 'false', 'disable', '0').
+ --ansi expects a single parameter with value 'auto', 'on', or 'off' (also accepts 'true', 'enable', '1', 'false', 'disable', '0').
+
+
Disable outputting ANSI escape characters to screen.
ANSI 이스케이프 문자를 화면에 출력하지 않도록 설정합니다.
+
+ Use '--ansi off' instead of '--no-ansi'.
+ Use '--ansi off' instead of '--no-ansi'.
+
+
Disable reporting progress to screen.
화면에 보고 진행률을 사용하지 않도록 설정합니다.
diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pl.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pl.xlf
index a11d897e2d..4e6ccdcdc1 100644
--- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pl.xlf
+++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pl.xlf
@@ -808,11 +808,32 @@ Więcej informacji o telemetrii platformy testowej firmy Microsoft: https://aka.
Dostawca telemetrii jest już ustawiony
+
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+
+
+
+ --ansi expects a single parameter with value 'auto', 'on', or 'off' (also accepts 'true', 'enable', '1', 'false', 'disable', '0').
+ --ansi expects a single parameter with value 'auto', 'on', or 'off' (also accepts 'true', 'enable', '1', 'false', 'disable', '0').
+
+
Disable outputting ANSI escape characters to screen.
Wyłącz wyprowadzanie znaków ucieczki ANSI na ekran.
+
+ Use '--ansi off' instead of '--no-ansi'.
+ Use '--ansi off' instead of '--no-ansi'.
+
+
Disable reporting progress to screen.
Wyłącz raportowanie postępu na ekranie.
diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pt-BR.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pt-BR.xlf
index 397143f683..0fa07a638b 100644
--- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pt-BR.xlf
+++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.pt-BR.xlf
@@ -808,11 +808,32 @@ Leia mais sobre a telemetria da Plataforma de Testes da Microsoft: https://aka.m
O provedor de telemetria já está definido
+
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+
+
+
+ --ansi expects a single parameter with value 'auto', 'on', or 'off' (also accepts 'true', 'enable', '1', 'false', 'disable', '0').
+ --ansi expects a single parameter with value 'auto', 'on', or 'off' (also accepts 'true', 'enable', '1', 'false', 'disable', '0').
+
+
Disable outputting ANSI escape characters to screen.
Desabilite a saída de caracteres de escape ANSI para a tela.
+
+ Use '--ansi off' instead of '--no-ansi'.
+ Use '--ansi off' instead of '--no-ansi'.
+
+
Disable reporting progress to screen.
Desabilite o progresso do relatório na tela.
diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ru.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ru.xlf
index a84666861a..ab1ba604ef 100644
--- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ru.xlf
+++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ru.xlf
@@ -808,11 +808,32 @@ Read more about Microsoft Testing Platform telemetry: https://aka.ms/testingplat
Поставщик телеметрии уже настроен
+
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+
+
+
+ --ansi expects a single parameter with value 'auto', 'on', or 'off' (also accepts 'true', 'enable', '1', 'false', 'disable', '0').
+ --ansi expects a single parameter with value 'auto', 'on', or 'off' (also accepts 'true', 'enable', '1', 'false', 'disable', '0').
+
+
Disable outputting ANSI escape characters to screen.
Отключить вывод escape-символов ANSI на экран.
+
+ Use '--ansi off' instead of '--no-ansi'.
+ Use '--ansi off' instead of '--no-ansi'.
+
+
Disable reporting progress to screen.
Отключить отчеты о ходе выполнения на экране.
diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.tr.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.tr.xlf
index 5249ba9270..5c5618398f 100644
--- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.tr.xlf
+++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.tr.xlf
@@ -808,11 +808,32 @@ Microsoft Test Platformu telemetrisi hakkında daha fazla bilgi edinin: https://
Telemetri sağlayıcısı zaten ayarlanmış
+
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+
+
+
+ --ansi expects a single parameter with value 'auto', 'on', or 'off' (also accepts 'true', 'enable', '1', 'false', 'disable', '0').
+ --ansi expects a single parameter with value 'auto', 'on', or 'off' (also accepts 'true', 'enable', '1', 'false', 'disable', '0').
+
+
Disable outputting ANSI escape characters to screen.
ANSI kaçış karakterlerinin ekrana çıkışını devre dışı bırakın.
+
+ Use '--ansi off' instead of '--no-ansi'.
+ Use '--ansi off' instead of '--no-ansi'.
+
+
Disable reporting progress to screen.
Ekrana yansıtılan ilerleme durumu raporlamasını devre dışı bırakın.
diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hans.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hans.xlf
index 8e7289310a..4f86b59515 100644
--- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hans.xlf
+++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hans.xlf
@@ -808,11 +808,32 @@ Microsoft 测试平台会收集使用数据,帮助我们改善体验。该数
已设置遥测提供程序
+
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+
+
+
+ --ansi expects a single parameter with value 'auto', 'on', or 'off' (also accepts 'true', 'enable', '1', 'false', 'disable', '0').
+ --ansi expects a single parameter with value 'auto', 'on', or 'off' (also accepts 'true', 'enable', '1', 'false', 'disable', '0').
+
+
Disable outputting ANSI escape characters to screen.
禁用将 ANSI 转义字符输出到屏幕。
+
+ Use '--ansi off' instead of '--no-ansi'.
+ Use '--ansi off' instead of '--no-ansi'.
+
+
Disable reporting progress to screen.
禁用向屏幕报告进度。
diff --git a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hant.xlf b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hant.xlf
index 569661be1c..4a316c94c0 100644
--- a/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hant.xlf
+++ b/src/Platform/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.zh-Hant.xlf
@@ -1,4 +1,4 @@
-
+
@@ -808,11 +808,32 @@ Microsoft 測試平台會收集使用量資料,以協助我們改善您的體
遙測提供者已設定
+
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+
+
+
+ --ansi expects a single parameter with value 'auto', 'on', or 'off' (also accepts 'true', 'enable', '1', 'false', 'disable', '0').
+ --ansi expects a single parameter with value 'auto', 'on', or 'off' (also accepts 'true', 'enable', '1', 'false', 'disable', '0').
+
+
Disable outputting ANSI escape characters to screen.
停用將 ANSI 逸出字元輸出至螢幕。
+
+ Use '--ansi off' instead of '--no-ansi'.
+ Use '--ansi off' instead of '--no-ansi'.
+
+
Disable reporting progress to screen.
停用向螢幕報告進度。
diff --git a/test/IntegrationTests/MSTest.Acceptance.IntegrationTests/HelpInfoTests.cs b/test/IntegrationTests/MSTest.Acceptance.IntegrationTests/HelpInfoTests.cs
index e87af996ef..bbe81c3164 100644
--- a/test/IntegrationTests/MSTest.Acceptance.IntegrationTests/HelpInfoTests.cs
+++ b/test/IntegrationTests/MSTest.Acceptance.IntegrationTests/HelpInfoTests.cs
@@ -68,12 +68,18 @@ The directory where the test results are going to be placed.
A global test execution timeout.
Takes one argument as string in the format [h|m|s] where 'value' is float.
Extension options:
+ --ansi
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
--filter
Filters tests using the given expression. For more information, see the Filter option details section. For more information and examples on how to use selective unit test filtering, see https://learn.microsoft.com/dotnet/core/testing/selective-unit-tests.
--maximum-failed-tests
Specifies a maximum number of test failures that, when exceeded, will abort the test run.
- --no-ansi
+ --no-ansi [obsolete]
Disable outputting ANSI escape characters to screen.
+ Obsolete: Use '--ansi off' instead of '--no-ansi'.
--no-progress
Disable reporting progress to screen.
--output
diff --git a/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoTests.cs b/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoTests.cs
index 853dc3b640..32cd2a3194 100644
--- a/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoTests.cs
+++ b/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoTests.cs
@@ -62,8 +62,14 @@ The directory where the test results are going to be placed.
A global test execution timeout.
Takes one argument as string in the format [h|m|s] where 'value' is float.
Extension options:
- --no-ansi
+ --ansi
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+ --no-ansi [obsolete]
Disable outputting ANSI escape characters to screen.
+ Obsolete: Use '--ansi off' instead of '--no-ansi'.
--no-progress
Disable reporting progress to screen.
--output
@@ -249,19 +255,27 @@ Takes one argument as string in the format \[h\|m\|s\] where 'value' is f
Version: .+
Description: Writes test results to terminal.
Options:
- --no-ansi
+ --ansi
+ Arity: 1
+ Hidden: False
+ Description: Control ANSI escape characters output\.
+ --ansi auto - Auto-detect terminal capabilities \(default\)
+ --ansi on\|true\|enable\|1 - Force enable ANSI escape sequences
+ --ansi off\|false\|disable\|0 - Force disable ANSI escape sequences
+ --no-ansi \[obsolete\]
Arity: 0
Hidden: False
- Description: Disable outputting ANSI escape characters to screen.
+ Description: Disable outputting ANSI escape characters to screen\.
+ Obsolete: Use '--ansi off' instead of '--no-ansi'\.
--no-progress
Arity: 0
Hidden: False
- Description: Disable reporting progress to screen.
+ Description: Disable reporting progress to screen\.
--output
Arity: 1
Hidden: False
- Description: Output verbosity when reporting tests.
- Valid values are 'Normal', 'Detailed'. Default is 'Normal'.
+ Description: Output verbosity when reporting tests\.
+ Valid values are 'Normal', 'Detailed'. Default is 'Normal'\.
Registered tools:
There are no registered tools\.
""";
@@ -331,6 +345,11 @@ Retry failed tests the given number of times
A global test execution timeout.
Takes one argument as string in the format [h|m|s] where 'value' is float.
Extension options:
+ --ansi
+ Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
--crashdump
[net6.0+ only] Generate a dump file if the test process crashes
--crashdump-filename
@@ -354,8 +373,9 @@ Default is 30m.
Specify the type of the dump.
Valid values are 'Mini', 'Heap', 'Triage' (only available in .NET 6+) or 'Full'.
Default type is 'Full'
- --no-ansi
+ --no-ansi [obsolete]
Disable outputting ANSI escape characters to screen.
+ Obsolete: Use '--ansi off' instead of '--no-ansi'.
--no-progress
Disable reporting progress to screen.
--output
@@ -600,10 +620,18 @@ Default type is 'Full'
Version: *
Description: Writes test results to terminal.
Options:
- --no-ansi
+ --ansi
+ Arity: 1
+ Hidden: False
+ Description: Control ANSI escape characters output.
+ --ansi auto - Auto-detect terminal capabilities (default)
+ --ansi on|true|enable|1 - Force enable ANSI escape sequences
+ --ansi off|false|disable|0 - Force disable ANSI escape sequences
+ --no-ansi [obsolete]
Arity: 0
Hidden: False
Description: Disable outputting ANSI escape characters to screen.
+ Obsolete: Use '--ansi off' instead of '--no-ansi'.
--no-progress
Arity: 0
Hidden: False
diff --git a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterCommandLineOptionsProviderTests.cs b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterCommandLineOptionsProviderTests.cs
new file mode 100644
index 0000000000..6b798a939a
--- /dev/null
+++ b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterCommandLineOptionsProviderTests.cs
@@ -0,0 +1,92 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using Microsoft.Testing.Platform.Extensions.CommandLine;
+using Microsoft.Testing.Platform.OutputDevice.Terminal;
+using Microsoft.Testing.Platform.Resources;
+
+namespace Microsoft.Testing.Platform.UnitTests.OutputDevice.Terminal;
+
+[TestClass]
+public sealed class TerminalTestReporterCommandLineOptionsProviderTests
+{
+ [TestMethod]
+ [DataRow("auto")]
+ [DataRow("on")]
+ [DataRow("true")]
+ [DataRow("enable")]
+ [DataRow("1")]
+ [DataRow("off")]
+ [DataRow("false")]
+ [DataRow("disable")]
+ [DataRow("0")]
+ public async Task IsValid_If_Ansi_Has_CorrectValue(string ansiValue)
+ {
+ var provider = new TerminalTestReporterCommandLineOptionsProvider();
+ CommandLineOption option = provider.GetCommandLineOptions().First(x => x.Name == TerminalTestReporterCommandLineOptionsProvider.AnsiOption);
+
+ ValidationResult validateOptionsResult = await provider.ValidateOptionArgumentsAsync(option, [ansiValue]).ConfigureAwait(false);
+ Assert.IsTrue(validateOptionsResult.IsValid);
+ Assert.IsTrue(string.IsNullOrEmpty(validateOptionsResult.ErrorMessage));
+ }
+
+ [TestMethod]
+ [DataRow("AUTO")]
+ [DataRow("On")]
+ [DataRow("TRUE")]
+ [DataRow("Enable")]
+ [DataRow("OFF")]
+ [DataRow("False")]
+ [DataRow("DISABLE")]
+ public async Task IsValid_If_Ansi_Has_CorrectValue_CaseInsensitive(string ansiValue)
+ {
+ var provider = new TerminalTestReporterCommandLineOptionsProvider();
+ CommandLineOption option = provider.GetCommandLineOptions().First(x => x.Name == TerminalTestReporterCommandLineOptionsProvider.AnsiOption);
+
+ ValidationResult validateOptionsResult = await provider.ValidateOptionArgumentsAsync(option, [ansiValue]).ConfigureAwait(false);
+ Assert.IsTrue(validateOptionsResult.IsValid);
+ Assert.IsTrue(string.IsNullOrEmpty(validateOptionsResult.ErrorMessage));
+ }
+
+ [TestMethod]
+ [DataRow("invalid")]
+ [DataRow("yes")]
+ [DataRow("no")]
+ [DataRow("2")]
+ [DataRow("")]
+ public async Task IsInvalid_If_Ansi_Has_IncorrectValue(string ansiValue)
+ {
+ var provider = new TerminalTestReporterCommandLineOptionsProvider();
+ CommandLineOption option = provider.GetCommandLineOptions().First(x => x.Name == TerminalTestReporterCommandLineOptionsProvider.AnsiOption);
+
+ ValidationResult validateOptionsResult = await provider.ValidateOptionArgumentsAsync(option, [ansiValue]).ConfigureAwait(false);
+ Assert.IsFalse(validateOptionsResult.IsValid);
+ Assert.AreEqual(PlatformResources.TerminalAnsiOptionInvalidArgument, validateOptionsResult.ErrorMessage);
+ }
+
+ [TestMethod]
+ [DataRow("normal")]
+ [DataRow("detailed")]
+ public async Task IsValid_If_Output_Has_CorrectValue(string outputValue)
+ {
+ var provider = new TerminalTestReporterCommandLineOptionsProvider();
+ CommandLineOption option = provider.GetCommandLineOptions().First(x => x.Name == TerminalTestReporterCommandLineOptionsProvider.OutputOption);
+
+ ValidationResult validateOptionsResult = await provider.ValidateOptionArgumentsAsync(option, [outputValue]).ConfigureAwait(false);
+ Assert.IsTrue(validateOptionsResult.IsValid);
+ Assert.IsTrue(string.IsNullOrEmpty(validateOptionsResult.ErrorMessage));
+ }
+
+ [TestMethod]
+ [DataRow("invalid")]
+ [DataRow("verbose")]
+ public async Task IsInvalid_If_Output_Has_IncorrectValue(string outputValue)
+ {
+ var provider = new TerminalTestReporterCommandLineOptionsProvider();
+ CommandLineOption option = provider.GetCommandLineOptions().First(x => x.Name == TerminalTestReporterCommandLineOptionsProvider.OutputOption);
+
+ ValidationResult validateOptionsResult = await provider.ValidateOptionArgumentsAsync(option, [outputValue]).ConfigureAwait(false);
+ Assert.IsFalse(validateOptionsResult.IsValid);
+ Assert.AreEqual(PlatformResources.TerminalOutputOptionInvalidArgument, validateOptionsResult.ErrorMessage);
+ }
+}
diff --git a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs
index 19719a8d51..ef3b689550 100644
--- a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs
+++ b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+using Microsoft.Testing.Platform.CommandLine;
using Microsoft.Testing.Platform.Helpers;
using Microsoft.Testing.Platform.OutputDevice.Terminal;
using Microsoft.Testing.Platform.Services;
@@ -80,7 +81,7 @@ public void NonAnsiTerminal_OutputFormattingIsCorrect()
ShowPassedTests = () => true,
// Like --no-ansi in commandline, should disable ANSI altogether.
- UseAnsi = false,
+ AnsiMode = AutoOnOff.Off,
ShowProgress = () => false,
});
@@ -177,10 +178,8 @@ public void SimpleAnsiTerminal_OutputFormattingIsCorrect()
var terminalReporter = new TerminalTestReporter(assembly, targetFramework, architecture, stringBuilderConsole, new CTRLPlusCCancellationTokenSource(), new TerminalTestReporterOptions
{
ShowPassedTests = () => true,
- // Like if we autodetect that we are in CI (e.g. by looking at TF_BUILD, and we don't disable ANSI.
- UseAnsi = true,
UseCIAnsi = true,
- ForceAnsi = true,
+ AnsiMode = AutoOnOff.On,
ShowProgress = () => false,
});
@@ -277,10 +276,8 @@ public void AnsiTerminal_OutputFormattingIsCorrect()
var terminalReporter = new TerminalTestReporter(assembly, targetFramework, architecture, stringBuilderConsole, new CTRLPlusCCancellationTokenSource(), new TerminalTestReporterOptions
{
ShowPassedTests = () => true,
- // Like if we autodetect that we are in ANSI capable terminal.
- UseAnsi = true,
UseCIAnsi = false,
- ForceAnsi = true,
+ AnsiMode = AutoOnOff.On,
ShowProgress = () => false,
});
@@ -378,10 +375,8 @@ public void AnsiTerminal_OutputProgressFrameIsCorrect()
var terminalReporter = new TerminalTestReporter(assembly, targetFramework, architecture, stringBuilderConsole, new CTRLPlusCCancellationTokenSource(), new TerminalTestReporterOptions
{
ShowPassedTests = () => true,
- // Like if we autodetect that we are in ANSI capable terminal.
- UseAnsi = true,
UseCIAnsi = false,
- ForceAnsi = true,
+ AnsiMode = AutoOnOff.On,
ShowActiveTests = true,
ShowProgress = () => true,
@@ -642,7 +637,7 @@ public void TestDisplayNames_WithControlCharacters_AreNormalized(char controlCha
var terminalReporter = new TerminalTestReporter(assembly, targetFramework, architecture, stringBuilderConsole, new CTRLPlusCCancellationTokenSource(), new TerminalTestReporterOptions
{
ShowPassedTests = () => true,
- UseAnsi = false,
+ AnsiMode = AutoOnOff.Off,
ShowProgress = () => false,
});
@@ -722,7 +717,7 @@ public void TestDiscovery_WithControlCharacters_AreNormalized(char controlChar,
var terminalReporter = new TerminalTestReporter(assembly, targetFramework, architecture, stringBuilderConsole, new CTRLPlusCCancellationTokenSource(), new TerminalTestReporterOptions
{
ShowPassedTests = () => true,
- UseAnsi = false,
+ AnsiMode = AutoOnOff.Off,
ShowProgress = () => false,
});
@@ -794,7 +789,7 @@ public void TerminalTestReporter_WhenInDiscoveryMode_ShouldIncrementDiscoveredTe
var terminalReporter = new TerminalTestReporter(assembly, "net8.0", "x64", stringBuilderConsole, new CTRLPlusCCancellationTokenSource(), new TerminalTestReporterOptions
{
ShowPassedTests = () => false,
- UseAnsi = false,
+ AnsiMode = AutoOnOff.Off,
ShowProgress = () => false,
});
diff --git a/test/Utilities/Microsoft.Testing.TestInfrastructure/TestHost.cs b/test/Utilities/Microsoft.Testing.TestInfrastructure/TestHost.cs
index 91f9c992db..a4c83b8c71 100644
--- a/test/Utilities/Microsoft.Testing.TestInfrastructure/TestHost.cs
+++ b/test/Utilities/Microsoft.Testing.TestInfrastructure/TestHost.cs
@@ -91,7 +91,7 @@ public async Task ExecuteAsync(
// Disable ANSI rendering so tests have easier time parsing the output.
// Disable progress so tests don't mix progress with overall progress, and with test process output.
int exitCode = await commandLine.RunAsyncAndReturnExitCodeAsync(
- $"{FullName} --no-ansi --no-progress {finalArguments}",
+ $"{FullName} --ansi off --no-progress {finalArguments}",
environmentVariables: environmentVariables,
workingDirectory: null,
cleanDefaultEnvironmentVariableIfCustomAreProvided: true,