Skip to content

Commit

Permalink
Merge pull request #65 from ddunkin/dotnet-test
Browse files Browse the repository at this point in the history
Fix running dotnet test. Add DotNetTestSettings.GetLogger.
  • Loading branch information
bgrainger authored Jun 6, 2024
2 parents c5e5c86 + 465bcec commit e58936d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
6 changes: 6 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release Notes

## Unreleased

* Fix running `dotnet test` with extra properties.
* Add `DotNetTestSettings.GetLogger` to support custom loggers.
* Don't send `-maxcpucount` argument when calling `dotnet test` with a dll.

## 5.21.1

* Send verbosity argument to `dotnet test`.
Expand Down
10 changes: 6 additions & 4 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 @@ -988,7 +989,7 @@ public static void RunTests(this DotNetBuildSettings settings, string? path)
"test",
Path.GetFileName(path),
settings.GetVerbosityArg(),
settings.GetMaxCpuCountArg(),
.. loggerArgs,
"--",
"RunConfiguration.TreatNoTestsAsError=true",
],
Expand All @@ -997,8 +998,7 @@ public static void RunTests(this DotNetBuildSettings settings, string? path)
}
else
{
RunDotNet(new[]
{
RunDotNet([
"test",
path,
"-c",
Expand All @@ -1008,9 +1008,11 @@ public static void RunTests(this DotNetBuildSettings settings, string? path)
"--no-build",
settings.GetVerbosityArg(),
settings.GetMaxCpuCountArg(),
.. settings.GetExtraPropertyArgs("test"),
.. loggerArgs,
"--",
"RunConfiguration.TreatNoTestsAsError=true",
}.Concat(settings.GetExtraPropertyArgs("test")));
]);
}
}
}
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 e58936d

Please sign in to comment.