18 my $results = $ARGV[1];
26 open FD, "$results" or die "open results";
28 m/^(\w*)\s+(<\S+>)$/ or die "syntax error";
30 my ($kind, $msgid) = ($1,$2);
32 push $expected{$kind}, $msgid;
38 my $bug = Emesinae::Bug->new( $dbh, ID => $bugid );
40 $actual{$_->{msgid}} = $_ foreach $bug->messages();
44 foreach ( @{$expected{Normal}} ) {
46 #print "Found expected message $_\n";
49 print "Expected message not found: $_\n";
54 foreach ( @{ $expected{Pruned}} ) {
55 next unless $actual{$_};
56 print "Found message which should be pruned: $_\n";
61 # At this point all thatshould remain in %actual is control replies.
65 # We generate control replies ourselves so they must have an In-Reply-To
66 # header. Construct a lookup table.
67 while ( my ($msgid,$msg) = each(%actual) ) {
68 my $tempdir = File::Temp::tempdir();
69 my $mime = $msg->get_mime($tempdir);
70 my $head = $mime->head;
72 $irt{$msgid} = $head->get('in-reply-to');
75 rmtree $tempdir, 0, 1;
78 foreach my $cr ( @{ $expected{ControlReply} } ) {
79 my @msgs = grep { $irt{$_} eq $cr } keys %actual;
82 # This is possible in real life, but does not (currently) occur
83 # within the test harness
84 print "Got unexpected number of control replies to: $cr\n";
87 #print "Got expected reply to $cr in $msgs[0]\n";
88 delete $actual{$msgs[0]};
90 print "Missing ControlReply to: $cr\n";
95 # At this point anything which remains is unexpected
96 foreach ( keys %actual ) {
97 print "Unexpected message in results: $_\n";
101 print "FAILED: $result errors\n" if $result;