Skip to content

Commit

Permalink
Rename the class
Browse files Browse the repository at this point in the history
  • Loading branch information
psfinaki committed Sep 30, 2023
1 parent d9275a4 commit cd15c9e
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public void ScanDiff_Throws_Stryker_Input_Exception_When_Commit_null()
public void ScanDiffReturnsListOfFiles_ExcludingTestFilesInDiffIgnoreFiles()
{
// Arrange
var diffIgnoreFiles = new[] { new ExcludableString("/c/Users/JohnDoe/Project/Tests/Test.cs") };
var diffIgnoreFiles = new[] { new ExclusionPattern("/c/Users/JohnDoe/Project/Tests/Test.cs") };

var basePath = FilePathUtils.NormalizePathSeparators("/c/Users/JohnDoe/Project/Tests");
var options = new StrykerOptions()
Expand Down Expand Up @@ -289,7 +289,7 @@ public void ScanDiffReturnsListOfFiles_ExcludingTestFilesInDiffIgnoreFiles()
public void ScanDiffReturnsListOfFiles_ExcludingTestFilesInDiffIgnoreFiles_Single_Asterisk()
{
// Arrange
var diffIgnoreFiles = new[] { new ExcludableString("/c/Users/JohnDoe/Project/*/Test.cs") };
var diffIgnoreFiles = new[] { new ExclusionPattern("/c/Users/JohnDoe/Project/*/Test.cs") };

var basePath = FilePathUtils.NormalizePathSeparators("/c/Users/JohnDoe/Project/Tests");
var options = new StrykerOptions()
Expand Down Expand Up @@ -365,7 +365,7 @@ public void ScanDiffReturnsListOfFiles_ExcludingTestFilesInDiffIgnoreFiles_Singl
public void ScanDiffReturnsListOfFiles_ExcludingTestFilesInDiffIgnoreFiles_Multi_Asterisk()
{
// Arrange
var diffIgnoreFiles = new[] { new ExcludableString("**/Test.cs") };
var diffIgnoreFiles = new[] { new ExclusionPattern("**/Test.cs") };

var basePath = FilePathUtils.NormalizePathSeparators("/c/Users/JohnDoe/Project/Tests");
var options = new StrykerOptions()
Expand Down Expand Up @@ -441,7 +441,7 @@ public void ScanDiffReturnsListOfFiles_ExcludingTestFilesInDiffIgnoreFiles_Multi
public void ScanDiffReturnsListOfFiles_ExcludingFilesInDiffIgnoreFiles_Multi_Asterisk()
{
// Arrange
var diffIgnoreFiles = new[] { new ExcludableString("**/file.cs") };
var diffIgnoreFiles = new[] { new ExclusionPattern("**/file.cs") };

var basePath = FilePathUtils.NormalizePathSeparators("/c/Users/JohnDoe/Project/Tests");
var options = new StrykerOptions()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@

namespace Stryker.Core.UnitTest
{
public class ExcludableStringTests : TestBase
public class ExclusionPatternTests : TestBase
{
[Fact]
public void ExcludableString_Null()
public void ExclusionPattern_Null()
{
_ = Assert.Throws<ArgumentNullException>(() => new ExcludableString(null));
_ = Assert.Throws<ArgumentNullException>(() => new ExclusionPattern(null));
}

[Fact]
public void ExcludableString_Globs()
public void ExclusionPattern_Globs()
{
var s1 = new ExcludableString(@"Person.cs");
var s2 = new ExcludableString(@"!Person.cs");
var s1 = new ExclusionPattern(@"Person.cs");
var s2 = new ExclusionPattern(@"!Person.cs");

s1.IsExcluded.ShouldBeFalse();
s2.IsExcluded.ShouldBeTrue();
s1.Glob.ToString().ShouldBe(s2.Glob.ToString());
}

[Fact]
public void ExcludableString_MutantSpans()
public void ExclusionPattern_MutantSpans()
{
var s1 = new ExcludableString(@"src/Person.cs{10..100}");
var s2 = new ExcludableString(@"src/Person.cs");
var s1 = new ExclusionPattern(@"src/Person.cs{10..100}");
var s2 = new ExclusionPattern(@"src/Person.cs");

s1.MutantSpans.ShouldBe("{10..100}");
s2.MutantSpans.ShouldBeEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void ShouldCopyValues()
DashboardUrl = "url",
DevMode = true,
Since = true,
DiffIgnoreChanges = new[] { new ExcludableString("**") },
DiffIgnoreChanges = new[] { new ExclusionPattern("**") },
ExcludedMutations = new[] { Mutator.Bitwise },
FallbackVersion = "main",
IgnoredMethods = new[] { new Regex("") },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

namespace Stryker.Core
{
public readonly struct ExcludableString
public readonly struct ExclusionPattern
{
private static readonly Regex _mutantSpansRegex = new("(\\{(\\d+)\\.\\.(\\d+)\\})+$");

public ExcludableString(string s)
public ExclusionPattern(string s)
{
if (s is null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Stryker.Core/Stryker.Core/FilePattern.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public FilePattern(Glob glob, bool isExclude, IReadOnlyCollection<TextSpan> text
/// <returns>The <see cref="FilePattern"/></returns>
public static FilePattern Parse(string pattern)
{
var s = new ExcludableString(pattern);
var s = new ExclusionPattern(pattern);
IReadOnlyCollection<TextSpan> textSpans;

if (string.IsNullOrEmpty(s.MutantSpans))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ Any non-excluded files will trigger all mutants to be tested because we cannot d
Use glob syntax for wildcards: https://en.wikipedia.org/wiki/Glob_(programming)
Example: ['**/*Assets.json','**/favicon.ico']";

public IEnumerable<ExcludableString> Validate()
public IEnumerable<ExclusionPattern> Validate()
{
if (SuppliedInput is { })
{
var diffIgnoreStrings = new List<ExcludableString>();
var diffIgnoreStrings = new List<ExclusionPattern>();
foreach (var pattern in SuppliedInput)
{
diffIgnoreStrings.Add(new ExcludableString(FilePathUtils.NormalizePathSeparators(pattern)));
diffIgnoreStrings.Add(new ExclusionPattern(FilePathUtils.NormalizePathSeparators(pattern)));
}

return diffIgnoreStrings;
}
return Enumerable.Empty<ExcludableString>();
return Enumerable.Empty<ExclusionPattern>();
}
}
}
2 changes: 1 addition & 1 deletion src/Stryker.Core/Stryker.Core/Options/StrykerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public class StrykerOptions
/// Context: When using the since feature, all tests are run again if files in the test project change (as these could impact the test results)
/// When the file is present in this option the tests should not run again as the file does not impact test results.
/// </summary>
public IEnumerable<ExcludableString> DiffIgnoreChanges { get; init; } = Enumerable.Empty<ExcludableString>();
public IEnumerable<ExclusionPattern> DiffIgnoreChanges { get; init; } = Enumerable.Empty<ExclusionPattern>();

/// <summary>
/// When no previous report can be found for the since feature, this commitish is used to se a baseline.
Expand Down

0 comments on commit cd15c9e

Please sign in to comment.