| Perlbug documentation | view source | Contained in the Perlbug distribution. |
Perlbug::Test - Perlbug testing module
Utility functions for Perlbug test scripts, several wrappers for the email side of things...
Output is seen from output() when TEST_VERBOSE is set to 1,
or when the script is being run directly.
Will set mailing to 0, meaning mails will be printed, rather than sent.
Set the current admin to the userid of the local bugmaster.
use Perlbug::Base;
use Perlbug::Test; # calls Test;
my $o_email = Perlbug::Base->new;
my $o_test = Perlbug::Test->new($o_base);
plan('todo' => 1);
my %header = ('To' => 'perlbug@perl.org');
my $o_int = $o_email->setup_int(\%header, 'mail body perl');
my ($switch, $msg) = $o_email->parse_mail($o_int);
if ($switch eq 'B') {
ok($test);
output("passed");
} else {
notok($test);
output("failed: $switch, $msg");
}
Create new Perlbug::Test object.
Sets current ( admin => $bugmaster, fatal => 0, isatest => 1 ):
my $o_test = Perlbug::Test->new(); # generic my $o_email_test = Perlbug::Test->new($o_email); # guess :-)
prints given args with newline, warns if $Perlbug::DEBUG set
output("message");
Compare two arrays: returns 1 if identical, 0 if not.
my $identical = $o_test->compare(\@arry1, \@arry2);
Provides mapping for default email content, passes back up to $o_email.
my $random_target_address = $o_test->target
my $random_forward_address = $o_test->forward
Tends to return member variables or, (where this is not supported), wraps any unhandlable calls to $o_arg->$meth(), where $o_arg is the Perlbug::Interface::Xxx->new object given by new() (see above);
my $bugdb = $o_test->email('bugdb');
my $test_bugid = $o_test->bugid
my $test_domain = $o_test->domain
my $test_body = $o_test->body
and so on
Return 0(odd) or 1(even) based on last number of given filename
my $num = iseven($filename);
Return 1(odd) or 0(even) based on last number of given filename
my $num = isodd($filename);
Return 1(ok) or 0(not) based on filename and arg, where arg just has to be successful in some way.
$i_isok = okbyfilearg('test0.tst', 1); # false (0)
$i_isok = okbyfilearg('test1.tst', 1); # true (1)
$i_isok = okbyfilearg('test2.tst', 0); # true (1)
$i_isok = okbyfilearg('test3.tst', 0); # false (0)
Wraps getting test material filenames from test directory, incorporates test count and check that all expected types are found.
my @tests = get_tests($t_dir, qw(this that and the other));
Fails if expected directory list or any files not found.
Return Mail Iinternet object from dir,file:
Or undef:
my $o_int = file2minet($filename);
Wrapper to return args from Mail Internet object, ready for method check_mail(@args)
Or ();
my @args = minet2args($o_int);
Returns X-Perlbug-Tag and X-Perlbug-Line headers from Mail Internet object:
Or ();
Instead of:
my ($o_hdr, $header, $body) = $self->splice($o_int);
my $tag = $o_hdr->get('X-Perlbug-Tag') || '';
my $line = $o_hdr->get('X-Perlbug-Line') || '';
You can:
my ($tag, $line) = minet2tagline($o_int);
Check headers against various given parameters, attempts to read all required lines/data.
my ($o_hdr, $header, $body) = $o_mail->splice($o_int);
my @should = $o_hdr->get('X-Perlbug-Match');
my @shouldnt = $o_hdr->get('X-Perlbug-Match-Non');
my @shouldfail = $o_hdr->get('X-Perlbug-Match-Bad');
($i_ok, $feedback) = $o_bugmail->check_mail($o_new, $body, \@should, \@shouldnt, \@shouldfail);
warn "Mail check failure($i_ok): ($feedback)\n" unless $i_ok == 1;
Richard Foley perlbug@rfi.net 2000 2001
| Perlbug documentation | view source | Contained in the Perlbug distribution. |