Skip to content

Commit

Permalink
Merge pull request #895 from Morilli/fix-test-concurrency
Browse files Browse the repository at this point in the history
use File.OpenRead instead of File.Open in tests to allow concurrent access
  • Loading branch information
adamhathcock authored Feb 11, 2025
2 parents 55797e5 + d560b46 commit 96b34ae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions tests/SharpCompress.Test/Zip/ZipArchiveTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ public void Zip_Deflate_PKWear_Multipy_Entry_Access()
{
var zipFile = Path.Combine(TEST_ARCHIVES_PATH, "Zip.deflate.pkware.zip");

using var fileStream = File.Open(zipFile, FileMode.Open);
using var fileStream = File.OpenRead(zipFile);
using var archive = ArchiveFactory.Open(
fileStream,
new ReaderOptions { Password = "12345678" }
Expand Down Expand Up @@ -729,7 +729,7 @@ public void Zip_Zip64_CompressedSizeExtraOnly_Read()
public void Zip_Uncompressed_Read_All()
{
var zipPath = Path.Combine(TEST_ARCHIVES_PATH, "Zip.uncompressed.zip");
using var stream = File.Open(zipPath, FileMode.Open, FileAccess.Read);
using var stream = File.OpenRead(zipPath);
var archive = ArchiveFactory.Open(stream);
var reader = archive.ExtractAllEntries();
var entries = 0;
Expand Down Expand Up @@ -758,7 +758,7 @@ public void Zip_Uncompressed_Skip_All()
"DEADBEEF",
};
var zipPath = Path.Combine(TEST_ARCHIVES_PATH, "Zip.uncompressed.zip");
using var stream = File.Open(zipPath, FileMode.Open, FileAccess.Read);
using var stream = File.OpenRead(zipPath);
var archive = ArchiveFactory.Open(stream);
var reader = archive.ExtractAllEntries();
var x = 0;
Expand All @@ -775,7 +775,7 @@ public void Zip_Uncompressed_Skip_All()
public void Zip_Forced_Ignores_UnicodePathExtra()
{
var zipPath = Path.Combine(TEST_ARCHIVES_PATH, "Zip.UnicodePathExtra.zip");
using (var stream = File.Open(zipPath, FileMode.Open, FileAccess.Read))
using (var stream = File.OpenRead(zipPath))
{
var archive = ArchiveFactory.Open(
stream,
Expand All @@ -791,7 +791,7 @@ public void Zip_Forced_Ignores_UnicodePathExtra()
reader.MoveToNextEntry();
Assert.Equal("궖귛궖귙귪궖귗귪궖귙_wav.frq", reader.Entry.Key);
}
using (var stream = File.Open(zipPath, FileMode.Open, FileAccess.Read))
using (var stream = File.OpenRead(zipPath))
{
var archive = ArchiveFactory.Open(
stream,
Expand Down
6 changes: 3 additions & 3 deletions tests/SharpCompress.Test/Zip/ZipReaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ public void Issue_685()
public void Zip_ReaderFactory_Uncompressed_Read_All()
{
var zipPath = Path.Combine(TEST_ARCHIVES_PATH, "Zip.uncompressed.zip");
using var stream = File.Open(zipPath, FileMode.Open, FileAccess.Read);
using var stream = File.OpenRead(zipPath);
using var reader = ReaderFactory.Open(stream);
while (reader.MoveToNextEntry())
{
Expand All @@ -355,7 +355,7 @@ public void Zip_ReaderFactory_Uncompressed_Read_All()
public void Zip_ReaderFactory_Uncompressed_Skip_All()
{
var zipPath = Path.Combine(TEST_ARCHIVES_PATH, "Zip.uncompressed.zip");
using var stream = File.Open(zipPath, FileMode.Open, FileAccess.Read);
using var stream = File.OpenRead(zipPath);
using var reader = ReaderFactory.Open(stream);
while (reader.MoveToNextEntry()) { }
}
Expand All @@ -364,7 +364,7 @@ public void Zip_ReaderFactory_Uncompressed_Skip_All()
public void Zip_Uncompressed_64bit()
{
var zipPath = Path.Combine(TEST_ARCHIVES_PATH, "64bitstream.zip.7z");
using var stream = File.Open(zipPath, FileMode.Open, FileAccess.Read);
using var stream = File.OpenRead(zipPath);
var archive = ArchiveFactory.Open(stream);
var reader = archive.ExtractAllEntries();
reader.MoveToNextEntry();
Expand Down

0 comments on commit 96b34ae

Please sign in to comment.