The OSX FileSystemWatcher coalesces past events of a file into new events. Previously we did some special work to try to filter out those extraneous events to better match the FSW inotify/win32 behavior. However, this had the consequence that we filtered out some valid events. This commit modifies the behavior to raise an event for exactly every flag that the OS API sets. It also modifies the OSX tests to no longer assert that an event *didn't* occur, but to only assert that an event *did* occur.
Commit migrated from https://github.com/dotnet/corefx/commit/1d3cb36b3f23c804cb243be07320c77e22d008c2
Reworks the FSW tests to be 100% passing.
- Adds path validation to most tests.
- Adds a Retry mechanism to handle expected intermittent failures due to untrustworthy underlying API calls.
- Adds more test cases to NotifyFilter and splits existing tests into separate dir/file tests to cover either behavior.
- Enable test parallelization
Commit migrated from https://github.com/dotnet/corefx/commit/28d10fa256f40c3d37a8cb82d96a1e5520df03d2
- Add Common TempDirectory class for short-term temporary directories that are easy to create and destroy
- Put all FSW tests into the System.IO.Tests namespace
- Modify all FSW tests to use the common TempFile/TempDirectory classes instead of their own custom one
- Modify all FSW tests to watch for events in a temporary directory. There shouldn't be any more new items being created or watched in the runtime folder.
- Fix the SymLink tests to use the ConditionalFact attribute similar to how the FileSystem tests function.
- Remove the unnecessary symlink print statements being outputted by the FileSystem CreateSymbolicLink function.
Commit migrated from https://github.com/dotnet/corefx/commit/65356f9471850b796d01f63536c3ba36e504f8e1
When we're waiting for an event that we know will arrive, we can wait for a fairly long time, because if it doesn't arrive we're going to fail the tests anyway. This changes makes all of the ExpectEvent calls use a long timeout, much longer than most were previously using. In the process I removed all of the custom values being passed, as they were all the same or shorter than the new default. This should help to minimize avoid false positive flakiness.
Commit migrated from https://github.com/dotnet/corefx/commit/81e84b7910244f2f72ba760c100b16c01a38877c
Changed the way the UnixFileSystem does File moving; it was previously implemented using the rename syscall but now uses a combination of link and unlink. The side effect of this change is that the FileSystemWatcher will now treat File.Move as a deletion.
- Resolvesdotnet/corefx#2460
- Removed all tests from FileSystemWatcher that made calls to File.Move and consolidated them into a new file: FileSystemWatcher.MoveFile.cs. This new file separates tests into Windows and Unix categories and uses Theories to supply the input WatcherChangeType and whether a move should trigger an event for the given type. If we later decide to change the Unix behavior of MoveFile, changing the FileSystemWatcher tests will be a simple matter of flipping the boolean values for the affected tests.
- Fixed some comments in UnixFileSystem to be more specific to FileSystemWatcher
- Changed variable names for FSW Move tests to be more descriptive
- Modified FSW MoveFile and Utitlity helper classes to use guids so that they may be run concurrently.
Commit migrated from https://github.com/dotnet/corefx/commit/cae7c5116d46c0d98e6f0fb3526fa2a15945501a
In my code review of @sokket's new FileSystemWatcher tests (dotnet/corefx#2347), I'd encouraged him to clean up some of the AutoResetEvents that were being created, in the name of good hygiene. But this introduces a sporadic failure in the tests due to a race condition.
The way that FileSystemWatcher is designed, stopping events on the instance doesn't actually prevent any in-progress operations from being processed, nor does stopping block until all in-process events have completed. As such, if after stopping processing we dispose of an event that's going to be set by one of the callbacks, it's possible such a set could occur from an in-flight operation after we've already disposed of the event, leading to an ObjectDisposedException that crashes the tests.
I contemplated adding synchronization to FSW itself to avoid these kinds of race conditions, e.g. by ensuring that the call to set "Enabled = false;" won't return until all in-progress operations have completed, but that could cause deadlocks not currently possible. As such, I simply stopped explicitly disposing of the events created in the tests, leaving the cleanup to finalization (as is already done for most other events in the tests).
Commit migrated from https://github.com/dotnet/corefx/commit/43bfad63384aee6eb7e20c064054c5e1cd00fbf0