Skip to content

Instantly share code, notes, and snippets.

@sshaw
Created January 21, 2012 00:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sshaw/1650517 to your computer and use it in GitHub Desktop.
Save sshaw/1650517 to your computer and use it in GitHub Desktop.
Test::Class Class Filter
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