Created
January 21, 2012 00:55
-
-
Save sshaw/1650517 to your computer and use it in GitHub Desktop.
Test::Class Class Filter
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
use Test::Class::Load 't/lib'; | |
# | |
# I feel that there's a better way to do this. | |
# Also if no tests run then no plan is emitted, shouldn't Test::Class deal with this? | |
# | |
# Regexes are not validated. | |
# | |
if($ENV{TEST_CLASS}) { | |
Test::Class->add_filter(sub { | |
my ($class, $method) = @_; | |
my ($wanted_class, $wanted_method) = split qr'\.', $ENV{TEST_CLASS}, 2; | |
my $match = $class =~ /$wanted_class/; | |
# If TEST_METHOD is set let Test::Class do the filtering | |
if($match && $wanted_method && !$ENV{TEST_METHOD}) { | |
$match = $method =~ /$wanted_method/ | |
} | |
$match; | |
}); | |
} | |
Test::Class->runtests; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment