镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Tar tests deduplicate - #130407

Merged
alinpahontu2912 merged 29 commits into
dotnet:mainfrom
alinpahontu2912:tar_tests_deduplicate
Sep 30, 2026
Merged

alinpahontu2912 merged 29 commits into
dotnet:mainfrom
alinpahontu2912:tar_tests_deduplicate

Conversation

@alinpahontu2912

Copy link
Copy Markdown
Member

Fixes #127379

alinpahontu2912 and others added 5 commits July 9, 2026 14:56
Introduce helper methods and Get_Boolean_Data() that allow Tar tests to
be parameterized by a bool to exercise both sync and async code paths
from a single test method. Follows the same pattern used by ZipArchive
tests (see ZipTestHelper.cs). The bool async parameter is always last.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Merge TarReader async test files into their sync counterparts using the
bool async parameter pattern with [MemberData(nameof(Get_Boolean_Data))].

Merged and deleted:
- TarReader.Async.Tests.cs
- TarReader.GetNextEntryAsync.Tests.cs
- TarReader.File.Async.Tests.cs + Base
- TarReader.File.GlobalExtendedAttributes.Async.Tests.cs
- TarReader.TarEntry.ExtractToFileAsync.Tests.cs (+ Unix)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Merge TarWriter async test files into their sync counterparts using the
bool async parameter pattern.

Merged and deleted:
- TarWriter.Async.Tests.cs
- TarWriter.WriteEntryAsync.Tests.cs
- TarWriter.WriteEntryAsync.Entry.{Gnu,Pax,Ustar,V7,Roundtrip}.Tests.cs
- TarWriter.WriteEntryAsync.File.Tests.cs (+ Unix, Windows)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Merge remaining async test files into their sync counterparts.

Merged and deleted:
- CompressedTar.Async.Tests.cs
- TarEntry.ExtractToFileAsync.Tests.cs
- TarFile.CreateFromDirectoryAsync.{File,Stream}.Tests.cs
- TarFile.CreateFromDirectoryAsync.File.Roundtrip.cs
- TarFile.ExtractToDirectoryAsync.{File,Stream}.Tests.cs
- TarFile.ExtractToDirectoryAsync.File.Tests.{Unix,Windows}.cs

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-formats-tar
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restructures System.Formats.Tar tests to remove duplicated sync vs async variants by introducing shared helpers and updating existing tests to exercise both code paths within a single test definition (typically via a bool async parameter or a loop over { false, true }). It also removes now-redundant *Async* test files and updates the test project file accordingly.

Changes:

  • Added TarTestsBase.Helpers.cs with helper methods to abstract sync/async Tar APIs and provide boolean theory data.
  • Migrated many TarWriter/TarReader/TarFile/TarEntry tests to cover both sync and async paths without separate *Async* test files.
  • Removed a set of redundant async-only test files and updated System.Formats.Tar.Tests.csproj compile items.

Reviewed changes

