-
Notifications
You must be signed in to change notification settings - Fork 484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable parallel test execution #404
Merged
adamhathcock
merged 23 commits into
adamhathcock:master
from
MattKotsenas:bugfix/idisposable
Jul 12, 2018
Merged
Enable parallel test execution #404
adamhathcock
merged 23 commits into
adamhathcock:master
from
MattKotsenas:bugfix/idisposable
Jul 12, 2018
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Move the `TestStream` and `ForwardOnlyStream` to Mocks/ to separate them from the test classes.
- Remove the duplicate `GC.SuppressFinalization` call (called in `System.IO.Stream) - Improve the `ThrowOnDispose` error message
Update the sub-stream classes to all inherit from `NonDisposingStream`. This allows them to correctly implement the `Dispose` pattern, and delegate the actual disposal to `NonDisposingStream`. In doing so, we need to remove some redundant overrides from `NonDisposingStream`, otherwise `BufferedSubStream` would use the overrides inherited from `NonDisposingStream` instead of the ones inherited from `Stream` (i.e. delegate `ReadByte` to `Read`).
`ArchiveFactory.Open` has two overloads that take `string` or `FileInfo` (string delegates to FileInfo). Both of these implementations open a `Stream` with the default `ReaderOptions`, which leaves the stream open, resulting in a leak. The fix is to set `LeaveOpen` to `false` if no options were provided. Note that if a user was provding options and `LeaveOpen` was set to `true`, the code did and will still leak.
The `IEnumerable<string>` version of `ReaderTests` is unused, so delete it to simplify the code.
Update `RarHeaderFactoryTests` and `GZipArchiveTests` to open the test readers as `FileAccess.Read` and `FileShare.Read` to prevent issues with multiple test from trying to open exclusive access to files.
Refactor `ListeningStream`: - Override of `WriteByte` was redundant and removed - Make `Dispose` delegate to base class
`AppendingStream` is unused, so rather than refactor it, just delete it.
Update `Volume` and `ForwardOnlyStream` to follow the project's general pattern and best-practices for `Dispose`
Refactor the `TestStream` constructor so by default it defers to the underlying Stream
Update the `ReaderTests` base class to validate that `Dispose` is called appropriately in both the close and the leave open cases.
Delete `NonSeekableStream` used in Zip64 tests in favor of `ForwardOnlyStream` used in Mocks. Additionally, delete the `ForwardOnlyStream.ReadByte` implementation as the implementation on the base Stream is sufficient.
- Refactor `RarReaderTests` to use `ReaderFactory` - Update `ReaderTests.Read` to support Rar tests
Refactor `TestSharpCompressWithEmptyStream` so it asserts that the files and bytes are the same.
Now that the sources of file locking are fixed, enable test parallelization and the forced garbage collection workaround. Lastly, remove the `IsLocked` check because it doesn't work in a parallel test running world - the file may be locked due to another test running.
Fixes #58 |
Fixes #237 |
MattKotsenas
changed the title
Enabled parallel test execution
Enable parallel test execution
Jul 12, 2018
adamhathcock
approved these changes
Jul 12, 2018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great clean up. I've needed someone to give this a fresh pair of eyes forever. Thank you!
Thank you for your quick response! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Enable test execution by fixing two classes of file locking problems:
IDisposable
in the librarySolving these problems generally had one of two solutions:
NonDisposingStream
in additional places so types that were "borrowing" a stream could still follow theDispose
pattern without upsetting code analysisLastly, the
IsLocked
check inTestBase
had to be removed because it isn't parallel-test-execution-aware. Some of that gap is closed by the expanded test coverage inReaderTests
, though more is certainly welcome. I chose to stop here to avoid making the PR unmanageable.