Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: optionally tell "ok" module to BAIL_OUT if module cannot be loaded #929

Open
XSven opened this issue Apr 29, 2024 · 1 comment

Comments

@XSven
Copy link

XSven commented Apr 29, 2024

I am looking for a way to replace this idiom

BEGIN {
  use_ok( 'Some::Module' ) or BAIL_OUT( "Cannot load module 'Some::Module'!" );
}

with something that uses the ok module?!

@exodist
Copy link
Member

exodist commented May 3, 2024

I think this feature request should be a new module. I do not want to complicate ok.pm with this functionality.

I would suggest subclassing https://metacpan.org/pod/Test2::Require::Module in Test2::Require::ModuleOrBail that implements the additional behavior.

If you write it as a PR against Test2-Suite I will likely merge it. But it is also perfectly reasonable as a stand alone cpan dist.

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

No branches or pull requests

2 participants