Skip to content

Commit

Permalink
fix bug in regexp check
Browse files Browse the repository at this point in the history
  • Loading branch information
apocalypse committed Dec 13, 2009
1 parent 554dffa commit ee5d204
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Changes
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Revision history for Perl extension Test::Reporter::POEGateway

Added the "maildone" event to the emailer
Minor POD tweaks
Don't load file-related modules if we're enabling poegateway in the mailer
Don't load file-related modules if we're using intra-session passing of reports

* 0.01

Expand Down
15 changes: 12 additions & 3 deletions lib/Test/Reporter/POEGateway.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ use base 'POE::Session::AttributeBased';

# Misc stuff
use HTTP::Request::Params;
use YAML::Tiny qw( DumpFile );
use Digest::SHA qw( sha1_hex );
use File::Spec;

# Set some constants
BEGIN {
Expand Down Expand Up @@ -88,6 +85,7 @@ sub spawn {
} else {
# setup the path to store reports
if ( ! exists $opt{'reports'} or ! defined $opt{'reports'} ) {
require File::Spec;
my $path = File::Spec->catdir( $ENV{HOME}, 'cpan_reports' );
if ( DEBUG ) {
warn "Using default REPORTS = '$path'";
Expand Down Expand Up @@ -166,6 +164,17 @@ sub _start : State {
],
) or die 'Unable to create httpd';

# load the file-related modules we need
if ( exists $_[HEAP]->{'REPORTS'} ) {
require YAML::Tiny;
YAML::Tiny->import( qw( DumpFile ) );

require Digest::SHA1;
Digest::SHA1->import( qw( sha1_hex ) );

require File::Spec;
}

return;
}

Expand Down
14 changes: 7 additions & 7 deletions lib/Test/Reporter/POEGateway/Mailer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -532,15 +532,15 @@ sub Got_STDOUT : State {
warn "Got stdout ($data)";
}

# We should get: "OK" or "NOK $error"
# We should get: "OK $msgid" or "NOK $error"
if ( $data =~ /^N?OK/ ) {
my $file = shift( @{ $_[HEAP]->{'NEWFILES'} } );
my $data = $_[HEAP]->{'WHEEL_WORKING'};
$_[HEAP]->{'WHEEL_WORKING'} = 0;

if ( $data =~ /^OK\s+(.+)$/ ) {
if ( $data =~ /^OK\s+(.+)\z/ ) {
my $message_id = $1;
if ( $message_id =~ /^\<(.+)\>$/ ) {
if ( $message_id =~ /^\<([^\>]+)\>\z/ ) {
$message_id = $1; # remove <...> around the ID
}

Expand All @@ -560,15 +560,15 @@ sub Got_STDOUT : State {
$_[KERNEL]->yield( 'send_report' );

if ( defined $_[HEAP]->{'MAILDONE'} and ref $data ) {
$_[KERNEL]->post( $_[HEAP]->{'SESSION'}, $_[HEAP]->{'MAILDONE'}, {
$_[KERNEL]->post( $_[HEAP]->{'SESSION'} => $_[HEAP]->{'MAILDONE'}, {
'STARTTIME' => delete $data->{'_time'},
'STOPTIME' => time,
'DATA' => $data,
'STATUS' => 1,
'MSGID' => $message_id,
} );
}
} elsif ( $data =~ /^NOK\s+(.+)$/ ) {
} elsif ( $data =~ /^NOK\s+(.+)\z/ ) {
my $err = $1;

# argh!
Expand All @@ -581,7 +581,7 @@ sub Got_STDOUT : State {
}

if ( defined $_[HEAP]->{'MAILDONE'} and ref $data ) {
$_[KERNEL]->post( $_[HEAP]->{'SESSION'}, $_[HEAP]->{'MAILDONE'}, {
$_[KERNEL]->post( $_[HEAP]->{'SESSION'} => $_[HEAP]->{'MAILDONE'}, {
'STARTTIME' => delete $data->{'_time'},
'STOPTIME' => time,
'DATA' => $data,
Expand All @@ -590,7 +590,7 @@ sub Got_STDOUT : State {
} );
}
}
} elsif ( $data =~ /^ERROR\s+(.+)$/ ) {
} elsif ( $data =~ /^ERROR\s+(.+)\z/ ) {
# hmpf!
my $err = $1;
warn "Unexpected error: $err";
Expand Down

0 comments on commit ee5d204

Please sign in to comment.