Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address minor feedback suggestions.
  • Loading branch information
carlossanlop committed Sep 20, 2022
commit 42cfe4fad4057387c8f85066497bfa2cfc18b90e
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
<Compile Include="TarWriter\TarWriter.WriteEntry.Entry.V7.Tests.cs" />
<Compile Include="WrappedStream.cs" Link="WrappedStream.cs" />
<Compile Include="$(CommonPath)DisableRuntimeMarshalling.cs" Link="Common\DisableRuntimeMarshalling.cs" />
<Compile Include="$(CommonPath)System\IO\PathInternal.cs" Link="Common\System\IO\PathInternal.cs" />
<Compile Include="$(CommonTestPath)System\IO\ReparsePointUtilities.cs" Link="Common\System\IO\ReparsePointUtilities.cs" />
</ItemGroup>
<!-- Windows specific files -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Generic;
using System.IO;
using System.Linq;
using Xunit;

namespace System.Formats.Tar.Tests
{
Expand All @@ -15,7 +12,7 @@ public static IEnumerable<object[]> WriteEntry_CopyArchive_Data()
{
foreach (CompressionMethod compressionMethod in Enum.GetValues<CompressionMethod>())
{
foreach (bool copyData in new object[] { false, true })
foreach (bool copyData in new bool[] { false, true })
{
foreach (object[] testCaseName in GetV7TestCaseNames())
{
Expand All @@ -29,15 +26,15 @@ public static IEnumerable<object[]> WriteEntry_CopyArchive_Data()

foreach (object[] testCaseNameObj in GetUstarTestCaseNames())
{
string testcaseName = (string)testCaseNameObj[0];
if (testcaseName is "folder_file_utf8" // The legacy name field is stored in ASCII in the Ustar format
string testCaseName = (string)testCaseNameObj[0];
if (testCaseName is "folder_file_utf8" // The legacy name field is stored in ASCII in the Ustar format
or "longpath_splitable_under255" // Folder stored under 'unarchived' runtime-assets due to NuGet not allowing very long paths
or "specialfiles") // Same but for fifos/chardevices/blockdevices
{
continue;
}

yield return new object[] { TestTarFormat.ustar, testcaseName, compressionMethod, copyData };
yield return new object[] { TestTarFormat.ustar, testCaseName, compressionMethod, copyData };
}

foreach (object[] testCaseNameObj in GetPaxAndGnuTestCaseNames())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,10 @@ public void WriteEntry_CopyArchive(TestTarFormat testFormat, string testCaseName
{
TarEntryFormat entryFormat = GetEntryFormatForTestTarFormat(testFormat);
string pathWithExpectedFiles = GetTestCaseUnarchivedFolderPath(testCaseName);
if (!Path.EndsInDirectorySeparator(pathWithExpectedFiles))
{
pathWithExpectedFiles = pathWithExpectedFiles + Path.DirectorySeparatorChar;
}
pathWithExpectedFiles = PathInternal.EnsureTrailingSeparator(pathWithExpectedFiles);

using Stream file = GetTarMemoryStream(compressionMethod, testFormat, testCaseName);
using Stream originArchive = compressionMethod == CompressionMethod.GZip ? new GZipStream(file, CompressionMode.Decompress) : file;
using Stream fileMemoryStream = GetTarMemoryStream(compressionMethod, testFormat, testCaseName);
using Stream originArchive = compressionMethod == CompressionMethod.GZip ? new GZipStream(fileMemoryStream, CompressionMode.Decompress) : fileMemoryStream;

VerifyCopyArchive(pathWithExpectedFiles, originArchive, entryFormat, copyData);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,10 @@ public async Task WriteEntry_CopyArchiveAsync(TestTarFormat testFormat, string t
{
TarEntryFormat entryFormat = GetEntryFormatForTestTarFormat(testFormat);
string pathWithExpectedFiles = GetTestCaseUnarchivedFolderPath(testCaseName);
if (!Path.EndsInDirectorySeparator(pathWithExpectedFiles))
{
pathWithExpectedFiles = pathWithExpectedFiles + Path.DirectorySeparatorChar;
}
pathWithExpectedFiles = PathInternal.EnsureTrailingSeparator(pathWithExpectedFiles);

await using Stream file = GetTarMemoryStream(compressionMethod, testFormat, testCaseName);
await using Stream originArchive = compressionMethod == CompressionMethod.GZip ? new GZipStream(file, CompressionMode.Decompress) : file;
await using Stream fileMemoryStream = GetTarMemoryStream(compressionMethod, testFormat, testCaseName);
await using Stream originArchive = compressionMethod == CompressionMethod.GZip ? new GZipStream(fileMemoryStream, CompressionMode.Decompress) : fileMemoryStream;

await VerifyCopyArchiveAsync(pathWithExpectedFiles, originArchive, entryFormat, copyData);
}
Expand Down