Skip to content
Prev Previous commit
Fix ignore test
  • Loading branch information
tmat committed Jun 21, 2019
commit b1918a97779e6d09700a4485c12059e5707bf12a
17 changes: 11 additions & 6 deletions src/Microsoft.Build.Tasks.Git.UnitTests/GitIgnoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void IsIgnored_CaseSensitive()
// does not match "/*.c"
Assert.False(matcher.IsPathIgnored(Path.Combine(workingDir.Path, "A", "B", "C", "D1", "x.c")));

AssertEx.Equal(new[]
AssertEx.SetEqual(new[]
{
"/Repo/.git: True",
"/Repo/A/B/C/D1/b: True",
Expand All @@ -153,7 +153,7 @@ public void IsIgnored_CaseSensitive()
"/Repo/A/B: False",
"/Repo/A: False",
"/Repo: False"
}, matcher.DirectoryIgnoreStateCache.Select(kvp => $"{kvp.Key.Substring(rootDir.Path.Length)}: {kvp.Value}").OrderBy(s => s, StringComparer.Ordinal));
}, matcher.DirectoryIgnoreStateCache.Select(kvp => $"{kvp.Key.Substring(rootDir.Path.Length)}: {kvp.Value}"));
}

[Fact]
Expand Down Expand Up @@ -197,15 +197,20 @@ public void IsIgnored_IgnoreCase()
// matches "dir/" (treated as a directory path)
Assert.True(matcher.IsPathIgnored(Path.Combine(workingDir.Path, "A", "DiR") + Path.DirectorySeparatorChar));

// matches "dir/" (existing directory path)
Assert.True(matcher.IsPathIgnored(Path.Combine(workingDir.Path, "A", "DIR")));
if (Path.DirectorySeparatorChar == '\\')
{
// matches "dir/" (existing directory path, the directory DIR only exists on case-insensitive FS)
Assert.True(matcher.IsPathIgnored(Path.Combine(workingDir.Path, "A", "DIR")));
}

Assert.True(matcher.IsPathIgnored(Path.Combine(workingDir.Path, "A", "diR")));

AssertEx.Equal(new[]
AssertEx.SetEqual(new[]
{
"/Repo/A/DIr: True",
"/Repo/A: False",
"/Repo: False",
}, matcher.DirectoryIgnoreStateCache.Select(kvp => $"{kvp.Key.Substring(rootDir.Path.Length)}: {kvp.Value}").OrderBy(s => s, StringComparer.Ordinal));
}, matcher.DirectoryIgnoreStateCache.Select(kvp => $"{kvp.Key.Substring(rootDir.Path.Length)}: {kvp.Value}"));
}
}
}