Copilot reviewed 54 out of 54 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntryAsync.File.Tests.Windows.cs Deleted redundant async-only TarWriter-from-file Windows tests (coverage moved to unified tests).
src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntryAsync.File.Tests.Unix.cs Deleted redundant async-only TarWriter-from-file Unix tests (coverage moved to unified tests).
src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntryAsync.File.Tests.cs Deleted redundant async-only TarWriter-from-file common tests (coverage moved to unified tests).
src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntryAsync.Entry.V7.Tests.cs Deleted redundant async-only V7-entry writer tests (coverage moved to unified tests).
src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntryAsync.Entry.Ustar.Tests.cs Deleted redundant async-only Ustar-entry writer tests (coverage moved to unified tests).
src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntryAsync.Entry.Pax.Tests.cs Deleted redundant async-only Pax-entry writer tests (coverage moved to unified tests).
src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntryAsync.Entry.Gnu.Tests.cs Deleted redundant async-only Gnu-entry writer tests (coverage moved to unified tests).
src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntryAsync.Entry.Roundtrip.Tests.cs Deleted redundant async-only roundtrip tests (coverage moved to unified tests).
src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.Async.Tests.cs Deleted redundant async-only TarWriter tests (coverage moved to unified tests).
src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.File.Tests.Windows.cs Updated Windows-specific TarWriter-from-file tests to run both sync and async paths.
src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.File.Tests.cs Updated common TarWriter-from-file tests to run both sync and async paths using helpers.
src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.Entry.V7.Tests.cs Updated V7 entry write tests to exercise both sync and async write/read/dispose paths.
src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.Entry.Ustar.Tests.cs Updated Ustar entry write tests to exercise both sync and async write/read/dispose paths.
src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.Entry.Roundtrip.Tests.cs Updated entry roundtrip tests to cover both sync and async paths via shared helpers.
src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.Tests.cs Consolidated async-only TarWriter tests into unified tests covering both paths.
src/libraries/System.Formats.Tar/tests/TarReader/TarReader.Async.Tests.cs Deleted redundant async-only TarReader tests (coverage moved to unified tests).
src/libraries/System.Formats.Tar/tests/TarReader/TarReader.Tests.cs Updated TarReader tests to cover both sync and async entry enumeration / disposal behaviors.
src/libraries/System.Formats.Tar/tests/TarReader/TarReader.File.GlobalExtendedAttributes.Async.Tests.cs Deleted redundant async-only GEA tests (coverage moved to unified tests).
src/libraries/System.Formats.Tar/tests/TarReader/TarReader.File.GlobalExtendedAttributes.Tests.cs Updated GEA tests to run both sync and async via shared helpers.
src/libraries/System.Formats.Tar/tests/TarReader/TarReader.TarEntry.ExtractToFileAsync.Tests.Unix.cs Deleted redundant async-only Unix extract tests (coverage moved to unified tests).
src/libraries/System.Formats.Tar/tests/TarReader/TarReader.TarEntry.ExtractToFileAsync.Tests.cs Deleted redundant async-only extract tests (coverage moved to unified tests).
src/libraries/System.Formats.Tar/tests/TarReader/TarReader.TarEntry.ExtractToFile.Tests.Unix.cs Updated Unix extract tests to run both sync and async via shared helpers.
src/libraries/System.Formats.Tar/tests/TarReader/TarReader.TarEntry.ExtractToFile.Tests.cs Updated extract tests to run both sync and async via shared helpers.
src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.File.Tests.Windows.cs Deleted redundant async-only Windows extract-to-directory tests (coverage moved to unified tests).
src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.File.Tests.Unix.cs Deleted redundant async-only Unix extract-to-directory tests (coverage moved to unified tests).
src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.File.Tests.cs Deleted redundant async-only extract-to-directory tests (coverage moved to unified tests).
src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.File.Tests.Windows.cs Updated Windows extract-to-directory tests to cover sync+async via helpers.
src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.File.Tests.Unix.cs Updated Unix extract-to-directory tests to cover sync+async via helpers.
src/libraries/System.Formats.Tar/tests/TarFile/TarFile.CreateFromDirectoryAsync.Stream.Tests.cs Deleted redundant async-only create-from-directory(stream) tests (coverage moved to unified tests).
src/libraries/System.Formats.Tar/tests/TarFile/TarFile.CreateFromDirectoryAsync.File.Tests.cs Deleted redundant async-only create-from-directory(file) tests (coverage moved to unified tests).
src/libraries/System.Formats.Tar/tests/TarFile/TarFile.CreateFromDirectoryAsync.File.Roundtrip.cs Deleted redundant async-only create-from-directory roundtrip tests (coverage moved to unified tests).
src/libraries/System.Formats.Tar/tests/TarFile/TarFile.CreateFromDirectory.Stream.Tests.cs Updated stream-based create-from-directory tests to cover both sync and async.
src/libraries/System.Formats.Tar/tests/TarFile/TarFile.CreateFromDirectory.File.Roundtrip.cs Updated create-from-directory roundtrip tests to cover both sync and async.
src/libraries/System.Formats.Tar/tests/TarEntry/TarEntry.ExtractToFileAsync.Tests.cs Deleted redundant async-only TarEntry extract-to-file tests (coverage moved to unified tests).
src/libraries/System.Formats.Tar/tests/TarEntry/TarEntry.ExtractToFile.Tests.cs Updated TarEntry extract-to-file tests to cover both sync and async via helpers.
src/libraries/System.Formats.Tar/tests/CompressedTar.Async.Tests.cs Deleted redundant async-only compressed tar tests (coverage moved to unified tests).
src/libraries/System.Formats.Tar/tests/CompressedTar.Tests.cs Updated compressed tar tests to cover both sync and async paths and fix extracted-path assertion.
src/libraries/System.Formats.Tar/tests/TarTestsBase.Helpers.cs Added shared helpers for sync/async parameterization (writer/reader creation, disposal, operations).
src/libraries/System.Formats.Tar/tests/System.Formats.Tar.Tests.csproj Updated compile items to remove deleted async-only test files and include the new helper file.

