Skip to content

Remove Test::More dependency in favor of Test2::API - #3

Merged
mohawk2 merged 1 commit into
mohawk2:masterfrom
yuu-no:master
Aug 30, 2026
Merged

Remove Test::More dependency in favor of Test2::API#3
mohawk2 merged 1 commit into
mohawk2:masterfrom
yuu-no:master

Conversation

@yuu-no

@yuu-no yuu-no commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR removes the runtime dependency on Test::More, making Test::Snapshot compatible with Test2::V0 directly.

Changes

  • Replace require Test::More with pure Test2::API usage
  • Use $ctx->pass/fail/diag instead of Test::More::pass/fail/diag
  • Remove $Test::Builder::Level manipulation (no longer needed with context)
  • Capture subtest names via test2_add_callback_pre_subtest and Hub metadata
  • Refactor _get_filename() to use $0 and Hub metadata instead of Test::Builder metadata

Motivation

Users who prefer Test2::V0 over Test::More can now use Test::Snapshot without pulling in Test::More as a runtime dependency. This also simplifies the codebase by using the modern Test2::API directly.

Test plan

  • Existing tests pass (prove -lr t/)
  • Added t/snapshot-test2.t for Test2::V0 compatibility testing
  • Renamed t/snapshot.tt/snapshot-testmore.t to clarify test coverage

@yuu-no

yuu-no commented Mar 30, 2026

Copy link
Copy Markdown
Contributor Author

Hi @mohawk2,

I’m just following up on this PR. I believe this change would be beneficial for the project. Could you please take a look when you have a moment?

Thanks!

@mohawk2

mohawk2 commented Aug 30, 2026

Copy link
Copy Markdown
Owner

Thank you for the contribution! I've just added GHA CI on this, and rebased your branch over it. You can see above that it's failed the release tests (prove -l xt would have shown this) because you didn't update the MANIFEST. I'll fix that now.

@mohawk2

mohawk2 commented Aug 30, 2026

Copy link
Copy Markdown
Owner

I've also removed the blank lines you added (my personal taste) and the return statement at the end of a function, which I gather actually slightly slows the interpreter down.

@mohawk2
mohawk2 merged commit 1167c98 into mohawk2:master Aug 30, 2026
4 checks passed
@mohawk2

mohawk2 commented Aug 30, 2026

Copy link
Copy Markdown
Owner

Thank you again! I'll add a note in Changes crediting you, and update the docs.

By the way, you PR-ed this from your master branch, it's considered best practice to do that from a feature branch in your repo instead.

mohawk2 added a commit that referenced this pull request Aug 30, 2026
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