Skip to content

Commit

Permalink
Fix parallel mode bug (#125)
Browse files Browse the repository at this point in the history
Co-authored-by: Jiapeng Xu <jiapengxu@microsoft.com>
irushx and jiapengxu-msft authored Oct 24, 2023
1 parent a2d10b4 commit 4b0e484
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/yunit/TestAdapter.cs
Original file line number Diff line number Diff line change
@@ -139,13 +139,13 @@ public void RunTests(IEnumerable<TestCase> tests, IRunContext runContext, IFrame
foreach (var fileTests in fileSequentialTestsParallelTests.GroupBy(test => test.CodeFilePath))
{
var testRuns = new ConcurrentBag<Task>();
Parallel.ForEach(fileTests.SelectMany(fileTest => fileTests), test => testRuns.Add(RunTest(frameworkHandle, test, inOnlyMode)));
Parallel.ForEach(fileTests.ToArray(), test => testRuns.Add(RunTest(frameworkHandle, test, inOnlyMode)));
Task.WhenAll(testRuns).GetAwaiter().GetResult();
}
}

var fileParallelTestsSequentialTests = groupTests.Where(group => group.Key == ParallelMode.FileParallelTestsSequential).SelectMany(group => group).ToArray();
if (fileSequentialTestsParallelTests.Any())
if (fileParallelTestsSequentialTests.Any())
{
var testRuns = new ConcurrentBag<Task>();
foreach (var fileTests in fileParallelTestsSequentialTests.GroupBy(test => test.CodeFilePath).ToArray())

0 comments on commit 4b0e484

Please sign in to comment.