Last active
August 29, 2015 14:11
-
-
Save exodist/5b0b9b21cfeda4323937 to your computer and use it in GitHub Desktop.
Test::SkipWithout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Test::SkipWithout; | |
use strict; | |
use warnings; | |
require Test::More; | |
sub import { | |
my $class = shift; | |
my ($module, $version) = @_; | |
my ($pkg, $file, $line) = caller; | |
return skip($module, $version, "$module did not load: $@") | |
unless eval qq{#line $line "$file"\nrequire $module; 1}; | |
return unless $version; | |
return skip($module, $version, $@) | |
unless eval qq{#line $line "$file"\n\$module->VERSION(\$version)}; | |
} | |
sub skip { | |
my ($module, $version, $reason) = @_; | |
Test::More::plan('skip_all' => $reason) | |
unless $ENV{RELEASE_TESTING} || $ENV{AUTHOR_TESTING}; | |
my $name = $module; | |
$name .= " $version" if $version; | |
Test::More::fail($name); | |
Test::More::diag($reason); | |
exit; | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment