Skip to content

DRY refactor plus pinned-output regression tests and CI#1

Merged
moetiker merged 0 commit into
mainfrom
refactor-dry
Jul 15, 2026
Merged

DRY refactor plus pinned-output regression tests and CI#1
moetiker merged 0 commit into
mainfrom
refactor-dry

Conversation

@oetiker

@oetiker oetiker commented Jul 3, 2026

Copy link
Copy Markdown
Member

Summary

  • Refactor the repeated patterns in zzclone into helper subs: transfer_cmd() (the send | mbuffer | receive pipeline existed 4×), snap_name() (5 scattered snapshot-name regexes in 3 spellings), read_lines() (4 hand-rolled pipe-open loops), list_snapshots() and get_guid(). The full-send branch now reuses the already-computed $dest_fileset instead of re-deriving the destination by string surgery (this also anchors the src-root substitution, fixing a latent quirk).
  • Add t/regression.t: runs zzclone against a canned fake zfs/ssh/sudo world (t/shims) across 14 option combinations and compares stdout, stderr and exit code with pinned expected output (t/expected). The fake dataset tree covers incremental, full-send, up-to-date, no-snapshot, resume-token and guid-mismatch paths, in local, remote-source and remote-destination flavours. UPDATE_EXPECTED=1 prove t/ regenerates the expected files after an intentional output change.
  • Add a GitHub Actions workflow running perl -c and prove t/ on pushes to main and on PRs.
  • README: document the previously missing -R/--rollback, -c/--chain and -v/--verbose options and add a Testing section.

Verification

The generated output is byte-identical before and after the refactor: the pre-refactor script passes the exact same pinned test suite (all 28 tests) as the refactored one. No dependencies beyond core Perl; prove ships with it.

🤖 Generated with Claude Code

@moetiker
moetiker merged commit 39943cf into main Jul 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants