Skip to content

Commit

Permalink
Add DotNetTestSettings.GetLogger to support custom loggers.
Browse files Browse the repository at this point in the history
  • Loading branch information
ddunkin committed Jun 6, 2024
1 parent bf28e56 commit 10daeb6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

* Fix running `dotnet test` with extra properties.
* Add `DotNetTestSettings.GetLogger` to support custom loggers.

## 5.21.1

Expand Down
3 changes: 3 additions & 0 deletions src/Faithlife.Build/DotNetBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,7 @@ public static void RunTests(this DotNetBuildSettings settings, string? path)
}
else
{
var loggerArgs = settings.TestSettings?.GetLogger?.Invoke(path) is { } logger ? new[] { "--logger", logger } : [];
if (Path.GetExtension(path)?.ToLowerInvariant() is ".dll" or ".exe")
{
RunDotNet(new AppRunnerSettings
Expand All @@ -989,6 +990,7 @@ public static void RunTests(this DotNetBuildSettings settings, string? path)
Path.GetFileName(path),
settings.GetVerbosityArg(),
settings.GetMaxCpuCountArg(),
.. loggerArgs,
"--",
"RunConfiguration.TreatNoTestsAsError=true",
],
Expand All @@ -1008,6 +1010,7 @@ public static void RunTests(this DotNetBuildSettings settings, string? path)
settings.GetVerbosityArg(),
settings.GetMaxCpuCountArg(),
.. settings.GetExtraPropertyArgs("test"),
.. loggerArgs,
"--",
"RunConfiguration.TreatNoTestsAsError=true",
]);
Expand Down
5 changes: 5 additions & 0 deletions src/Faithlife.Build/DotNetTestSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public sealed class DotNetTestSettings
/// </summary>
public bool? UseParallel { get; set; }

/// <summary>
/// Get the logger for the specified project.
/// </summary>
public Func<string?, string?>? GetLogger { get; set; }

/// <summary>
/// Clones the settings.
/// </summary>
Expand Down

0 comments on commit 10daeb6

Please sign in to comment.