# $^C was only introduced in 5.005-ish. We do this to prevent
# use of uninitialized value warnings in older perls.
$VERSION = eval $VERSION; # make the alpha version come out as a number
# Make Test::Builder thread-safe for ithreads.
# Load threads::shared when threads are turned on
if( $] >= 5.008 && $Config{useithreads} && $INC{'threads.pm'}) {
# Hack around YET ANOTHER threads::shared bug. It would
# occassionally forget the contents of the variable when sharing it.
# So we first copy the data, then share, then put our copy back.
elsif( $type eq 'ARRAY' ) {
elsif( $type eq 'SCALAR' ) {
die "Unknown type: ".$type;
$_[0] = &threads::shared::share($_[0]);
elsif( $type eq 'ARRAY' ) {
elsif( $type eq 'SCALAR' ) {
die "Unknown type: ".$type;
# 5.8.0's threads::shared is busted when threads are off.
*share = sub { return $_[0] };
Test::Builder - Backend for building test libraries
package My::Test::Module;
my $Test = Test
::Builder
->new;
$Test->output('my_logfile');
$Test->exported_to($pack);
$self->export_to_level(1, $self, 'ok');
Test::Simple and Test::More have proven to be popular testing modules,
but they're not always flexible enough. Test::Builder provides the a
building block upon which to write your own test libraries I<which can
my $Test = Test::Builder->new;
Returns a Test::Builder object representing the current state of the
Since you only run one test per program C<new> always returns the same
Test::Builder object. No matter how many times you call new(), you're
getting the same object. This is called a singleton. This is done so that
multiple modules share such global information as the test counter and
where test output is going.
If you want a completely new Test::Builder object different from the
singleton, use C<create>.
my $Test = Test
::Builder
->new;
$Test ||= $class->create;
my $Test = Test::Builder->create;
Ok, so there can be more than one Test::Builder object and this is how
you get it. You might use this instead of C<new()> if you're testing
a Test::Builder based module, but otherwise you probably want C<new>.
B<NOTE>: the implementation is not complete. C<level>, for example, is
still shared amongst B<all> Test::Builder objects, even ones created using
this method. Also, the method name may change in the future.
my $self = bless {}, $class;
Reinitializes the Test::Builder singleton to its original state.
Mostly useful for tests run in persistent environments where the same
test might be run multiple times in the same process.
# We leave this a global because it has to be localized and localizing
# hash keys is just asking for pain. Also, it was documented.
$self->{Original_Pid} = $$;
share($self->{Curr_Test});
$self->{Test_Results} = &share([]);
$self->{Exported_To} = undef;
$self->{Expected_Tests} = 0;
$self->_dup_stdhandles unless $^C;
These methods are for setting up tests and declaring how many there
are. You usually only want to call one of these methods.
my $pack = $Test->exported_to;
$Test->exported_to($pack);
Tells Test::Builder what package you exported your functions to.
This is important for getting TODO tests right.
$self->{Exported_To} = $pack;
return $self->{Exported_To};
$Test->plan( skip_all => $reason );
$Test->plan( tests => $num_tests );
A convenient way to set up your tests. Call this and Test::Builder
will print the appropriate headers and take the appropriate actions.
If you call plan(), don't call any of the other methods below.
my($self, $cmd, $arg) = @_;
if( $self->{Have_Plan} ) {
die sprintf "You tried to plan twice! Second plan at %s line %d\n",
if( $cmd eq 'no_plan' ) {
elsif( $cmd eq 'skip_all' ) {
return $self->skip_all($arg);
elsif( $cmd eq 'tests' ) {
return $self->expected_tests($arg);
die "Got an undefined number of tests. Looks like you tried to ".
"say how many tests you plan to run but made a mistake.\n";
die "You said to run 0 tests! You've got to run something.\n";
my @args = grep { defined } ($cmd, $arg);
Carp::croak("plan() doesn't understand @args");
my $max = $Test->expected_tests;
$Test->expected_tests($max);
Gets/sets the # of tests we expect this test to run and prints out
die "Number of tests must be a postive integer. You gave it '$max'.\n"
unless $max =~ /^\+?\d+$/ and $max > 0;
$self->{Expected_Tests} = $max;
$self->_print("1..$max\n") unless $self->no_header;
return $self->{Expected_Tests};
Declares that this test will run an indeterminate # of tests.
Find out whether a plan has been defined. $plan is either C<undef> (no plan has been set), C<no_plan> (indeterminate # of tests) or an integer (the number of expected tests).
return($self->{Expected_Tests}) if $self->{Expected_Tests};
return('no_plan') if $self->{No_Plan};
$Test->skip_all($reason);
Skips all the tests, using the given $reason. Exits immediately with 0.
$out .= " # Skip $reason" if $reason;
$self->_print($out) unless $self->no_header;
These actually run the tests, analogous to the functions in
$name is always optional.
Your basic test. Pass if $test is true, fail if $test is false. Just
like Test::Simple's ok().
my($self, $test, $name) = @_;
# $test might contain an object which we don't want to accidentally
# store, so we turn it into a boolean.
unless( $self->{Have_Plan} ) {
Carp::croak("You tried to run a test without a plan! Gotta have a plan.");
# In case $name is a string overloaded object, force it to stringify.
$self->_unoverload_str(\$name);
$self->diag(<<ERR) if defined $name and $name =~ /^[\d\s]+$/;
You named your test '$name'. You shouldn't use numbers for your test names.
my($pack, $file, $line) = $self->caller;
my $todo = $self->todo($pack);
$self->_unoverload_str(\
$todo);
@
$result{ 'ok', 'actual_ok' } = ( ( $todo ?
1 : 0 ), 0 );
@
$result{ 'ok', 'actual_ok' } = ( 1, $test );
$out .= " $self->{Curr_Test}" if $self->use_numbers;
$name =~ s
|#|\\#|g; # # in a name can confuse Test::Harness.
$result->{reason
} = $todo;
$result->{type
} = 'todo';
$self->{Test_Results
}[$self->{Curr_Test
}-1] = $result;
my $msg = $todo ?
"Failed (TODO)" : "Failed";
$self->_print_diag("\n") if $ENV{HARNESS_ACTIVE
};
$self->diag(qq[ $msg test
'$name'\n]);
$self->diag(qq[ in $file at line
$line.\n]);
$self->diag(qq[ $msg test
in $file at line
$line.\n]);
eval { require overload
} || return;
if( _is_object
($$thing) ) {
if( my $string_meth = overload
::Method
($$thing, $type) ) {
$$thing = $$thing->$string_meth();
return eval { ref $thing && $thing->isa('UNIVERSAL') } ?
1 : 0;
$self->_unoverload(q
[""], @_);
$self->_unoverload('0+', @_);
next unless $self->_is_dualvar($$val);
# This is a hack to detect a dualvar such as $!
return 1 if $numval != 0 and $numval ne $val;
$Test->is_eq($got, $expected, $name);
Like Test::More's is(). Checks if $got eq $expected. This is the
$Test->is_num($got, $expected, $name);
Like Test::More's is(). Checks if $got == $expected. This is the
my($self, $got, $expect, $name) = @_;
local $Level = $Level + 1;
$self->_unoverload_str(\
$got, \
$expect);
if( !defined $got || !defined $expect ) {
# undef only matches undef and nothing else
my $test = !defined $got && !defined $expect;
$self->_is_diag($got, 'eq', $expect) unless $test;
return $self->cmp_ok($got, 'eq', $expect, $name);
my($self, $got, $expect, $name) = @_;
local $Level = $Level + 1;
$self->_unoverload_num(\
$got, \
$expect);
if( !defined $got || !defined $expect ) {
# undef only matches undef and nothing else
my $test = !defined $got && !defined $expect;
$self->_is_diag($got, '==', $expect) unless $test;
return $self->cmp_ok($got, '==', $expect, $name);
my($self, $got, $type, $expect) = @_;
foreach my $val (\
$got, \
$expect) {
# quote and force string context
$self->_unoverload_num($val);
return $self->diag(sprintf <<DIAGNOSTIC, $got, $expect);
$Test->isnt_eq($got, $dont_expect, $name);
Like Test::More's isnt(). Checks if $got ne $dont_expect. This is
$Test->is_num($got, $dont_expect, $name);
Like Test::More's isnt(). Checks if $got ne $dont_expect. This is
my($self, $got, $dont_expect, $name) = @_;
local $Level = $Level + 1;
if( !defined $got || !defined $dont_expect ) {
# undef only matches undef and nothing else
my $test = defined $got || defined $dont_expect;
$self->_cmp_diag($got, 'ne', $dont_expect) unless $test;
return $self->cmp_ok($got, 'ne', $dont_expect, $name);
my($self, $got, $dont_expect, $name) = @_;
local $Level = $Level + 1;
if( !defined $got || !defined $dont_expect ) {
# undef only matches undef and nothing else
my $test = defined $got || defined $dont_expect;
$self->_cmp_diag($got, '!=', $dont_expect) unless $test;
return $self->cmp_ok($got, '!=', $dont_expect, $name);
$Test->like($this, qr/$regex/, $name);
$Test->like($this, '/$regex/', $name);
Like Test::More's like(). Checks if $this matches the given $regex.
You'll want to avoid qr// if you want your tests to work before 5.005.
$Test->unlike($this, qr/$regex/, $name);
$Test->unlike($this, '/$regex/', $name);
Like Test::More's unlike(). Checks if $this B<does not match> the
my($self, $this, $regex, $name) = @_;
local $Level = $Level + 1;
$self->_regex_ok($this, $regex, '=~', $name);
my($self, $this, $regex, $name) = @_;
local $Level = $Level + 1;
$self->_regex_ok($this, $regex, '!~', $name);
$Test->maybe_regex(qr/$regex/);
$Test->maybe_regex('/$regex/');
Convenience method for building testing functions that take regular
expressions as arguments, but need to work before perl 5.005.
Takes a quoted regular expression produced by qr//, or a string
representing a regular expression.
Returns a Perl value which may be used instead of the corresponding
regular expression, or undef if it's argument is not recognised.
For example, a version of like(), sans the useful diagnostic messages,
my ($self, $this, $regex, $name) = @_;
my $usable_regex = $self->maybe_regex($regex);
die "expecting regex, found '$regex'\n"
$self->ok($this =~ m/$usable_regex/, $name);
my $usable_regex = undef;
return $usable_regex unless defined $regex;
if( ref $regex eq 'Regexp' ) {
# Check for '/foo/' or 'm,foo,'
elsif( ($re, $opts) = $regex =~ m{^ /(.*)/ (\w*) $ }sx or
(undef, $re, $opts) = $regex =~ m
,^ m
([^\w\s
]) (.+) \
1 (\w
*) $,sx
$usable_regex = length $opts ?
"(?$opts)$re" : $re;
my($self, $this, $regex, $cmp, $name) = @_;
my $usable_regex = $self->maybe_regex($regex);
unless (defined $usable_regex) {
$ok = $self->ok( 0, $name );
$self->diag(" '$regex' doesn't look much like a regex to me.");
my $code = $self->_caller_context;
# Yes, it has to look like this or 5.4.5 won't see the #line directive.
# Don't ask me, man, I just work here.
$code" . q{$test = $this =~ /$usable_regex/ ? 1 : 0};
$test = !$test if $cmp eq '!~';
local $Level = $Level + 1;
$ok = $self->ok( $test, $name );
$this = defined $this ? "'$this'" : 'undef';
my $match = $cmp eq '=~' ? "doesn't match" : "matches";
$self->diag(sprintf <<DIAGNOSTIC, $this, $match, $regex);
$Test->cmp_ok($this, $type, $that, $name);
Works just like Test::More's cmp_ok().
$Test->cmp_ok($big_num, '!=', $other_big_num);
my %numeric_cmps = map { ($_, 1) }
("<", "<=", ">", ">=", "==", "!=", "<=>");
my($self, $got, $type, $expect, $name) = @_;
# Treat overloaded objects as numbers if we're asked to do a
my $unoverload = $numeric_cmps{$type} ?
'_unoverload_num'
$self->$unoverload(\
$got, \
$expect);
local($@
,$!); # don't interfere with $@
# eval() sometimes resets $!
my $code = $self->_caller_context;
# Yes, it has to look like this or 5.4.5 won't see the #line directive.
# Don't ask me, man, I just work here.
$code" . "\$got $type \$expect;";
local $Level = $Level + 1;
my $ok = $self->ok($test, $name);
if( $type =~ /^(eq|==)$/ ) {
$self->_is_diag($got, $type, $expect);
$self->_cmp_diag($got, $type, $expect);
my($self, $got, $type, $expect) = @_;
$got = defined $got ?
"'$got'" : 'undef';
$expect = defined $expect ?
"'$expect'" : 'undef';
return $self->diag(sprintf <<DIAGNOSTIC, $got, $type, $expect);
my($pack, $file, $line) = $self->caller(1);
$code .= "#line $line $file\n" if defined $file and defined $line;
$Test->BAIL_OUT($reason);
Indicates to the Test::Harness that things are going so badly all
testing should terminate. This includes running any additional test
$self->_print("Bail out! $reason");
BAIL_OUT() used to be BAILOUT()
Skips the current test, reporting $why.
$self->_unoverload_str(\
$why);
unless( $self->{Have_Plan
} ) {
Carp
::croak
("You tried to run tests without a plan! Gotta have a plan.");
lock($self->{Curr_Test
});
$self->{Test_Results
}[$self->{Curr_Test
}-1] = &share
({
$out .= " $self->{Curr_Test}" if $self->use_numbers;
$out .= " $why" if length $why;
Like skip(), only it will declare the test as failing and TODO. Similar
print "not ok $tnum # TODO $why\n";
unless( $self->{Have_Plan
} ) {
Carp
::croak
("You tried to run tests without a plan! Gotta have a plan.");
lock($self->{Curr_Test
});
$self->{Test_Results
}[$self->{Curr_Test
}-1] = &share
({
$out .= " $self->{Curr_Test}" if $self->use_numbers;
$out .= " # TODO & SKIP $why\n";
$Test->skip_rest($reason);
Like skip(), only it skips all the rest of the tests you plan to run
If you're running under no_plan, it skips once and terminates the
How far up the call stack should $Test look when reporting where the
Setting $Test::Builder::Level overrides. This is typically useful
local $Test::Builder::Level = 2;
$Test->use_numbers($on_or_off);
Whether or not the test should output numbers. That is, this if true:
Most useful when you can't depend on the test output order, such as
when threads or forking is involved.
Test::Harness will accept either, but avoid mixing the two styles.
my($self, $use_nums) = @_;
if( defined $use_nums ) {
$self->{Use_Nums
} = $use_nums;
return $self->{Use_Nums
};
$Test->no_diag($no_diag);
If set true no diagnostics will be printed. This includes calls to
$Test->no_ending($no_ending);
Normally, Test::Builder does some extra diagnostics when the test
ends. It also changes the exit code as described below.
If this is true, none of that will be done.
$Test->no_header($no_header);
If set to true, no "1..N" header will be printed.
foreach my $attribute (qw(No_Header No_Ending No_Diag)) {
my $method = lc $attribute;
$self->{$attribute} = $no;
return $self->{$attribute};
*{__PACKAGE__
.'::'.$method} = $code;
Controlling where the test output goes.
It's ok for your test to change where STDOUT and STDERR point to,
Test::Builder's default output settings will not be affected.
Prints out the given @msgs. Like C<print>, arguments are simply
Normally, it uses the failure_output() handle, but if this is for a
TODO test, the todo_output() handle is used.
Output will be indented and marked with a # so as not to interfere
with test output. A newline will be put on the end if there isn't one
We encourage using this rather than calling print directly.
Returns false. Why? Because diag() is often used in conjunction with
a failing test (C<ok() || diag()>) it "passes through" the failure.
return ok(...) || diag(...);
Mark Fowler <mark@twoshortplanks.com>
return if $self->no_diag;
# Prevent printing headers when compiling (i.e. -c)
# Smash args together like print does.
# Convert undef to 'undef' so its readable.
my $msg = join '', map { defined($_) ?
$_ : 'undef' } @msgs;
# Escape each line with a #.
# Stick a newline on the end if it needs it.
$msg .= "\n" unless $msg =~ /\n\Z/;
local $Level = $Level + 1;
$self->_print_diag($msg);
Prints to the output() filehandle.
# Prevent printing headers when only compiling. Mostly for when
# tests are deparsed with B::Deparse
my $msg = join '', @msgs;
local($\
, $", $,) = (undef, ' ', '');
# Escape each line after the first with a # so we don't
$msg =~ s/\n(.)/\n# $1/sg;
# Stick a newline on the end if it needs it.
$msg .= "\n" unless $msg =~ /\n\Z/;
$Test->_print_diag(@msg);
Like _print, but prints to the current diagnostic filehandle.
local($\, $", $,) = (undef, ' ', '');
my $fh = $self->todo ?
$self->todo_output : $self->failure_output;
Where normal "ok/not ok" test output should go.
$Test->failure_output($fh);
$Test->failure_output($file);
Where diagnostic output on test failures and diag() should go.
$Test->todo_output($file);
Where diagnostics about todo test failures and diag() should go.
$self->{Out_FH
} = _new_fh
($fh);
$self->{Fail_FH
} = _new_fh
($fh);
$self->{Todo_FH
} = _new_fh
($fh);
if( _is_fh
($file_or_fh) ) {
open $fh, ">$file_or_fh" or
die "Can't open test output log $file_or_fh: $!";
return 0 unless defined $maybe_fh;
return 1 if ref \
$maybe_fh eq 'GLOB'; # its a glob
return UNIVERSAL
::isa
($maybe_fh, 'GLOB') ||
UNIVERSAL
::isa
($maybe_fh, 'IO::Handle') ||
# 5.5.4's tied() and can() doesn't like getting undef
UNIVERSAL
::can
((tied($maybe_fh) || ''), 'TIEHANDLE');
$self->_open_testhandles;
# Set everything to unbuffered else plain prints to STDOUT will
# come out in the wrong order from our own prints.
$self->output(\
*TESTOUT
);
$self->failure_output(\
*TESTERR
);
$self->todo_output(\
*TESTOUT
);
my $Opened_Testhandles = 0;
return if $Opened_Testhandles;
# We dup STDOUT and STDERR so people can change them in their
# test suites while still getting normal test output.
open(TESTOUT
, ">&STDOUT") or die "Can't dup STDOUT: $!";
open(TESTERR
, ">&STDERR") or die "Can't dup STDERR: $!";
=head2 Test Status and Info
my $curr_test = $Test->current_test;
$Test->current_test($num);
Gets/sets the current test number we're on. You usually shouldn't
If set forward, the details of the missing tests are filled in as 'unknown'.
if set backward, the details of the intervening tests are deleted. You
can erase history if you really want to.
lock($self->{Curr_Test
});
unless( $self->{Have_Plan
} ) {
Carp
::croak
("Can't change the current test number without a plan!");
$self->{Curr_Test
} = $num;
# If the test counter is being pushed forward fill in the details.
my $test_results = $self->{Test_Results
};
if( $num > @
$test_results ) {
my $start = @
$test_results ? @
$test_results : 0;
$test_results->[$_] = &share
({
reason
=> 'incrementing test number',
# If backward, wipe history. Its their funeral.
elsif( $num < @
$test_results ) {
$#{$test_results} = $num - 1;
return $self->{Curr_Test
};
my @tests = $Test->summary;
A simple summary of the tests so far. True for pass, false for fail.
This is a logical pass/fail, so todos are passes.
Of course, test #1 is $tests[0], etc...
return map { $_->{'ok'} } @
{ $self->{Test_Results
} };
my @tests = $Test->details;
Like summary(), but with a lot more detail.
{ 'ok' => is the test considered a pass?
actual_ok => did it literally say 'ok'?
name => name of the test (if any)
type => type of test (if any, see below).
reason => reason for the above (if any)
'ok' is true if Test::Harness will consider the test to be a pass.
'actual_ok' is a reflection of whether or not the test literally
printed 'ok' or 'not ok'. This is for examining the result of 'todo'
'name' is the name of the test.
'type' indicates if it was a special test. Normal tests have a type
of ''. Type can be one of the following:
todo_skip see todo_skip()
Sometimes the Test::Builder test counter is incremented without it
printing any test output, for example, when current_test() is changed.
In these cases, Test::Builder doesn't know the result of the test, so
it's type is 'unkown'. These details for these tests are filled in.
They are considered ok, but the name and actual_ok is left undef.
For example "not ok 23 - hole count # TODO insufficient donuts" would
result in this structure:
$tests[22] = # 23 - 1, since arrays start from 0.
{ ok => 1, # logically, the test passed since it's todo
actual_ok => 0, # in absolute terms, it failed
reason => 'insufficient donuts'
return @
{ $self->{Test_Results
} };
my $todo_reason = $Test->todo;
my $todo_reason = $Test->todo($pack);
todo() looks for a $TODO variable in your tests. If set, all tests
will be considered 'todo' (see Test::More and Test::Harness for
details). Returns the reason (ie. the value of $TODO) if running as
todo tests, false otherwise.
todo() is about finding the right package to look for $TODO in. It
uses the exported_to() package to find it. If that's not set, it's
pretty good at guessing the right package to look at based on $Level.
Sometimes there is some confusion about where todo() should be looking
for the $TODO variable. If you want to be sure, tell it explicitly
$pack = $pack || $self->exported_to || $self->caller($Level);
return defined ${$pack.'::TODO'} ?
${$pack.'::TODO'}
my $package = $Test->caller;
my($pack, $file, $line) = $Test->caller;
my($pack, $file, $line) = $Test->caller($height);
Like the normal caller(), except it reports according to your level().
my @caller = CORE
::caller($self->level + $height + 1);
return wantarray ?
@caller : $caller[0];
Runs a bunch of end of test sanity checks to make sure reality came
through ok. If anything is wrong it will die with a fairly friendly
_whoa
($self->{Curr_Test
} < 0, 'Says here you ran a negative number of tests!');
_whoa
(!$self->{Have_Plan
} and $self->{Curr_Test
},
'Somehow your tests ran without a plan!');
_whoa
($self->{Curr_Test
} != @
{ $self->{Test_Results
} },
'Somehow you got a different number of results than tests ran!');
_whoa($check, $description);
A sanity check, similar to assert(). If the $check is true, something
has gone horribly wrong. It will die with the given $description and
a note to contact the author.
This should never happen
! Please contact the author immediately
!
Perl seems to have some trouble with exiting inside an END block. 5.005_03
and 5.6.1 both seem to do odd things. Instead, this function edits $?
directly. It should ONLY be called from inside an END block. It
doesn't actually exit, that's your job.
# We don't want to muck with death in an eval, but $^S isn't
# totally reliable. 5.005_03 and 5.6.1 both do the wrong thing
# with it. Instead, we use caller. This also means it runs under
for( my $stack = 1; my $sub = (CORE
::caller($stack))[3]; $stack++ ) {
$in_eval = 1 if $sub =~ /^\(eval\)/;
$Test->{Test_Died
} = 1 unless $in_eval;
# Don't bother with an ending if this is a forked copy. Only the parent
# Exit if plan() was never called. This is so "require Test::Simple"
# Don't do an ending if we bailed out.
if( ($self->{Original_Pid
} != $$) or
(!$self->{Have_Plan
} && !$self->{Test_Died
}) or
# Figure out if we passed or failed and print helpful messages.
my $test_results = $self->{Test_Results
};
# The plan? We have no plan.
$self->_print("1..$self->{Curr_Test}\n") unless $self->no_header;
$self->{Expected_Tests
} = $self->{Curr_Test
};
# Auto-extended arrays and elements which aren't explicitly
# filled in with a shared reference will puke under 5.8.0
# ithreads. So we have to fill them in by hand. :(
my $empty_result = &share
({});
for my $idx ( 0..$self->{Expected_Tests
}-1 ) {
$test_results->[$idx] = $empty_result
unless defined $test_results->[$idx];
my $num_failed = grep !$_->{'ok'},
@
{$test_results}[0..$self->{Curr_Test
}-1];
my $num_extra = $self->{Curr_Test
} - $self->{Expected_Tests
};
my $s = $self->{Expected_Tests
} == 1 ?
'' : 's';
Looks like you planned $self->{Expected_Tests} test$s but only ran $self->{Curr_Test}.
elsif( $num_extra > 0 ) {
my $s = $self->{Expected_Tests
} == 1 ?
'' : 's';
Looks like you planned $self->{Expected_Tests} test$s but ran $num_extra extra.
my $num_tests = $self->{Curr_Test
};
my $s = $num_failed == 1 ?
'' : 's';
my $qualifier = $num_extra == 0 ?
'' : ' run';
Looks like you failed $num_failed test$s of $num_tests$qualifier.
if( $self->{Test_Died
} ) {
Looks like your test died just after $self->{Curr_Test}.
_my_exit
( 255 ) && return;
$exit_code = $num_failed <= 254 ?
$num_failed : 254;
elsif( $num_extra != 0 ) {
_my_exit
( $exit_code ) && return;
elsif ( $self->{Skip_All
} ) {
elsif ( $self->{Test_Died
} ) {
Looks like your test died before it could output anything.
_my_exit
( 255 ) && return;
$self->diag("No tests run!\n");
_my_exit
( 255 ) && return;
$Test->_ending if defined $Test and !$Test->no_ending;
If all your tests passed, Test::Builder will exit with zero (which is
normal). If anything failed it will exit with how many failed. If
you run less (or more) tests than you planned, the missing (or extras)
will be considered failures. If no tests were ever run Test::Builder
will throw a warning and exit with 255. If the test died, even after
having successfully completed all its tests, it will still be
considered a failure and will exit with 255.
255 test died or all passed but wrong # of tests run
any other number how many failed (including missing or extras)
If you fail more than 254 tests, it will be reported as 254.
In perl 5.8.0 and later, Test::Builder is thread-safe. The test
number is shared amongst all threads. This means if one thread sets
the test number using current_test() they will all be effected.
Test::Builder is only thread-aware if threads.pm is loaded I<before>
CPAN can provide the best examples. Test::Simple, Test::More,
Test::Exception and Test::Differences all use Test::Builder.
Test::Simple, Test::More, Test::Harness
Original code by chromatic, maintained by Michael G Schwern
E<lt>schwern@pobox.comE<gt>
Copyright 2002, 2004 by chromatic E<lt>chromatic@wgz.orgE<gt> and
Michael G Schwern E<lt>schwern@pobox.comE<gt>.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
See F<http://www.perl.com/perl/misc/Artistic.html>