Skip to content

Tar tests deduplicate - #130407

Open
alinpahontu2912 wants to merge 27 commits into
dotnet:mainfrom
alinpahontu2912:tar_tests_deduplicate
Open

alinpahontu2912 wants to merge 27 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

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.

🔵 Needs a closer look

Asynchronous stream lifecycle coverage remains incomplete, and the format-data provider is duplicated.

Review details

Suppressed comments (5)

src/libraries/System.Formats.Tar/tests/TarReader/TarReader.GetNextEntry.Tests.cs:269

  • With async: true, this merged test still probes the exhausted DataStream only through synchronous Read. The deleted async test used ReadAsync and Assert.ThrowsAsync, so the async data-stream failure paths (both before and after reader disposal) are no longer covered. Branch these assertions on async and use the async read/throws APIs for the async case.
                TarEntry entry2 = await GetNextEntry(reader, async: async);

src/libraries/System.Formats.Tar/tests/TarReader/TarReader.GetNextEntry.Tests.cs:414

  • The async case now reaches this test, but it reads and disposes the returned entry stream with synchronous APIs. The removed async version exercised ReadAsync followed by DisposeAsync; keep those calls conditional on async so this test still covers the asynchronous data-stream lifecycle.
            TarEntry entry = await GetNextEntry(reader, copyData: false, async: async);

src/libraries/System.Formats.Tar/tests/TarReader/TarReader.GetNextEntry.Tests.cs:457

  • This parameterized async case also uses synchronous Read and Dispose on the entry stream. The deleted async test covered ReadAsync/DisposeAsync for the partially-read stream, so the async branch has lost that coverage; dispatch both operations according to async.
            TarEntry entry = await GetNextEntry(reader, copyData: false, async: async);

src/libraries/System.Formats.Tar/tests/TarReader/TarReader.GetNextEntry.Tests.cs:500

  • Although this test is now run with async: true, the returned stream is still disposed synchronously. The removed async variant used DisposeAsync, so the no-read asynchronous disposal path is no longer exercised; select DisposeAsync for the async case.
            TarEntry entry = await GetNextEntry(reader, copyData: false, async: async);

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

  • This provider duplicates the format list already centralized in GetTarEntryFormats()/GetTarEntryFormatsAndBooleanData() below. If a new TarEntryFormat is added, the tests using GetFormatBooleanData will silently omit it; delegate to the existing provider (or replace the call sites with GetTarEntryFormatsAndBooleanData) so there is only one list to maintain.

[!NOTE] This review comment was created by GitHub Copilot.

  • Files reviewed: 59/59 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 11, 2026 09:58

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.

🟡 Changes recommended

Async verification in two TarFile creation test suites still uses synchronous reader paths.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 59/59 changed files
  • Comments generated: 2
  • Review effort level: Lite

@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.

This branch has not been deployed

No deployments
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