From 2d0141c307ce045d157d57d5e08c1544cb347877 Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Mon, 29 Jan 2007 23:41:46 -0800 Subject: [PATCH] * More changes to sendmail tester and the mail handling test script - It now runs successfully and tests things appropriately --- t/06_mail_handling.t | 29 +++++++++++++++++++++++++---- t/sendmail_tester | 6 +++--- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/t/06_mail_handling.t b/t/06_mail_handling.t index e7af860..7d71fcb 100644 --- a/t/06_mail_handling.t +++ b/t/06_mail_handling.t @@ -17,6 +17,7 @@ use IO::File; use File::Temp qw(tempdir); use Cwd qw(getcwd); use Debbugs::MIME qw(create_mime_message); +use File::Basename qw(dirname basename); my $sendmail_dir = tempdir(CLEANUP => $ENV{DEBUG}?0:1); @@ -31,9 +32,12 @@ END{ } } +$ENV{DEBBUGS_CONFIG_FILE} ="$config_dir/debbugs_config"; +$ENV{PERL5LIB} = getcwd(); $ENV{SENDMAIL_TESTDIR} = $sendmail_dir; my $sendmail_tester = getcwd().'/t/sendmail_tester'; + unless (-x $sendmail_tester) { BAIL_OUT(q(t/sendmail_tester doesn't exist or isn't executable. You may be in the wrong directory.)); } @@ -41,12 +45,19 @@ unless (-x $sendmail_tester) { my %files_to_create = ("$config_dir/debbugs_config" => < qq(1\n), - "$config_dir/Maintainers" => qq(foo Blah Bleargh ), + "$config_dir/Maintainers" => qq(foo Blah Bleargh \n), + "$config_dir/Maintainers.override" => qq(), + "$config_dir/indices/sources" => <new($file,'w') or BAIL_OUT("Unable to create $file: $!"); print {$fh} $contents; close $fh; @@ -60,13 +71,13 @@ system('ln','-s','index.archive.realtime', "$spool_dir/index.archive"); -$ENV{DEBBUGS_CONFIG_FILE} ="$config_dir/debbugs_config"; # create the spool files and sub directories map {system('mkdir','-p',"$spool_dir/$_"); } map {('db-h/'.$_,'archive/'.$_)} map { sprintf "%02d",$_ % 100} 0..99; system('mkdir','-p',"$spool_dir/incoming"); +system('mkdir','-p',"$spool_dir/lock"); # We're going to use create mime message to create these messages, and @@ -152,6 +163,7 @@ print {$receive} create_mime_message([To => 'control@bugs.something', ], <= 2,'1@bugs.something messages appear to have been sent out properly'); +ok($SD_SIZE_NOW-$SD_SIZE_PREV >= 1,'control@bugs.something messages appear to have been sent out properly'); $SD_SIZE_PREV=$SD_SIZE_NOW; +# now we need to check to make sure the control message was processed without errors +ok(system("sh -c 'find ".$sendmail_dir.q( -type f | xargs grep -q "Subject: Processed: Munging a bug"')) == 0, + 'control@bugs.something message was parsed without errors'); +# now we need to check to make sure that the control message actually did anything +# This is an eval because $ENV{DEBBUGS_CONFIG_FILE} isn't set at BEGIN{} time +eval "use Debbugs::Status qw(read_bug);"; +my $status = read_bug(bug=>1); +ok($status->{subject} eq 'new title','bug 1 retitled'); +ok($status->{severity} eq 'wishlist','bug 1 wishlisted'); diff --git a/t/sendmail_tester b/t/sendmail_tester index 22f1e4c..ace1463 100755 --- a/t/sendmail_tester +++ b/t/sendmail_tester @@ -12,10 +12,10 @@ if (not -d $ENV{SENDMAIL_TESTDIR}) { my $fn = "$ENV{SENDMAIL_TESTDIR}/".time.$$; -my $fh = new IO::File $fn ,'w' or die "Unable to open file $fn for writing: $!"; +my $fh = IO::File->new($fn ,'w') or die "Unable to open file $fn for writing: $!"; -print {$fh} join(' ',map {"'$_'"} @ARGV) or die "Unable to write to file $fn: $!"; +print {$fh} "$0 called with: ", join(' ',map {"'$_'"} @ARGV) or die "Unable to write to file $fn: $!"; print {$fh} "\n\n"; -print {$fh} <> or die "Unable to write to file $fn: $!"; +print {$fh} or die "Unable to write to file $fn: $!"; close $fh or die "Unable to close file $fn: $!"; -- 2.39.2