Skip to content

♻️ Extract create_test_archive and get_archive_entry_names into shared test utils#2925

Merged
ChanTsune merged 3 commits into
mainfrom
refactor/shared-test-helpers
Apr 5, 2026
Merged

♻️ Extract create_test_archive and get_archive_entry_names into shared test utils#2925
ChanTsune merged 3 commits into
mainfrom
refactor/shared-test-helpers

Conversation

@ChanTsune

@ChanTsune ChanTsune commented Apr 4, 2026

Copy link
Copy Markdown
Owner

Move duplicated test helpers from stdio/archive_inclusion.rs into utils/archive.rs so they can be reused across test modules.

Summary by CodeRabbit

  • Refactor

    • Consolidated archive-related test utilities to reduce duplication and improve maintainability.
  • Tests

    • Introduced shared archive helpers and updated tests to use them for creating and inspecting test archives.

…d test utils

Move duplicated test helpers from stdio/archive_inclusion.rs into
utils/archive.rs so they can be reused across test modules.
@coderabbitai

coderabbitai Bot commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e3e49d53-40a9-4508-9d72-678996746553

📥 Commits

Reviewing files that changed from the base of the PR and between 88b089f and ab007a6.

📒 Files selected for processing (2)
  • cli/tests/cli/stdio/mtree.rs
  • cli/tests/cli/utils/archive.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • cli/tests/cli/utils/archive.rs

📝 Walkthrough

Walkthrough

Consolidated test archive helpers: removed local implementations of create_test_archive and get_archive_entry_names from test files and added/imported shared implementations in cli/tests/cli/utils/archive.rs. No production API or behavior changes.

Changes

Cohort / File(s) Summary
Test: stdio/archive_inclusion
cli/tests/cli/stdio/archive_inclusion.rs
Deleted local helper implementations for creating and inspecting .pna test archives; now import create_test_archive and get_archive_entry_names from shared utils. Removed direct pna and local IO/path helper usage.
Test: mtree
cli/tests/cli/stdio/mtree.rs
Replaced local get_archive_entry_names with import from crate::utils::archive; adjusted imports and removed the file-local collection helper.
Shared test utilities
cli/tests/cli/utils/archive.rs
Added pub fn create_test_archive(path, entries) to create .pna archives and pub fn get_archive_entry_names(path) -> Vec<String> to collect entry names; uses pna APIs and filesystem ops with unwrap() error handling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • @ support #2523 — earlier introduction of local create_test_archive / get_archive_entry_names implementations in tests (same helpers consolidated here).
  • Worktree expand test #2780 — adds additional archive-related test utilities in cli/tests/cli/utils/archive.rs (related helper additions and shared utilities).

Suggested labels

cli

Poem

🐰 In burrows of tests I tidy and hop,

Helpers once splintered now gather and stop.
Archives are built with a hop and a hum,
Shared tools in one warren — faster they come.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: extracting and consolidating duplicated test helper functions (create_test_archive and get_archive_entry_names) from stdio/archive_inclusion.rs into a shared utils/archive.rs module for reuse across test files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/shared-test-helpers

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request refactors test utilities by moving the create_test_archive and get_archive_entry_names functions from a specific test file into a shared utility module to promote code reuse. A review comment identifies a potential failure in create_test_archive when handling paths without parent directory components and suggests a more robust implementation for directory creation.

Comment thread cli/tests/cli/utils/archive.rs
@github-actions github-actions Bot added the cli This issue is about cli application label Apr 4, 2026
@ChanTsune
ChanTsune merged commit 574e2d6 into main Apr 5, 2026
103 checks passed
@ChanTsune
ChanTsune deleted the refactor/shared-test-helpers branch April 5, 2026 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli This issue is about cli application

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant