From bf28e565bd4fc68bac46df19e0dc932cfae86f9b Mon Sep 17 00:00:00 2001 From: Dave Dunkin Date: Thu, 16 May 2024 17:37:27 -0700 Subject: [PATCH 1/3] Add dotnet test extra property options in the right place. --- ReleaseNotes.md | 4 ++++ src/Faithlife.Build/DotNetBuild.cs | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 8374231..062d3d1 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,5 +1,9 @@ # Release Notes +## Unreleased + +* Fix running `dotnet test` with extra properties. + ## 5.21.1 * Send verbosity argument to `dotnet test`. diff --git a/src/Faithlife.Build/DotNetBuild.cs b/src/Faithlife.Build/DotNetBuild.cs index 0ece440..fd4975f 100644 --- a/src/Faithlife.Build/DotNetBuild.cs +++ b/src/Faithlife.Build/DotNetBuild.cs @@ -997,8 +997,7 @@ public static void RunTests(this DotNetBuildSettings settings, string? path) } else { - RunDotNet(new[] - { + RunDotNet([ "test", path, "-c", @@ -1008,9 +1007,10 @@ public static void RunTests(this DotNetBuildSettings settings, string? path) "--no-build", settings.GetVerbosityArg(), settings.GetMaxCpuCountArg(), + .. settings.GetExtraPropertyArgs("test"), "--", "RunConfiguration.TreatNoTestsAsError=true", - }.Concat(settings.GetExtraPropertyArgs("test"))); + ]); } } } From 10daeb67aecd6d9f867f11cccd9b693c03e057fb Mon Sep 17 00:00:00 2001 From: Dave Dunkin Date: Fri, 17 May 2024 08:29:03 -0700 Subject: [PATCH 2/3] Add `DotNetTestSettings.GetLogger` to support custom loggers. --- ReleaseNotes.md | 1 + src/Faithlife.Build/DotNetBuild.cs | 3 +++ src/Faithlife.Build/DotNetTestSettings.cs | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 062d3d1..f89d401 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -3,6 +3,7 @@ ## Unreleased * Fix running `dotnet test` with extra properties. +* Add `DotNetTestSettings.GetLogger` to support custom loggers. ## 5.21.1 diff --git a/src/Faithlife.Build/DotNetBuild.cs b/src/Faithlife.Build/DotNetBuild.cs index fd4975f..b45d45e 100644 --- a/src/Faithlife.Build/DotNetBuild.cs +++ b/src/Faithlife.Build/DotNetBuild.cs @@ -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 @@ -989,6 +990,7 @@ public static void RunTests(this DotNetBuildSettings settings, string? path) Path.GetFileName(path), settings.GetVerbosityArg(), settings.GetMaxCpuCountArg(), + .. loggerArgs, "--", "RunConfiguration.TreatNoTestsAsError=true", ], @@ -1008,6 +1010,7 @@ public static void RunTests(this DotNetBuildSettings settings, string? path) settings.GetVerbosityArg(), settings.GetMaxCpuCountArg(), .. settings.GetExtraPropertyArgs("test"), + .. loggerArgs, "--", "RunConfiguration.TreatNoTestsAsError=true", ]); diff --git a/src/Faithlife.Build/DotNetTestSettings.cs b/src/Faithlife.Build/DotNetTestSettings.cs index 2be30cb..f10c7fd 100644 --- a/src/Faithlife.Build/DotNetTestSettings.cs +++ b/src/Faithlife.Build/DotNetTestSettings.cs @@ -31,6 +31,11 @@ public sealed class DotNetTestSettings /// public bool? UseParallel { get; set; } + /// + /// Get the logger for the specified project. + /// + public Func? GetLogger { get; set; } + /// /// Clones the settings. /// From 465bcec87e21dedd4d55d2498ce01cb3481976f0 Mon Sep 17 00:00:00 2001 From: Dave Dunkin Date: Wed, 5 Jun 2024 17:21:35 -0700 Subject: [PATCH 3/3] Remove -maxcpucount arg when calling dotnet test with a dll, it is not supported. --- ReleaseNotes.md | 1 + src/Faithlife.Build/DotNetBuild.cs | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/ReleaseNotes.md b/ReleaseNotes.md index f89d401..4111d45 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -4,6 +4,7 @@ * 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 diff --git a/src/Faithlife.Build/DotNetBuild.cs b/src/Faithlife.Build/DotNetBuild.cs index b45d45e..2c40b07 100644 --- a/src/Faithlife.Build/DotNetBuild.cs +++ b/src/Faithlife.Build/DotNetBuild.cs @@ -989,7 +989,6 @@ public static void RunTests(this DotNetBuildSettings settings, string? path) "test", Path.GetFileName(path), settings.GetVerbosityArg(), - settings.GetMaxCpuCountArg(), .. loggerArgs, "--", "RunConfiguration.TreatNoTestsAsError=true",