-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the ported runner sources for XUnitRunnerUap
- Loading branch information
1 parent
f132521
commit 3bdfe07
Showing
53 changed files
with
189 additions
and
968 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
src/Microsoft.DotNet.XUnitConsoleRunner/src/Utility/ConsoleRunnerLogger.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#if WINDOWS_UWP | ||
|
||
using System; | ||
|
||
namespace Xunit.ConsoleClient | ||
{ | ||
/// <summary> | ||
/// An implementation of <see cref="IRunnerLogger"/> which logs messages | ||
/// to <see cref="Console"/> and <see cref="Console.Error"/>. | ||
/// </summary> | ||
public class ConsoleRunnerLogger : IRunnerLogger | ||
{ | ||
readonly object lockObject; | ||
readonly bool useColors; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ConsoleRunnerLogger"/> class. | ||
/// </summary> | ||
/// <param name="useColors">A flag to indicate whether colors should be used when | ||
/// logging messages.</param> | ||
public ConsoleRunnerLogger(bool useColors) : this(useColors, new object()) { } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ConsoleRunnerLogger"/> class. | ||
/// </summary> | ||
/// <param name="useColors">A flag to indicate whether colors should be used when | ||
/// logging messages.</param> | ||
/// <param name="lockObject">The lock object used to prevent console clashes.</param> | ||
public ConsoleRunnerLogger(bool useColors, object lockObject) | ||
{ | ||
this.useColors = useColors; | ||
this.lockObject = lockObject; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public object LockObject => lockObject; | ||
|
||
/// <inheritdoc/> | ||
public void LogError(StackFrameInfo stackFrame, string message) | ||
{ | ||
using (SetColor(ConsoleColor.Red)) | ||
lock (LockObject) | ||
Console.Error.WriteLine(message); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void LogImportantMessage(StackFrameInfo stackFrame, string message) | ||
{ | ||
using (SetColor(ConsoleColor.Gray)) | ||
lock (LockObject) | ||
Console.WriteLine(message); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void LogMessage(StackFrameInfo stackFrame, string message) | ||
{ | ||
using (SetColor(ConsoleColor.DarkGray)) | ||
lock (LockObject) | ||
Console.WriteLine(message); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void LogWarning(StackFrameInfo stackFrame, string message) | ||
{ | ||
using (SetColor(ConsoleColor.Yellow)) | ||
lock (LockObject) | ||
Console.WriteLine(message); | ||
} | ||
|
||
IDisposable SetColor(ConsoleColor color) | ||
=> useColors ? new ColorRestorer(color) : null; | ||
|
||
class ColorRestorer : IDisposable | ||
{ | ||
public ColorRestorer(ConsoleColor color) | ||
=> ConsoleHelper.SetForegroundColor(color); | ||
|
||
public void Dispose() | ||
=> ConsoleHelper.ResetColor(); | ||
} | ||
} | ||
} | ||
|
||
#endif |
2 changes: 1 addition & 1 deletion
2
src/Microsoft.DotNet.XUnitConsoleRunner/src/Utility/TransformFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
using System; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.