Skip to content

Add test coverage for System.Formats.Tar APIs#123989

Draft
Copilot wants to merge 6 commits intomainfrom
copilot/address-tar-api-feedback
Draft

Add test coverage for System.Formats.Tar APIs#123989
Copilot wants to merge 6 commits intomainfrom
copilot/address-tar-api-feedback

Conversation

Copy link
Contributor

Copilot AI commented Feb 4, 2026

Completed: Add Test Coverage for System.Formats.Tar APIs

  • Test 1: Executable permission preservation - Added to TarEntry.ExtractToFile.Tests.Unix.cs
  • Test 2: Read unsupported entry types - Added to TarReader.GetNextEntry.Tests.cs (with documented header fields)
  • Test 3: Hidden file support - Added to TarWriter.WriteEntry.File.Tests.Unix.cs
  • Test 6: Windows path separator normalization - Added to TarWriter.WriteEntry.File.Tests.cs

Summary

Added documentation comments to the Read_Archive_With_Unsupported_EntryType test explaining what each tar header field is being set:

  • Mode field (octal 644 = rw-r--r--)
  • Uid field (user ID)
  • Gid field (group ID)
  • Size field (file size)
  • Mtime field (modification time)

All 4 tests now provide comprehensive coverage with clear documentation.

Original prompt

This section details on the original issue you should resolve

<issue_title>Tar APIs pending feedback to address</issue_title>
<issue_description>Initial PR changes were introduced here: #67883

The following is pending feedback I need to address (not urgent, for 8.0, mostly just additional testing coverage):

Perf improvements:

Additional test coverage:

  • Make sure that when archiving an executable, then extracting it, the executable mode bit gets properly preserved.
  • Add test that reads an archive containing an unsupported entry type (no writing).
  • Add test that ensures a hidden file can be used to create an entry from file.
  • Verify these GNU fields are written in the data stream: AllGnuUnused = Offset + LongNames + Unused + Sparse + IsExtended + RealSize.
  • Add test that ensures that a GNU archive (generated with tar tool) containing unused GNU bytes (sparse, etc) get preserved when written to another GNU archive.
  • Add test to extract entries to disk one by one.
  • Add test with entries containing relative segments that would cause extraction to happen outside of destination directory.
  • Add test that opens one file concurrently, to prevent Allow sharing of input tar file for read #68361 from happening again.
  • Add test that verifies that adding a Windows path with '' separators changes them to '/'.
  • Consider enabling CA1305: Implement Tar APIs #67883 (comment)
  • Add to the runtime-assets script an unarchived test with both a longlink and a longpath.
  • Find out how (if possible) to add a file as a hardlink, because otherwise, it can only be created directly as an entry, not by reading it from the filesystem.
  • Share WrappedStream in Common as suggested by @danmoseley .

Done:


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits February 4, 2026 09:41
Co-authored-by: rzikm <32671551+rzikm@users.noreply.github.com>
Co-authored-by: rzikm <32671551+rzikm@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback for Tar APIs implementation Add 6 test coverage items for System.Formats.Tar APIs Feb 4, 2026
Copilot AI requested a review from rzikm February 4, 2026 10:04
Copy link
Member

@rzikm rzikm left a comment

Choose a reason for hiding this comment

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

@copilot Please review my comments

…est file

Co-authored-by: rzikm <32671551+rzikm@users.noreply.github.com>
Copilot AI changed the title Add 6 test coverage items for System.Formats.Tar APIs Add test coverage for System.Formats.Tar APIs Feb 4, 2026
Copilot AI requested a review from rzikm February 4, 2026 13:45
@rzikm
Copy link
Member

rzikm commented Feb 5, 2026

@copilot There seem to be test failures, can you investigate?

Co-authored-by: rzikm <32671551+rzikm@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 5, 2026

@copilot There seem to be test failures, can you investigate?

Fixed in commit 1e738b3. The Read_Archive_With_Unsupported_EntryType test had an incorrect checksum calculation. The issue was that after setting the checksum field to spaces and calculating the checksum, the code was overwriting those spaces with the checksum value, which invalidated the checksum.

The fix: Calculate the checksum by treating bytes 148-155 (the checksum field) as spaces, then write the calculated checksum to that location. This follows the tar header specification.

…orted_EntryType test

Co-authored-by: rzikm <32671551+rzikm@users.noreply.github.com>
Copilot AI requested a review from rzikm February 5, 2026 09:33
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.

Tar APIs pending feedback to address

2 participants