/usr/share/perl5/Test/Routine/Runner.pm is in libtest-routine-perl 0.020-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | package Test::Routine::Runner;
# ABSTRACT: tools for running Test::Routine tests
$Test::Routine::Runner::VERSION = '0.020';
use Moose;
#pod =head1 OVERVIEW
#pod
#pod A Test::Routine::Runner takes a callback for building test instances, then uses
#pod it to build instances and run the tests on it. The Test::Routine::Runner
#pod interface is still undergoing work, but the Test::Routine::Util exports for
#pod running tests, descibed in L<Test::Routine|Test::Routine/Running Tests>, are
#pod more stable. Please use those instead, unless you are willing to deal with
#pod interface breakage.
#pod
#pod =cut
use Carp qw(confess croak);
use Scalar::Util qw(reftype);
use Test::More ();
use Try::Tiny;
use Moose::Util::TypeConstraints;
use namespace::clean;
# XXX: THIS CODE BELOW WILL BE REMOVED VERY SOON -- rjbs, 2010-10-18
use Sub::Exporter -setup => {
exports => [
run_tests => \'_curry_tester',
run_me => \'_curry_tester',
],
groups => [ default => [ qw(run_me run_tests) ] ],
};
sub _curry_tester {
my ($class, $name) = @_;
use Test::Routine::Util;
my $sub = Test::Routine::Util->_curry_tester($name);
return sub {
warn "you got $name from Test::Routine::Runner; use Test::Routine::Util instead; Test::Routine::Runner's exports will be removed soon\n";
goto &$sub;
}
}
# XXX: THIS CODE ABOVE WILL BE REMOVED VERY SOON -- rjbs, 2010-10-18
subtype 'Test::Routine::_InstanceBuilder', as 'CodeRef';
subtype 'Test::Routine::_Instance',
as 'Object',
where { $_->does('Test::Routine::Common') };
coerce 'Test::Routine::_InstanceBuilder',
from 'Test::Routine::_Instance',
via { my $instance = $_; sub { $instance } };
has test_instance => (
is => 'ro',
does => 'Test::Routine::Common',
init_arg => undef,
lazy_build => 1,
);
has _instance_builder => (
is => 'ro',
isa => 'Test::Routine::_InstanceBuilder',
coerce => 1,
traits => [ 'Code' ],
init_arg => 'instance_from',
required => 1,
handles => {
'_build_test_instance' => 'execute_method',
},
);
has description => (
is => 'ro',
isa => 'Str',
required => 1,
);
has fresh_instance => (
is => 'ro',
isa => 'Bool',
default => 0,
);
sub run {
my ($self) = @_;
my $thing = $self->test_instance;
my @tests = grep { Moose::Util::does_role($_, 'Test::Routine::Test::Role') }
$thing->meta->get_all_methods;
my $re = $ENV{TEST_METHOD};
if (defined $re and length $re) {
my $filter = try { qr/$re/ } # compile the the regex separately ...
catch { croak("TEST_METHOD ($re) is not a valid regular expression: $_") };
$filter = qr/\A$filter\z/; # ... so it can't mess with the anchoring
@tests = grep { $_->description =~ $filter } @tests;
}
# As a side note, I wonder whether there is any way to format the code below
# to not look stupid. -- rjbs, 2010-09-28
my @ordered_tests = sort {
$a->_origin->{file} cmp $b->_origin->{file}
|| $a->_origin->{nth} <=> $b->_origin->{nth}
} @tests;
Test::More::subtest($self->description, sub {
for my $test (@ordered_tests) {
$self->test_instance->run_test( $test );
$self->clear_test_instance if $self->fresh_instance;
}
});
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Test::Routine::Runner - tools for running Test::Routine tests
=head1 VERSION
version 0.020
=head1 OVERVIEW
A Test::Routine::Runner takes a callback for building test instances, then uses
it to build instances and run the tests on it. The Test::Routine::Runner
interface is still undergoing work, but the Test::Routine::Util exports for
running tests, descibed in L<Test::Routine|Test::Routine/Running Tests>, are
more stable. Please use those instead, unless you are willing to deal with
interface breakage.
=head1 AUTHOR
Ricardo Signes <rjbs@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Ricardo Signes.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|