NAME

Perlbug::TestBed - Perlbug testing module

DESCRIPTION

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.

Note that files with odd filenames (test_1, test_5, etc) are normally expected to succeed with the given function test, and even names are expected to fail, thus giving a checkable failure.

Names with only a zero, ie: my_test_0 are purely placeholders, and should be ignored.

All tests sit in directories with only numbers for names.

Testable per dir|file

	0 = placeholder
	1 = success
	2 = failure

There are a couple of email specific helper methods which require input from a particular set of tags, minet2args(), minet2tagline() and check_mail().

SYNOPSIS

    use Perlbug::TestBed;
	use TestBed;
	plan('todo' => 8); # will do nine(9)
	my $test = 0;
	
	my $o_test = Perlbug::TestBed->new('Email'); # currently ignored
	my @tests = get_tests('testmails/head2head', qw(this that etc));
	
	my ($i_ok, $data) = $o_test->check_header(*STDIN); # for example
	if ($i_ok == 1) { # == 1 (hopefully :-) || 0 :-(
		ok($test);
	} else {
		notok($test);
	}
	
	output($test, 'data');
	output("done test($test)");
	

METHODS

new

Create new Perlbug::TestBed object:

    my $o_test = Perlbug::TestBed->new();              # generic

	my $o_email_test = Perlbug::TestBed->new('Email'); # guess :-)
output

prints given args

iseven

Return 0(odd) or 1(even) based on last number of given filename

my $num = iseven($filename);
isodd

Return 1(odd) or 0(even) based on last number of given filename

my $num = isodd($filename);
okbyfilearg

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)
get_rand_msgid

Returns randomised recognisableid . processid . rand(time)

my $it = get_rand_msgid();
get_tests

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.

file2minet

Return Mail Iinternet object from dir,file:

Or undef:

my $o_int = file2minet($filename);
minet2args

Wrapper to return args from Mail Internet object, ready for method check_mail(@args)

Or ();

my @args = minet2args($o_int); 	
minet2tagline

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_mail

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;

AUTHOR

Richard Foley perlbug@rfi.net 2000