Skip to content

Commit bbc2540

Browse files
committed
(build) running tests in parallel
1 parent 3fc00cb commit bbc2540

File tree

1 file changed

+27
-30
lines changed

1 file changed

+27
-30
lines changed

build/pack.cake

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -42,46 +42,43 @@ Task("Test")
4242
var framework = parameters.FullFxVersion;
4343

4444
// run using dotnet test
45+
var actions = new List<Action>();
4546
var projects = GetFiles("./src/**/*.Tests.csproj");
4647
foreach(var project in projects)
4748
{
48-
var settings = new DotNetCoreTestSettings
49+
actions.Add(() =>
4950
{
50-
Framework = framework,
51-
NoBuild = true,
52-
NoRestore = true,
53-
Configuration = parameters.Configuration
54-
};
55-
56-
var coverletSettings = new CoverletSettings {
57-
CollectCoverage = true,
58-
CoverletOutputFormat = CoverletOutputFormat.opencover,
59-
CoverletOutputDirectory = parameters.Paths.Directories.TestCoverageOutput + "/",
60-
CoverletOutputName = $"{project.GetFilenameWithoutExtension()}.coverage.xml"
61-
};
62-
63-
if (IsRunningOnUnix())
64-
{
65-
settings.Filter = "TestCategory!=NoMono";
66-
}
51+
var settings = new DotNetCoreTestSettings
52+
{
53+
Framework = framework,
54+
NoBuild = true,
55+
NoRestore = true,
56+
Configuration = parameters.Configuration
57+
};
6758

68-
DotNetCoreTest(project.FullPath, settings, coverletSettings);
69-
}
59+
var coverletSettings = new CoverletSettings {
60+
CollectCoverage = true,
61+
CoverletOutputFormat = CoverletOutputFormat.opencover,
62+
CoverletOutputDirectory = parameters.Paths.Directories.TestCoverageOutput + "/",
63+
CoverletOutputName = $"{project.GetFilenameWithoutExtension()}.coverage.xml"
64+
};
7065

71-
// run using NUnit
72-
var testAssemblies = GetFiles("./src/**/bin/" + parameters.Configuration + "/" + framework + "/*.Tests.dll");
66+
if (IsRunningOnUnix())
67+
{
68+
settings.Filter = "TestCategory!=NoMono";
69+
}
70+
71+
DotNetCoreTest(project.FullPath, settings, coverletSettings);
72+
});
73+
}
7374

74-
var nunitSettings = new NUnit3Settings
75+
var options = new ParallelOptions
7576
{
76-
Results = new List<NUnit3Result> { new NUnit3Result { FileName = parameters.Paths.Files.TestCoverageOutputFilePath } }
77+
MaxDegreeOfParallelism = -1,
78+
CancellationToken = default
7779
};
7880

79-
if(IsRunningOnUnix()) {
80-
nunitSettings.Where = "cat!=NoMono";
81-
nunitSettings.Agents = 1;
82-
}
83-
84-
//NUnit3(testAssemblies, nunitSettings);
81+
Parallel.Invoke(options, actions.ToArray());
8582
});
8683

8784
#endregion

0 commit comments

Comments
 (0)