You've already forked linux-packaging-mono
Imported Upstream version 5.10.0.47
Former-commit-id: d0813289fa2d35e1f8ed77530acb4fb1df441bc0
This commit is contained in:
parent
88ff76fe28
commit
e46a49ecf1
@@ -87,8 +87,6 @@ namespace System.IO.Tests
|
||||
WatcherChangeTypes expected = 0;
|
||||
if (filter == NotifyFilters.DirectoryName)
|
||||
expected |= WatcherChangeTypes.Renamed;
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && (filter == NotifyFilters.FileName))
|
||||
expected |= WatcherChangeTypes.Renamed;
|
||||
|
||||
ExpectEvent(watcher, expected, action, cleanup, targetPath);
|
||||
}
|
||||
@@ -140,6 +138,33 @@ namespace System.IO.Tests
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[OuterLoop]
|
||||
[MemberData(nameof(FilterTypes))]
|
||||
public void FileSystemWatcher_Directory_NotifyFilter_LastWriteTime_TwoFilters(NotifyFilters filter)
|
||||
{
|
||||
Assert.All(FilterTypes(), (filter2Arr =>
|
||||
{
|
||||
using (var testDirectory = new TempDirectory(GetTestFilePath()))
|
||||
using (var dir = new TempDirectory(Path.Combine(testDirectory.Path, "dir")))
|
||||
using (var watcher = new FileSystemWatcher(testDirectory.Path, Path.GetFileName(dir.Path)))
|
||||
{
|
||||
filter |= (NotifyFilters)filter2Arr[0];
|
||||
watcher.NotifyFilter = filter;
|
||||
Action action = () => Directory.SetLastWriteTime(dir.Path, DateTime.Now + TimeSpan.FromSeconds(10));
|
||||
|
||||
WatcherChangeTypes expected = 0;
|
||||
if ((filter & NotifyFilters.LastWrite) > 0)
|
||||
expected |= WatcherChangeTypes.Changed;
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && ((filter & LinuxFiltersForAttribute) > 0))
|
||||
expected |= WatcherChangeTypes.Changed;
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && ((filter & OSXFiltersForModify) > 0))
|
||||
expected |= WatcherChangeTypes.Changed;
|
||||
ExpectEvent(watcher, expected, action, expectedPath: dir.Path);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(FilterTypes))]
|
||||
[PlatformSpecific(TestPlatforms.Windows)] // Uses P/Invokes to set security info
|
||||
@@ -255,5 +280,35 @@ namespace System.IO.Tests
|
||||
ExpectEvent(watcher, expected, action, cleanup, new string[] { otherDir, dir.Path });
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FileSystemWatcher_Directory_NotifyFilter_DirectoryNameDoesntTriggerOnFileEvent()
|
||||
{
|
||||
using (var testDirectory = new TempDirectory(GetTestFilePath()))
|
||||
using (var dir = new TempDirectory(Path.Combine(testDirectory.Path, "dir")))
|
||||
using (var watcher = new FileSystemWatcher(testDirectory.Path, "*"))
|
||||
{
|
||||
watcher.NotifyFilter = NotifyFilters.FileName;
|
||||
string renameDirSource = Path.Combine(testDirectory.Path, "dir2_source");
|
||||
string renameDirDest = Path.Combine(testDirectory.Path, "dir2_dest");
|
||||
string otherDir = Path.Combine(testDirectory.Path, "dir3");
|
||||
Directory.CreateDirectory(renameDirSource);
|
||||
|
||||
Action action = () =>
|
||||
{
|
||||
Directory.CreateDirectory(otherDir);
|
||||
Directory.Move(renameDirSource, renameDirDest);
|
||||
Directory.SetLastWriteTime(dir.Path, DateTime.Now + TimeSpan.FromSeconds(10));
|
||||
Directory.Delete(otherDir);
|
||||
};
|
||||
Action cleanup = () =>
|
||||
{
|
||||
Directory.Move(renameDirDest, renameDirSource);
|
||||
};
|
||||
|
||||
WatcherChangeTypes expected = 0;
|
||||
ExpectEvent(watcher, expected, action, cleanup, new string[] { otherDir, dir.Path });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -102,4 +102,4 @@ namespace System.IO.Tests
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,9 +91,6 @@ namespace System.IO.Tests
|
||||
|
||||
if (filter == NotifyFilters.DirectoryName)
|
||||
expected |= WatcherChangeTypes.Renamed;
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && (filter == NotifyFilters.FileName))
|
||||
expected |= WatcherChangeTypes.Renamed;
|
||||
|
||||
ExpectEvent(watcher, expected, action, cleanup, targetPath);
|
||||
}
|
||||
}
|
||||
@@ -167,6 +164,36 @@ namespace System.IO.Tests
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[OuterLoop]
|
||||
[MemberData(nameof(FilterTypes))]
|
||||
public void FileSystemWatcher_File_NotifyFilter_Size_TwoFilters(NotifyFilters filter)
|
||||
{
|
||||
Assert.All(FilterTypes(), (filter2Arr =>
|
||||
{
|
||||
using (var testDirectory = new TempDirectory(GetTestFilePath()))
|
||||
using (var file = new TempFile(Path.Combine(testDirectory.Path, "file")))
|
||||
using (var watcher = new FileSystemWatcher(testDirectory.Path, Path.GetFileName(file.Path)))
|
||||
{
|
||||
filter |= (NotifyFilters)filter2Arr[0];
|
||||
watcher.NotifyFilter = filter;
|
||||
Action action = () => File.AppendAllText(file.Path, "longText!");
|
||||
Action cleanup = () => File.AppendAllText(file.Path, "short");
|
||||
|
||||
WatcherChangeTypes expected = 0;
|
||||
if (((filter & NotifyFilters.Size) > 0) || ((filter & NotifyFilters.LastWrite) > 0))
|
||||
expected |= WatcherChangeTypes.Changed;
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && ((filter & LinuxFiltersForModify) > 0))
|
||||
expected |= WatcherChangeTypes.Changed;
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && ((filter & OSXFiltersForModify) > 0))
|
||||
expected |= WatcherChangeTypes.Changed;
|
||||
else if (PlatformDetection.IsWindows7 && ((filter & NotifyFilters.Attributes) > 0)) // win7 FSW Size change passes the Attribute filter
|
||||
expected |= WatcherChangeTypes.Changed;
|
||||
ExpectEvent(watcher, expected, action, expectedPath: file.Path);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(FilterTypes))]
|
||||
[PlatformSpecific(TestPlatforms.Windows)] // Uses P/Invokes to set security info
|
||||
@@ -281,5 +308,34 @@ namespace System.IO.Tests
|
||||
ExpectEvent(watcher, expected, action, cleanup, new string[] { otherFile, file.Path });
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FileSystemWatcher_File_NotifyFilter_FileNameDoesntTriggerOnDirectoryEvent()
|
||||
{
|
||||
using (var testDirectory = new TempDirectory(GetTestFilePath()))
|
||||
using (var file = new TempFile(Path.Combine(testDirectory.Path, "file")))
|
||||
using (var sourcePath = new TempFile(Path.Combine(testDirectory.Path, "sourceFile")))
|
||||
using (var watcher = new FileSystemWatcher(testDirectory.Path, "*"))
|
||||
{
|
||||
watcher.NotifyFilter = NotifyFilters.DirectoryName;
|
||||
string otherFile = Path.Combine(testDirectory.Path, "file2");
|
||||
string destPath = Path.Combine(testDirectory.Path, "destFile");
|
||||
|
||||
Action action = () =>
|
||||
{
|
||||
File.Create(otherFile).Dispose();
|
||||
File.SetLastWriteTime(file.Path, DateTime.Now + TimeSpan.FromSeconds(10));
|
||||
File.Delete(otherFile);
|
||||
File.Move(sourcePath.Path, destPath);
|
||||
};
|
||||
Action cleanup = () =>
|
||||
{
|
||||
File.Move(destPath, sourcePath.Path);
|
||||
};
|
||||
|
||||
WatcherChangeTypes expected = 0;
|
||||
ExpectEvent(watcher, expected, action, cleanup, new string[] { otherFile, file.Path });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -497,7 +497,7 @@ namespace System.IO.Tests
|
||||
watcher.Path = ".";
|
||||
Assert.Equal(".", watcher.Path);
|
||||
|
||||
if (!PlatformDetection.IsWinRT)
|
||||
if (!PlatformDetection.IsInAppContainer)
|
||||
{
|
||||
watcher.Path = "..";
|
||||
Assert.Equal("..", watcher.Path);
|
||||
|
||||
@@ -43,9 +43,6 @@
|
||||
<Compile Include="$(CommonTestPath)\System\IO\TempDirectory.cs">
|
||||
<Link>Common\System\IO\TempDirectory.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonTestPath)\System\PlatformDetection.cs">
|
||||
<Link>Common\System\PlatformDetection.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
</Project>
|
||||
|
||||
@@ -202,26 +202,14 @@ namespace System.IO.Tests
|
||||
AutoResetEvent changed = null, created = null, deleted = null, renamed = null;
|
||||
string[] expectedFullPaths = expectedPaths == null ? null : expectedPaths.Select(e => Path.GetFullPath(e)).ToArray();
|
||||
|
||||
// On OSX we get a number of extra events tacked onto valid events. As such, we can not ever confidently
|
||||
// say that a event won't occur, only that one will occur.
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
{
|
||||
if (verifyChanged = ((expectedEvents & WatcherChangeTypes.Changed) > 0))
|
||||
changed = WatchChanged(watcher, expectedPaths);
|
||||
if (verifyCreated = ((expectedEvents & WatcherChangeTypes.Created) > 0))
|
||||
created = WatchCreated(watcher, expectedPaths);
|
||||
if (verifyDeleted = ((expectedEvents & WatcherChangeTypes.Deleted) > 0))
|
||||
deleted = WatchDeleted(watcher, expectedPaths);
|
||||
if (verifyRenamed = ((expectedEvents & WatcherChangeTypes.Renamed) > 0))
|
||||
renamed = WatchRenamed(watcher, expectedPaths);
|
||||
}
|
||||
else
|
||||
{
|
||||
changed = WatchChanged(watcher, (expectedEvents & WatcherChangeTypes.Changed) > 0 ? expectedPaths : null);
|
||||
created = WatchCreated(watcher, (expectedEvents & WatcherChangeTypes.Created) > 0 ? expectedPaths : null);
|
||||
deleted = WatchDeleted(watcher, (expectedEvents & WatcherChangeTypes.Deleted) > 0 ? expectedPaths : null);
|
||||
renamed = WatchRenamed(watcher, (expectedEvents & WatcherChangeTypes.Renamed) > 0 ? expectedPaths : null);
|
||||
}
|
||||
if (verifyChanged = ((expectedEvents & WatcherChangeTypes.Changed) > 0))
|
||||
changed = WatchChanged(watcher, expectedPaths);
|
||||
if (verifyCreated = ((expectedEvents & WatcherChangeTypes.Created) > 0))
|
||||
created = WatchCreated(watcher, expectedPaths);
|
||||
if (verifyDeleted = ((expectedEvents & WatcherChangeTypes.Deleted) > 0))
|
||||
deleted = WatchDeleted(watcher, expectedPaths);
|
||||
if (verifyRenamed = ((expectedEvents & WatcherChangeTypes.Renamed) > 0))
|
||||
renamed = WatchRenamed(watcher, expectedPaths);
|
||||
|
||||
watcher.EnableRaisingEvents = true;
|
||||
action();
|
||||
@@ -443,4 +431,4 @@ namespace System.IO.Tests
|
||||
NotifyFilters.LastWrite |
|
||||
NotifyFilters.Size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user