Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ internal static class AnsiCodes
/// <summary>
/// The control sequence introducer.
/// </summary>
public const string CSI = "\x1b[";
public const string CSI = $"{Esc}[";

/// <summary>
/// Select graphic rendition.
/// </summary>
/// <remarks>
/// Print <see cref="CSI"/>color-code<see cref="SetColor"/> to change text color.
/// </remarks>
public const string SetColor = ";1m";
public const string SetColor = "m";

/// <summary>
/// Select graphic rendition - set bold mode.
Expand All @@ -45,17 +45,17 @@ internal static class AnsiCodes
/// <remarks>
/// Print <see cref="LinkPrefix"/>url<see cref="LinkInfix"/>text<see cref="LinkSuffix"/> to render a hyperlink.
/// </remarks>
public const string LinkPrefix = "\x1b]8;;";
public const string LinkPrefix = $"{Esc}]8;;";

/// <summary>
/// <see cref="LinkPrefix"/>.
/// </summary>
public const string LinkInfix = "\x1b\\";
public const string LinkInfix = $"{Esc}\\";

/// <summary>
/// <see cref="LinkPrefix"/>.
/// </summary>
public const string LinkSuffix = "\x1b]8;;\x1b\\";
public const string LinkSuffix = $"{Esc}]8;;{Esc}\\";

/// <summary>
/// Moves up the specified number of lines and puts cursor at the beginning of the line.
Expand Down Expand Up @@ -100,12 +100,12 @@ internal static class AnsiCodes
/// <summary>
/// Hides the cursor.
/// </summary>
public const string HideCursor = "\x1b[?25l";
public const string HideCursor = $"{Esc}[?25l";

/// <summary>
/// Shows/restores the cursor.
/// </summary>
public const string ShowCursor = "\x1b[?25h";
public const string ShowCursor = $"{Esc}[?25h";

/// <summary>
/// Set progress state to a busy spinner. <br/>
Expand All @@ -115,7 +115,7 @@ internal static class AnsiCodes
/// <see href="https://conemu.github.io/en/AnsiEscapeCodes.html#ConEmu_specific_OSC">ConEmu specific OSC codes.</see><br/>
/// <see href="https://iterm2.com/documentation-escape-codes.html">iTerm2 proprietary escape codes.</see>
/// </remarks>
public const string SetBusySpinner = "\x1b]9;4;3;\x1b\\";
public const string SetBusySpinner = $"{Esc}]9;4;3;{Esc}\\";

/// <summary>
/// Remove progress state, restoring taskbar status to normal. <br/>
Expand All @@ -125,7 +125,7 @@ internal static class AnsiCodes
/// <see href="https://conemu.github.io/en/AnsiEscapeCodes.html#ConEmu_specific_OSC">ConEmu specific OSC codes.</see><br/>
/// <see href="https://iterm2.com/documentation-escape-codes.html">iTerm2 proprietary escape codes.</see>
/// </remarks>
public const string RemoveBusySpinner = "\x1b]9;4;0;\x1b\\";
public const string RemoveBusySpinner = $"{Esc}]9;4;0;{Esc}\\";

public static string Colorize(string? s, TerminalColor color)
=> RoslynString.IsNullOrWhiteSpace(s) ? s ?? string.Empty : $"{CSI}{(int)color}{SetColor}{s}{SetDefaultColor}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public void AppendLink(string? path, int? lineNumber)
urlString = uri.ToString();
}

SetColor(TerminalColor.Gray);
SetColor(TerminalColor.DarkGray);
Append(AnsiCodes.LinkPrefix);
Append(urlString);
Append(AnsiCodes.LinkInfix);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void AppendTestWorkerProgress(int i, AnsiTerminal terminal)

terminal.Append('[');
charsTaken++;
terminal.SetColor(TerminalColor.DarkGreen);
terminal.SetColor(TerminalColor.Green);
terminal.Append('✓');
charsTaken++;
string passedText = passed.ToString(CultureInfo.CurrentCulture);
Expand All @@ -64,7 +64,7 @@ public void AppendTestWorkerProgress(int i, AnsiTerminal terminal)
terminal.Append('/');
charsTaken++;

terminal.SetColor(TerminalColor.DarkRed);
terminal.SetColor(TerminalColor.Red);
terminal.Append('x');
charsTaken++;
string failedText = failed.ToString(CultureInfo.CurrentCulture);
Expand All @@ -75,7 +75,7 @@ public void AppendTestWorkerProgress(int i, AnsiTerminal terminal)
terminal.Append('/');
charsTaken++;

terminal.SetColor(TerminalColor.DarkYellow);
terminal.SetColor(TerminalColor.Yellow);
terminal.Append('↓');
charsTaken++;
string skippedText = skipped.ToString(CultureInfo.CurrentCulture);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ public void StopUpdate()
TerminalColor.DarkBlue => ConsoleColor.DarkBlue,
TerminalColor.DarkMagenta => ConsoleColor.DarkMagenta,
TerminalColor.DarkCyan => ConsoleColor.DarkCyan,
TerminalColor.DarkWhite => ConsoleColor.White,
TerminalColor.Gray => ConsoleColor.White,
TerminalColor.Default => _defaultForegroundColor,
TerminalColor.Gray => ConsoleColor.Gray,
TerminalColor.DarkGray => ConsoleColor.Gray,
TerminalColor.Red => ConsoleColor.Red,
TerminalColor.Green => ConsoleColor.Green,
TerminalColor.Yellow => ConsoleColor.Yellow,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,49 +14,49 @@ internal enum TerminalColor
Black = 30,

/// <summary>
/// Red.
/// DarkRed.
/// </summary>
DarkRed = 31,

/// <summary>
/// Green.
/// DarkGreen.
/// </summary>
DarkGreen = 32,

/// <summary>
/// Yellow.
/// DarkYellow.
/// </summary>
DarkYellow = 33,

/// <summary>
/// Blue.
/// DarkBlue.
/// </summary>
DarkBlue = 34,

/// <summary>
/// Magenta.
/// DarkMagenta.
/// </summary>
DarkMagenta = 35,

/// <summary>
/// Cyan.
/// DarkCyan.
/// </summary>
DarkCyan = 36,

/// <summary>
/// White.
/// Gray. This entry looks out of order, but in reality 37 is dark white, which is lighter than bright black = Dark Gray in Console colors.
/// </summary>
DarkWhite = 37,
Gray = 37,

/// <summary>
/// Default.
/// </summary>
Default = 39,

/// <summary>
/// Gray.
/// DarkGray. This entry looks out of order, but in reality 90 is bright black, which is darker than dark white = Gray in Console colors.
/// </summary>
Gray = 90,
DarkGray = 90,

