/usr/share/perl5/Test/Aggregate/Builder.pm is in libtest-aggregate-perl 0.371-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 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | package Test::Aggregate::Builder;
use strict;
use warnings;
=encoding utf-8
=head1 NAME
Test::Aggregate::Builder - Internal overrides for Test::Builder.
=head1 VERSION
Version 0.371
=cut
our $VERSION = '0.371';
$VERSION = eval $VERSION;
=head1 SYNOPSIS
use Test::Aggregate::Builder;
=head1 DESCRIPTION
B<WARNING>: This module is for internal use only. DO NOT USE DIRECTLY.
=cut
BEGIN { $ENV{TEST_AGGREGATE} = 1 }
END { # for VMS
delete $ENV{TEST_AGGREGATE};
}
use Test::Builder;
{
my $DONE_TESTING;
BEGIN {
no warnings 'redefine';
if ( Test::Builder->can('done_testing') ) {
$DONE_TESTING = \&Test::Builder::done_testing;
*Test::Builder::done_testing = sub {
my ( $self, $num_tests ) = @_;
$self->expected_tests( defined $num_tests
? $num_tests
: $self->current_test
);
return;
};
my $output_plan = \&Test::Builder::_output_plan;
*Test::Builder::_output_plan = sub {
return unless $_[0]->{Done_Testing};
goto $output_plan;
};
}
else {
*Test::Builder::_plan_check = sub {
my $self = shift;
# Will this break under threads?
$self->{Expected_Tests} = $self->{Curr_Test} + 1;
};
}
}
END {
my $tb = Test::Builder->new;
$tb->{'Test::Aggregate::Builder'}{ignore_timing_blocks} = 1;
my $tests = $tb->current_test;
$tb->expected_tests($tests);
if ( $DONE_TESTING ) {
$tb->$DONE_TESTING($tests);
}
else {
$tb->_print("1..$tests\n") unless $tb->{Have_Output_Plan};
}
}
}
no warnings 'redefine';
# The following is done to get around the fact that deferred plans are not
# supported. Unfortunately, there's no clean way to override this, but this
# allows us to minimize the monkey patching.
# XXX We fully-qualify the sub names because PAUSE won't index what it thinks
# is an attempt to hijack the Test::Builder namespace.
sub Test::Builder::no_header { 1 }
{
# prevent the 'you tried to plan twice' errors
my $plan;
BEGIN { $plan = \&Test::Builder::plan }
our $skip = \1;
sub Test::Builder::plan {
delete $_[0]->{Have_Plan};
$_[0]->{'Test::Aggregate::Builder'} ||= {};
my $tab_builder = $_[0]->{'Test::Aggregate::Builder'};
if ( 'skip_all' eq ( $_[1] || '' ) ) {
my $callpack = caller(1);
$tab_builder->{skip_all}{$callpack} = $_[2];
my $running_test = $tab_builder->{running};
die $skip if defined $running_test && $running_test eq $callpack;
return;
}
my $callpack = caller(1);
if ( 'tests' eq ( $_[1] || '' ) ) {
$tab_builder->{plan_for}{$callpack} = $_[2];
if ( $tab_builder->{test_nowarnings_loaded}{$callpack} )
{
# Test::NoWarnings was loaded before plan() was called, so it
# didn't have a change to decrement it
$tab_builder->{plan_for}{$callpack}--;
}
}
$plan->(@_);
}
}
{
my $ok;
BEGIN { $ok = \&Test::Builder::ok }
my %FORBIDDEN = map { $_ => 1 } qw/BEGIN CHECK INIT END/;
sub Test::Builder::ok {
__check_test_count(@_);
my $level = 1;
while (1) {
my ($caller) = ( ( ( caller($level) )[3] || '' ) =~ /::([[:word:]]+)\z/ );
last unless $caller;
if ( $FORBIDDEN{$caller}
&& not $_[0]
->{'Test::Aggregate::Builder'}{ignore_timing_blocks} )
{
my ( $self, $test, $name ) = @_;
$test = $test ? "Yes" : "No";
my ( $filename, $line ) = ( caller($level) )[ 1, 2 ];
$self->diag(<<" END");
>>>> DEPRECATION WARNING <<<<
>>>> See http://use.perl.org/~Ovid/journal/38974 <<<<
Aggregated tests should not be run in BEGIN, CHECK, INIT or END blocks.
File: $filename
Line: $line
Name: $name
Pass: $test
END
}
$level++;
}
local $Test::Builder::Level = $Test::Builder::Level + 1;
$ok->(@_);
}
}
{
my $reset;
BEGIN { $reset = \&Test::Builder::reset }
sub Test::Builder::reset {
my $self = shift;
$reset->($self);
$self->{'Test::Aggregate::Builder'} = {
plan_for => {},
tests_run => {},
file_for => {},
test_nowarnings_loaded => {},
skip_all => {},
check_plan => undef,
last_test => undef,
};
}
}
{
# Called in _ending and prevents the 'you tried to run a test without a
# plan' error.
my $_sanity_check;
BEGIN { $_sanity_check = \&Test::Builder::_sanity_check }
sub Test::Builder::_sanity_check {
$_[0]->{Have_Plan} = 1;
$_sanity_check->(@_);
}
}
{
my $skip;
BEGIN { $skip = \&Test::Builder::skip }
sub Test::Builder::skip {
__check_test_count(@_);
$skip->(@_);
}
}
# two purposes: we check the test cout for a package, but we also return the
# package name
sub __check_test_count {
my $self = shift;
my $callpack;
return unless $self->{'Test::Aggregate::Builder'}{check_plan};
my $stack_level = 1;
while ( my ( $package, undef, undef, $subroutine ) = caller($stack_level) ) {
last if 'Test::Aggregate' eq $package;
# XXX Because these blocks aren't really subroutines, caller()
# doesn't report what you expect.
last
if $callpack && $subroutine =~ /::(?:BEGIN|END)\z/;
$callpack = $package;
$stack_level++;
}
{
no warnings 'uninitialized';
$self->{'Test::Aggregate::Builder'}{tests_run}{$callpack} += 1;
}
return $callpack;
}
=head1 AUTHOR
Curtis Poe, C<< <ovid at cpan.org> >>
=head1 BUGS
Please report any bugs or feature requests to
C<bug-test-aggregate at rt.cpan.org>, or through the web interface at
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Aggregate>.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Test::Aggregate::Builder
You can also find information oneline:
L<http://metacpan.org/release/Test-Aggregate>
=head1 COPYRIGHT & LICENSE
Copyright 2007 Curtis "Ovid" Poe, all rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=cut
1;
|