Three tests were consuming the vast majority of the time:
- DirectoryLongerThanMaxLongPathWithExtendedSyntax_ThrowsPathTooLongException. It was taking 70 seconds on my machine. I moved it to outer loop.
- ManyConcurrentWriteAsyncs. It uses a MemberData that results in it executing ~40 times, for a combined time of around 7 seconds on my machine. I made one combination run in inner loop and moved the rest to outer.
- CopyToAsyncBetweenFileStreams. Same MemberData, same solution.
Commit migrated from https://github.com/dotnet/corefx/commit/03205295cc6834b1fdcd8b7ba364515f4ec7164a
- Mainly, I added several tests (with lots of theory-based parameterized inputs) to stress WriteAsync: many concurrent writes, long chains of writes, etc., for various size inputs and buffers, async vs not, etc.
- There were multiple variations on Flush tests based on whether to use Flush(), Flush(false), or False(true). I combined these all into single theories.
- I then added some more Flush tests for some missing cases highlighted by code coverage, e.g. flushing reads.
- I then duplicated these tests for FlushAsync, and added some additional tests specific to FlushAsync, e.g. cancellation.
- I added a few tests for pipes.
Commit migrated from https://github.com/dotnet/corefx/commit/bb34d5a458613faa39d3808a8a352e62e3bcf52f
1) Internal buffer overflows, but write can fit in next buffer - Fill the existing buffer, copy the remaining data into a new buffer, and flush the original to disk
2) Internal buffer is non-empty, overflows, and the remaining data won't fit in a second buffer - Chain the flush operation to a second write operation which writes the entire incoming block directly to disk.
Additionally, adds a new unit test to ensure the different buffering cases are being covered.
Commit migrated from https://github.com/dotnet/corefx/commit/b69caa929d3cb3b87574ee31a651d799f61e3a75
- References dotnet/corefx#2460. File.Move and FileInfo.MoveTo no longer always overwrite the destination file; added a non-concurrent validity check to MoveFile in the Unix implementation to serve as a temporary solution.
- Resolvesdotnet/corefx#2459. Reenabled Directory_CreateDirectory.DriveLetter_Unix as it's previous failures were not the fault of the method but of the system.
- Added test checks to work around the issue in dotnet/corefx#2537 until a final decision is reached for the desktop.
- Added Interop.Link to the Interop files for the (possible) implementation of File.Move
- Consolidated all of the related files that did nothing but inherit from other classes (e.g. File_GetFiles_str and File_GetFiles_str_str were consolidated into File_GetFiles)
- Removed the "partial" keyword from some test classes
- Finished overhauling all test cases that don't directly require solutions to Build System issues before being re-added (e.g. those that require networked drives or altering the current directory)
- Added some tests to increase code coverage slightly in some cases.
- All classes and files have been renamed to match the standard set by FileStream: only include parameters in the test/class name if there are overloads
- Modified the Unix behavior for distinguishing between a FileNotFoundException and a DirectoryNotFoundException to match that of Windows.
- Removed some redundant error checks that never catch
- DirectoryInfo.MoveTo(destPath) did not have checks for destinations with paths that are over MAXPATH. I added them to better match the behavior and error timing of Directory.Move(source, dest).
Commit migrated from https://github.com/dotnet/corefx/commit/481d5c645763da79145af50d123db3f4041aa05e
UnixFileStream.Seek was dumping the read buffer as desired, but with a SeekOrigin.Current, it wasn't factoring in the read buffer information into the offset (the fact that we have a read buffer means that the caller's definition of "Current" doesn't match the actual underlying file descriptor's position). This fix just updates the offset (as is correctly done in similar code in the Win32FileStream implementation) based on how much data we have in the read buffer.
I've also added a seek test that repeatedly seeks around and reads data. It blows up without the fix and passes with it.
Commit migrated from https://github.com/dotnet/corefx/commit/563f4977543f483ce1a5df8b9ffd9f96ffe0921f
Prior to this set of changes, 110 of the FileSystem tests were failing on Linux. After this change, all allowed tests pass.
Primary product fixes:
- Using rmdir/unlink for directory/file deletion rather than using remove
- Disallowing FileStreams to be opened for directories
- Supporting copying files when only target directory (not target name) is specified
- Overhauling directory enumeration to ensure to match Win32 behaviors related to search pattern normalization, input validation, supporting re-iteration through an enumerable, outputting partial paths based on user-supplied path, using a SafeHandle to ensure resources are cleaned up
- Fixing FileSystemObject.LastWriteTime to correctly return the LastWriteTime rather than LastAccessTime
- Fixing FileAttributes.ReadOnly handling due to inappropriate caching
- Validating inputs to FileSystemObject.Attributes, and make sure that changes to attributes are visible afterwards
- Adding support for getting CreationTime if it's supported by the OS
- Marking links with FileAttributes.ReparsePoint
- Working around current runtime bug related to exception handling and finally blocks getting executed twice
Primary test fixes:
- Suppressing tests as platform-specific that dependend on Win32-isms like drive letters, alternate data streams, etc.
- Changing a bunch of '\' usage to instead use Path.DirectorySeparatorChar or Path.Combine
- Adapting to behavioral differences between Windows and Unix, e.g. whether a directory can be deleted if it's readonly, invalid path characters, max path lengths, file sharing differences, etc.
These changes should all accrue to OSX as well, but we'll need to separately do an exercise to clean this library and tests up there for anything OSX-specific.
Commit migrated from https://github.com/dotnet/corefx/commit/dd48c9dc1f0a7142a005ff1d4c162e10facda306
There are 338 System.IO.FileSystem tests currently passing on Windows. On Linux, 65 of these are currently failing, mostly negative tests expecting a certain exception and getting a different actual one or none at all.
This commit fixes 40 of those, mostly via product fixes, plus a few test tweaks (where the test was based on something specific to Windows), such that now only 25 are failing. Of those 25, 24 are tests for FileSharing that are expecting exceptions not being generated on Linux because that support isn't available in the library; we'll most likely just disable these tests for Linux. The remaining 1 test fails because it's expecting ReadAsync to complete synchronously if the read can be satisfied from the read buffer, and the current ReadAsync/WriteAsync implementations just delegate to the base class for functionality; we already have a work item open to eventually address that.
Commit migrated from https://github.com/dotnet/corefx/commit/8062cc0dbed1ad31b9e6d438ddc71d91ee066031