/// <summary>
/// Red.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ private void AppendTestRunSummary(ITerminal terminal)
if (!_options.ShowAssembly && _assemblies.Count == 1)
{
TestProgressState testProgressState = _assemblies.Values.Single();
terminal.SetColor(TerminalColor.Gray);
terminal.SetColor(TerminalColor.DarkGray);
terminal.Append(" - ");
terminal.ResetColor();
AppendAssemblyLinkTargetFrameworkAndArchitecture(terminal, testProgressState.Assembly, testProgressState.TargetFramework, testProgressState.Architecture);
Expand Down Expand Up @@ -317,7 +317,7 @@ private void AppendTestRunSummary(ITerminal terminal)

if (colorizeSkipped)
{
terminal.SetColor(TerminalColor.DarkYellow);
terminal.SetColor(TerminalColor.Yellow);
}

terminal.AppendLine(skippedText);
Expand All @@ -339,7 +339,7 @@ private static void AppendAssemblyResult(ITerminal terminal, bool succeeded, int
{
if (!succeeded)
{
terminal.SetColor(TerminalColor.DarkRed);
terminal.SetColor(TerminalColor.Red);
// If the build failed, we print one of three red strings.
string text = (countErrors > 0, countWarnings > 0) switch
{
Expand All @@ -353,13 +353,13 @@ private static void AppendAssemblyResult(ITerminal terminal, bool succeeded, int
}
else if (countWarnings > 0)
{
terminal.SetColor(TerminalColor.DarkYellow);
terminal.SetColor(TerminalColor.Yellow);
terminal.Append($"succeeded with {countWarnings} warning(s)");
terminal.ResetColor();
}
else
{
terminal.SetColor(TerminalColor.DarkGreen);
terminal.SetColor(TerminalColor.Green);
terminal.Append(PlatformResources.PassedLowercase);
terminal.ResetColor();
}
Expand Down Expand Up @@ -436,9 +436,9 @@ internal void TestCompleted(

TerminalColor color = outcome switch
{
TestOutcome.Error or TestOutcome.Fail or TestOutcome.Canceled or TestOutcome.Timeout => TerminalColor.DarkRed,
TestOutcome.Skipped => TerminalColor.DarkYellow,
TestOutcome.Passed => TerminalColor.DarkGreen,
TestOutcome.Error or TestOutcome.Fail or TestOutcome.Canceled or TestOutcome.Timeout => TerminalColor.Red,
TestOutcome.Skipped => TerminalColor.Yellow,
TestOutcome.Passed => TerminalColor.Green,
_ => throw new NotSupportedException(),
};
string outcomeText = outcome switch
Expand All @@ -455,7 +455,7 @@ internal void TestCompleted(
terminal.ResetColor();
terminal.Append(' ');
terminal.Append(displayName);
terminal.SetColor(TerminalColor.Gray);
terminal.SetColor(TerminalColor.DarkGray);
terminal.Append(' ');
AppendLongDuration(terminal, duration);
if (_options.ShowAssembly)
Expand Down Expand Up @@ -502,7 +502,7 @@ private static void FormatStackTrace(ITerminal terminal, string? errorStackTrace
return;
}

terminal.SetColor(TerminalColor.DarkRed);
terminal.SetColor(TerminalColor.Red);
terminal.Append(SingleIndentation);
terminal.Append(PlatformResources.StackTrace);
terminal.AppendLine(":");
Expand All @@ -529,7 +529,7 @@ private static void FormatStackTrace(ITerminal terminal, string? errorStackTrace
if (match.Success)
{
bool weHaveFilePathAndCodeLine = !RoslynString.IsNullOrWhiteSpace(match.Groups["code"].Value);
terminal.SetColor(TerminalColor.Gray);
terminal.SetColor(TerminalColor.DarkGray);
terminal.Append(PlatformResources.StackFrameAt);
terminal.Append(' ');
terminal.ResetColor();
Expand All @@ -545,7 +545,7 @@ private static void FormatStackTrace(ITerminal terminal, string? errorStackTrace

if (weHaveFilePathAndCodeLine)
{
terminal.SetColor(TerminalColor.Gray);
terminal.SetColor(TerminalColor.DarkGray);
terminal.Append(' ');
terminal.Append(PlatformResources.StackFrameIn);
terminal.Append(' ');
Expand Down Expand Up @@ -653,7 +653,7 @@ private static void AppendLongDuration(ITerminal terminal, TimeSpan duration, bo
{
if (colorize)
{
terminal.SetColor(TerminalColor.Gray);
terminal.SetColor(TerminalColor.DarkGray);
}

HumanReadableDurationFormatter.Append(terminal, duration, wrapInParentheses);
Expand Down Expand Up @@ -772,8 +772,8 @@ private static TerminalColor ToTerminalColor(ConsoleColor consoleColor)
ConsoleColor.DarkRed => TerminalColor.DarkRed,
ConsoleColor.DarkMagenta => TerminalColor.DarkMagenta,
ConsoleColor.DarkYellow => TerminalColor.DarkYellow,
ConsoleColor.DarkGray => TerminalColor.DarkGray,
ConsoleColor.Gray => TerminalColor.Gray,
ConsoleColor.DarkGray => TerminalColor.Gray,
ConsoleColor.Blue => TerminalColor.Blue,
ConsoleColor.Green => TerminalColor.Green,
ConsoleColor.Cyan => TerminalColor.Cyan,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,27 +88,27 @@ public void OutputFormattingIsCorrect()
string output = stringBuilderConsole.Output;

string expected = $"""
␛[32;1mpassed␛[m PassedTest1␛[90;1m ␛[90;1m(10s 000ms)␛[m
␛[33;1mskipped␛[m SkippedTest1␛[90;1m ␛[90;1m(10s 000ms)␛[m
␛[31;1mfailed (canceled)␛[m TimedoutTest1␛[90;1m ␛[90;1m(10s 000ms)␛[m
␛[31;1mfailed (canceled)␛[m CanceledTest1␛[90;1m ␛[90;1m(10s 000ms)␛[m
␛[31;1mfailed␛[m FailedTest1␛[90;1m ␛[90;1m(10s 000ms)␛[m
␛[91;1m Tests failed
␛[m␛[91;1m Expected
␛[92mpassed␛[m PassedTest1␛[90m ␛[90m(10s 000ms)␛[m
␛[93mskipped␛[m SkippedTest1␛[90m ␛[90m(10s 000ms)␛[m
␛[91mfailed (canceled)␛[m TimedoutTest1␛[90m ␛[90m(10s 000ms)␛[m
␛[91mfailed (canceled)␛[m CanceledTest1␛[90m ␛[90m(10s 000ms)␛[m
␛[91mfailed␛[m FailedTest1␛[90m ␛[90m(10s 000ms)␛[m
␛[91m Tests failed
␛[m␛[91m Expected
ABC
Actual
DEF
␛[m␛[31;1m Stack Trace:
␛[90;1mat ␛[m␛[91;1mFailingTest()␛[90;1m in ␛[90;1m␛]8;;file:///{folderLink}codefile.cs␛\{folder}codefile.cs:10␛]8;;␛\␛[m
␛[m␛[91m Stack Trace:
␛[90mat ␛[m␛[91mFailingTest()␛[90m in ␛[90m␛]8;;file:///{folderLink}codefile.cs␛\{folder}codefile.cs:10␛]8;;␛\␛[m


Out of process file artifacts produced:
- ␛[90;1m␛]8;;file:///{folderLink}artifact1.txt␛\{folder}artifact1.txt␛]8;;␛\␛[m
- ␛[90m␛]8;;file:///{folderLink}artifact1.txt␛\{folder}artifact1.txt␛]8;;␛\␛[m
In process file artifacts produced:
- ␛[90;1m␛]8;;file:///{folderLink}artifact2.txt␛\{folder}artifact2.txt␛]8;;␛\␛[m
␛[91;1mTest run summary: Failed!␛[90;1m - ␛[m␛[90;1m␛]8;;file:///{folderLinkNoSlash}␛\{folder}assembly.dll␛]8;;␛\␛[m (net8.0|x64)
- ␛[90m␛]8;;file:///{folderLink}artifact2.txt␛\{folder}artifact2.txt␛]8;;␛\␛[m
␛[91mTest run summary: Failed!␛[90m - ␛[m␛[90m␛]8;;file:///{folderLinkNoSlash}␛\{folder}assembly.dll␛]8;;␛\␛[m (net8.0|x64)
␛[m total: 5
␛[91;1m failed: 3
␛[91m failed: 3
␛[m succeeded: 1
skipped: 1
duration: 3652058d 23h 59m 59s 999ms
Expand Down