Comment thread src/libraries/System.Formats.Tar/tests/TarTestsBase.Helpers.cs Outdated
Comment thread src/libraries/System.Formats.Tar/tests/TarTestsBase.Helpers.cs Outdated
Copilot AI review requested due to automatic review settings July 9, 2026 13:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 54 out of 54 changed files in this pull request and generated 2 comments.

Comment thread src/libraries/System.Formats.Tar/tests/TarTestsBase.Helpers.cs Outdated
Comment thread src/libraries/System.Formats.Tar/tests/TarTestsBase.Helpers.cs Outdated
Copilot AI review requested due to automatic review settings July 9, 2026 13:52
@alinpahontu2912
alinpahontu2912 force-pushed the tar_tests_deduplicate branch from 387982c to 8db6312 Compare July 9, 2026 13:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 54 out of 54 changed files in this pull request and generated 2 comments.

Comment thread src/libraries/System.Formats.Tar/tests/TarTestsBase.Helpers.cs Outdated
Comment thread src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.Tests.cs
Copilot AI review requested due to automatic review settings July 9, 2026 14:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 54 out of 54 changed files in this pull request and generated 2 comments.

Comment thread src/libraries/System.Formats.Tar/tests/TarTestsBase.Helpers.cs
Copilot AI review requested due to automatic review settings July 10, 2026 08:26

@rzikm rzikm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were getting there, I left few more comments

Comment thread src/libraries/System.Formats.Tar/tests/TarReader/TarReader.File.Tests.cs Outdated
Copilot AI review requested due to automatic review settings September 21, 2026 07:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Several converted tests still use synchronous-only verification paths, and the new inherited test base introduces redundant Pax test executions.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 3 Low severity

Open (3)
Previously missed (2)

In code that hasn't changed since last review

Low severity Async extraction test does not cover asynchronous reader path

src/​libraries/​System.Formats.Tar/​tests/​TarFile/​TarFile.ExtractToDirectory.File.Tests.cs:230

The new async parameter only controls extraction here; the verification loop still calls TarReader.GetNextEntry() synchronously. As a result, the async: true case does not cover the asynchronous reader path. Use TarReaderHolder and GetNextEntry(reader, async: async) for this verification, matching the other merged sync/async tests.

Low severity Remove unused synchronous CreateTarReader overload

src/​libraries/​System.Formats.Tar/​tests/​TarTestsBase.Helpers.cs:85

This sync-only overload has no call sites in the System.Formats.Tar tests; every CreateTarReader use resolves to the TarReaderHolder overload with an async flag. Keeping it adds dead API surface to the shared test base and makes overload selection harder to understand; remove it.

Copilot AI review requested due to automatic review settings September 24, 2026 08:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Async verification and disposal coverage remain incomplete, and an unused helper overload should be removed.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Low severity

Open (1)
Resolved since last review (3)
Previously missed (3)

In code that hasn't changed since last review

Low severity Async extraction test still verifies with synchronous TarReader

src/​libraries/​System.Formats.Tar/​tests/​TarFile/​TarFile.ExtractToDirectory.File.Tests.cs:230

The new async parameter selects ExtractToDirectory, but this verification still constructs a plain TarReader and calls synchronous GetNextEntry(). Thus the async: true case does not exercise asynchronous reading in this test. Use CreateTarReader/TarReaderHolder and GetNextEntry(reader, async: async) for the verification loop.

Low severity Async round-trip verification does not exercise GetNextEntryAsync

src/​libraries/​System.Formats.Tar/​tests/​TarFile/​TarFile.ExtractToDirectory.Stream.Tests.cs:288

This test now parameterizes archive extraction and uses asynchronous stream reads when async is true, but the archive verification still uses a synchronous TarReader at line 296. The async case therefore misses GetNextEntryAsync; create the reader through TarReaderHolder with the same flag so the round-trip covers both reader paths.

Low severity Remove unused CreateTarReader overload

src/​libraries/​System.Formats.Tar/​tests/​TarTestsBase.Helpers.cs:85

CreateTarReader(Stream, bool leaveOpen = false) has no call sites; every reader construction in the updated tests uses the overload that accepts the sync/async flag. This dead overload adds another construction path without supporting the deduplication pattern, so remove it rather than retaining unused helper code.

Comment thread src/libraries/System.Formats.Tar/tests/TarTestsBase.cs
Copilot AI review requested due to automatic review settings September 24, 2026 10:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Unresolved async-disposal and async-I/O coverage gaps remain, along with duplicate Pax test execution.

