From 307b64210a2ae1a0505e8899e1011ecff4aaa4d8 Mon Sep 17 00:00:00 2001 From: kcamp Date: Wed, 14 Feb 2018 10:09:41 -0500 Subject: [PATCH] GH-2039: Fix XUnit2Settings + XUnit2Runner to honor explicit specifications of ParallelismOption.None --- src/Cake.Common.Tests/Unit/Tools/XUnit/XUnit2RunnerTests.cs | 5 +++-- .../Unit/Tools/XUnit/XUnit2SettingsTests.cs | 4 ++-- src/Cake.Common/Tools/XUnit/XUnit2Runner.cs | 2 +- src/Cake.Common/Tools/XUnit/XUnit2Settings.cs | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Cake.Common.Tests/Unit/Tools/XUnit/XUnit2RunnerTests.cs b/src/Cake.Common.Tests/Unit/Tools/XUnit/XUnit2RunnerTests.cs index 0d0c677207..12c116a6b7 100644 --- a/src/Cake.Common.Tests/Unit/Tools/XUnit/XUnit2RunnerTests.cs +++ b/src/Cake.Common.Tests/Unit/Tools/XUnit/XUnit2RunnerTests.cs @@ -542,11 +542,12 @@ public void Should_Not_Use_App_Domains_If_Disabled_In_Settings() } [Theory] + [InlineData(null, "\"/Working/Test1.dll\"")] [InlineData(ParallelismOption.All, "\"/Working/Test1.dll\" -parallel all")] [InlineData(ParallelismOption.Assemblies, "\"/Working/Test1.dll\" -parallel assemblies")] [InlineData(ParallelismOption.Collections, "\"/Working/Test1.dll\" -parallel collections")] - [InlineData(ParallelismOption.None, "\"/Working/Test1.dll\"")] - public void Should_Use_Parallel_Switch_If_Settings_Value_Is_Not_None(ParallelismOption option, string expected) + [InlineData(ParallelismOption.None, "\"/Working/Test1.dll\" -parallel none")] + public void Should_Use_Parallel_Switch_If_Settings_Value_Is_Specified(ParallelismOption? option, string expected) { // Given var fixture = new XUnit2RunnerFixture(); diff --git a/src/Cake.Common.Tests/Unit/Tools/XUnit/XUnit2SettingsTests.cs b/src/Cake.Common.Tests/Unit/Tools/XUnit/XUnit2SettingsTests.cs index 8628537a9a..2c8e516686 100644 --- a/src/Cake.Common.Tests/Unit/Tools/XUnit/XUnit2SettingsTests.cs +++ b/src/Cake.Common.Tests/Unit/Tools/XUnit/XUnit2SettingsTests.cs @@ -83,13 +83,13 @@ public void Should_Set_NoAppDomain_To_False_By_Default() } [Fact] - public void Should_Set_Parallelism_Option_To_None_By_Default() + public void Should_Set_Parallelism_Option_To_Null_By_Default() { // Given, When var settings = new XUnit2Settings(); // Then - Assert.Equal(settings.Parallelism, ParallelismOption.None); + Assert.Null(settings.Parallelism); } [Fact] diff --git a/src/Cake.Common/Tools/XUnit/XUnit2Runner.cs b/src/Cake.Common/Tools/XUnit/XUnit2Runner.cs index d95f07d346..397c92c989 100644 --- a/src/Cake.Common/Tools/XUnit/XUnit2Runner.cs +++ b/src/Cake.Common/Tools/XUnit/XUnit2Runner.cs @@ -128,7 +128,7 @@ private ProcessArgumentBuilder GetArguments(IReadOnlyList assemblyPath } // parallelize test execution? - if (settings.Parallelism != ParallelismOption.None) + if (settings.Parallelism.HasValue) { builder.Append("-parallel " + settings.Parallelism.ToString().ToLowerInvariant()); } diff --git a/src/Cake.Common/Tools/XUnit/XUnit2Settings.cs b/src/Cake.Common/Tools/XUnit/XUnit2Settings.cs index 0db98bd818..86af209247 100644 --- a/src/Cake.Common/Tools/XUnit/XUnit2Settings.cs +++ b/src/Cake.Common/Tools/XUnit/XUnit2Settings.cs @@ -81,7 +81,7 @@ public sealed class XUnit2Settings : ToolSettings /// /// The parallelism option. /// - public ParallelismOption Parallelism { get; set; } + public ParallelismOption? Parallelism { get; set; } /// /// Gets or sets a value indicating whether to run tests in using x86 test runner.