public IEnumerable <Mutant> FilterMutants(IEnumerable <Mutant> mutants, IReadOnlyFileLeaf file, StrykerOptions options) { // Mutants can be enabled for testing based on multiple reasons. We store all the filtered mutants in this list and return this list. IEnumerable <Mutant> filteredMutants; // A non-csharp file is flagged by the diff result as modified. We cannot determine which mutants will be affected by this, thus all mutants have to be tested. if (_diffResult.ChangedTestFiles is { } && _diffResult.ChangedTestFiles.Any(x => !x.EndsWith(".cs")))
public IEnumerable <Mutant> FilterMutants(IEnumerable <Mutant> mutants, IReadOnlyFileLeaf file, StrykerOptions options) { return(mutants.Where(IsMutantIncluded)); bool IsMutantIncluded(Mutant mutant) { // Check if the the mutant is included. if (!_includePattern.Any(MatchesPattern)) { return(false); } // Check if the mutant is excluded. if (_excludePattern.Any(MatchesPattern)) { return(false); } return(true); bool MatchesPattern(FilePattern pattern) { // We check both the full and the relative path to allow for relative paths. return(pattern.IsMatch(file.FullPath, mutant.Mutation.OriginalNode.Span) || pattern.IsMatch(file.RelativePath, mutant.Mutation.OriginalNode.Span)); } } }
private void UpdateMutantsWithBaselineStatus(IEnumerable <Mutant> mutants, IReadOnlyFileLeaf file) { if (!_baseline.Files.ContainsKey(FilePathUtils.NormalizePathSeparators(file.RelativePath))) { return; } SourceFile baselineFile = _baseline.Files[FilePathUtils.NormalizePathSeparators(file.RelativePath)]; if (baselineFile is { })
public IEnumerable <Mutant> FilterMutants(IEnumerable <Mutant> mutants, IReadOnlyFileLeaf file, StrykerOptions options) { if (options.WithBaseline) { if (_baseline == null) { _logger.LogDebug("Returning all mutants on {0} because there is no baseline available", file.RelativePath); } else { UpdateMutantsWithBaselineStatus(mutants, file); } } return(mutants); }
/// <inheritdoc /> public IEnumerable <Mutant> FilterMutants(IEnumerable <Mutant> mutants, IReadOnlyFileLeaf file, StrykerOptions options) => mutants.Where(mutant => !options.ExcludedMutations.Contains(mutant.Mutation.Type));
public IEnumerable <Mutant> FilterMutants(IEnumerable <Mutant> mutants, IReadOnlyFileLeaf file, StrykerOptions options) { return(mutants.Where(m => !Exclude(m.Mutation.OriginalNode))); }