Review effort: Lite
Findings: None

Resolved since last review (1)
Previously missed (1)

In code that hasn't changed since last review

Low severity Preserve asynchronous FileStream setup in async readback tests

src/​libraries/​System.Formats.Tar/​tests/​TarFile/​TarFile.CreateFromDirectory.File.Tests.cs:90

The async cases now reopen the generated archive with File.OpenRead, which creates a synchronous FileStream, so the GetNextEntryAsync tests no longer exercise the asynchronous FileStream strategy or async disposal. The deleted async file tests used FileStreamOptions with FileOptions.Asynchronous and await using; preserve that setup for async: true (and apply it to the other readback blocks in this file) so this deduplication does not remove the async I/O coverage.

Copilot AI review requested due to automatic review settings September 24, 2026 10:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Moderate issues remain in asynchronous file-stream coverage and guaranteed TarReader disposal.

Review effort: Lite
Findings: None

Previously missed (2)

In code that hasn't changed since last review

Medium severity Guarantee TarReader disposal when assertions or reads fail

src/​libraries/​System.Formats.Tar/​tests/​TarTestsBase.cs:964

Changing this from a using declaration to manual disposal leaves the reader undisposed whenever an assertion or GetNextEntry call throws before the cleanup block. In the file-backed callers that can leave a handle open and interfere with temporary-directory cleanup on Windows. Use TarReaderHolder with await using (or a try/finally) so disposal is guaranteed on failures.

Low severity Remove unused CreateTarReader overload

src/​libraries/​System.Formats.Tar/​tests/​TarTestsBase.Helpers.cs:85

This overload is unused: every CreateTarReader call in the test tree uses the TarReaderHolder overload below, so retaining this overload adds dead helper API and makes the overload set harder to understand. Remove the unused overload.

alinpahontu2912 and others added 2 commits September 29, 2026 14:38
TarTestsBase.cs references helper members defined in TarTestsBase.Helpers.cs
and other TarTestsBase.*.cs partial files, but the Manual test project
only included TarTestsBase.cs, causing CS0246/CS0103 build errors.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@alinpahontu2912

Copy link
Copy Markdown
Member Author

/ba-g failures are unrelated

@alinpahontu2912
alinpahontu2912 enabled auto-merge (squash) September 30, 2026 08:25
@alinpahontu2912
alinpahontu2912 merged commit 6fe5c26 into dotnet:main Sep 30, 2026
82 of 84 checks passed
rzikm added a commit that referenced this pull request Oct 1, 2026
<!-- -->

TAR extraction currently requires the destination directory to exist,
unlike ZIP extraction. This change allows callers to extract into a
missing destination without creating it first, while preserving lazy
directory creation for empty archives.

Remove the destination-existence checks and rely on TAR's existing
per-entry extraction helpers to create destination and parent
directories as needed. This covers all eight overloads:
synchronous/asynchronous, file/stream inputs, and `bool
overwriteFiles`/`TarExtractOptions`. Existing directories remain
accepted regardless of the overwrite setting, and file-overwrite
behavior is unchanged. Path-containment checks, link handling,
permissions, cancellation, and stream ownership continue through the
existing implementation. ZIP is unchanged.

Update XML documentation and add shared regression coverage for
existing/missing destinations, missing parents, empty archives, nested
files and directory entries, file collisions, files occupying required
directory paths, invalid paths, and traversal through file/link entries.
Cancellation tests cover both overload families. The tests use main's
consolidated sync/async infrastructure following the merge of #130407.

### Validation

- Libraries baseline and TAR builds succeeded on Windows x64 using a
short `subst` path.
- Before the fix, 212 targeted cases failed.
- After merging main at `6fe5c26c9be`, the TAR build succeeded and the
full default Windows TAR suite passed 6,956 tests with zero failures,
including all 344 destination regression cases and four cancellation
cases.
- Unix-specific tests were not run.

### Compatibility

This is a behavioral compatibility change: callers that previously
received `DirectoryNotFoundException` for a missing destination now get
successful extraction, or success without directory creation for an
empty archive. Callers requiring an existing destination must validate
that precondition explicitly.

The PR is labeled `needs-breaking-change-doc-created` for the
repository's post-merge compatibility-documentation process.

> [!NOTE]
> This PR description and the code changes were generated with GitHub
Copilot.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deduplicate Tar sync/async tests

4 participants