Skip to content

Commit

Permalink
Failing test for watching a SubFileSystem involving case sensitivity
Browse files Browse the repository at this point in the history
Watcher events get silently discarded if all conditions are met:
* SubFileSystem was created with incorrect case
* Changed file path includes a ~
* Any segment of changed file path is short enough to possibly be a SFN
  • Loading branch information
Metapyziks committed Jun 21, 2024
1 parent a4b9faf commit 073a020
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/Zio.Tests/FileSystems/TestSubFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,43 @@ public void TestWatcher()
Assert.True(gotChange);
}

[SkippableTheory]
[InlineData("/test", "/test", "/foo.txt")]
[InlineData("/test", "/test", "/~foo.txt")]
[InlineData("/test", "/TEST", "/foo.txt")]
[InlineData("/test", "/TEST", "/~foo.txt")]
[InlineData("/verylongname", "/VERYLONGNAME", "/foo.txt")]
[InlineData("/verylongname", "/VERYLONGNAME", "/~foo.txt")]
public void TestWatcherCaseSensitive(string physicalDir, string subDir, string filePath)
{
Skip.IfNot(IsWindows, "This test involves case insensitivity on Windows");

var physicalFs = GetCommonPhysicalFileSystem();
physicalFs.CreateDirectory(physicalDir);

Assert.True(physicalFs.DirectoryExists(physicalDir));
Assert.True(physicalFs.DirectoryExists(subDir));

var subFs = new SubFileSystem(physicalFs, subDir);
var watcher = subFs.Watch("/");

var gotChange = false;
watcher.Created += (sender, args) =>
{
if (args.FullPath == filePath)
{
gotChange = true;
}
};

watcher.IncludeSubdirectories = true;
watcher.EnableRaisingEvents = true;

physicalFs.WriteAllText($"{physicalDir}{filePath}", "test");
Thread.Sleep(100);
Assert.True(gotChange);
}

[SkippableFact]
public void TestDirectorySymlink()
{
Expand Down

0 comments on commit 073a020

Please sign in to comment.