Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(since): Retest all mutants covered by tests for which we cannot determine the filepath #2753

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

using System.Collections.Generic;
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.Extensions.Logging;
using Stryker.Core.DiffProviders;
using Stryker.Core.Logging;
using Stryker.Core.Mutants;
using Stryker.Core.Options;
using Stryker.Core.ProjectComponents;
using System.Collections.Generic;
using System.Linq;

namespace Stryker.Core.MutantFilters
{
Expand Down Expand Up @@ -120,10 +120,13 @@ private IEnumerable<Mutant> ResetMutantStatusForChangedTests(IEnumerable<Mutant>

foreach (var mutant in mutants)
{
if (mutant.CoveringTests.IsEmpty || mutant.CoveringTests.Count == 0)
continue;
rouke-broersma marked this conversation as resolved.
Show resolved Hide resolved
var coveringTests = _tests.Extract(mutant.CoveringTests.GetGuids());

if (coveringTests != null
&& coveringTests.Any(coveringTest => _diffResult.ChangedTestFiles.Any(changedTestFile => coveringTest.TestFilePath == changedTestFile)))
&& coveringTests.Any(coveringTest => _diffResult.ChangedTestFiles.Any(changedTestFile => coveringTest.TestFilePath == changedTestFile
|| string.IsNullOrEmpty(coveringTest.TestFilePath))))
{
mutant.ResultStatus = MutantStatus.Pending;
mutant.ResultStatusReason = "One or more covering tests changed";
Expand Down
2 changes: 1 addition & 1 deletion src/Stryker.Core/Stryker.Core/Mutants/TestSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ public void RegisterTests(IEnumerable<TestDescription> tests)

public void RegisterTest(TestDescription test) => _tests[test.Id] = test;

public IEnumerable<TestDescription> Extract(IEnumerable<Guid> ids) => ids.Select(i => _tests[i]);
public IEnumerable<TestDescription> Extract(IEnumerable<Guid> ids) => ids?.Select(i => _tests[i]) ?? Enumerable.Empty<TestDescription>();
}
}