3 use Test::More tests => 14;
8 # Here, we're going to shoot messages through a set of things that can
11 # First, we're going to send mesages to receive.
12 # To do so, we'll first send a message to submit,
13 # then send messages to the newly created bugnumber.
16 use File::Temp qw(tempdir);
18 use Debbugs::MIME qw(create_mime_message);
19 use File::Basename qw(dirname basename);
20 # The test functions are placed here to make things easier
22 use DebbugsTest qw(:all);
25 # HTTP::Server:::Simple defines a SIG{CHLD} handler that breaks system; undef it here.
29 %config = create_debbugs_configuration(debug => exists $ENV{DEBUG}?$ENV{DEBUG}:0);
35 my $sendmail_dir = $config{sendmail_dir};
36 my $spool_dir = $config{spool_dir};
37 my $config_dir = $config{config_dir};
41 diag("spool_dir: $spool_dir\n");
42 diag("config_dir: $config_dir\n");
43 diag("sendmail_dir: $sendmail_dir\n");
47 # We're going to use create mime message to create these messages, and
48 # then just send them to receive.
51 send_message(to=>'submit@bugs.something',
52 headers => [To => 'submit@bugs.something',
53 From => 'foo@bugs.something',
54 Subject => 'Submiting a bug '.$bug,
56 body => <<EOF) or fail('Unable to send message');
60 This is a silly bug $bug
64 # next, we check to see that (at least) the proper messages have been
65 # sent out. 1) ack to submitter 2) mail to maintainer
67 # This keeps track of the previous size of the sendmail directory
70 num_messages_sent($SD_SIZE,10,
72 'submit messages appear to have been sent out properly',
76 # now send a message to the bug
78 send_message(to => '1@bugs.something',
79 headers => [To => '1@bugs.something',
80 From => 'foo@bugs.something',
81 Subject => 'Sending a message to a bug',
83 body => <<EOF) or fail('sending message to 1@bugs.someting failed');
91 num_messages_sent($SD_SIZE,2,
93 '1@bugs.something messages appear to have been sent out properly');
95 # just check to see that control doesn't explode
96 send_message(to => 'control@bugs.something',
97 headers => [To => 'control@bugs.something',
98 From => 'foo@bugs.something',
99 Subject => 'Munging a bug',
101 body => <<EOF) or fail 'message to control@bugs.something failed';
106 # now we need to check to make sure the control message was processed without errors
107 ok(system('sh','-c','find '.$sendmail_dir.q( -type f | xargs grep -q "Subject: Processed: Munging a bug")) == 0,
108 'control@bugs.something message was parsed without errors');
109 eval "use Debbugs::Status qw(read_bug writebug);";
110 my $status = read_bug(bug=>10);
111 ok($status->{blockedby} eq '2','bug 10 is blocked by 2 (and only 2)');
112 $status = read_bug(bug=>2);
113 ok($status->{blocks} eq '10','bug 2 blocks 10 (and only 10)');
115 send_message(to => 'control@bugs.something',
116 headers => [To => 'control@bugs.something',
117 From => 'foo@bugs.something',
118 Subject => 'Munging a bug',
120 body => <<EOF) or fail 'message to control@bugs.something failed';
125 ok(system('sh','-c','find '.$sendmail_dir.q( -type f | xargs grep -q "Subject: Processed: Munging a bug")) == 0,
126 'control@bugs.something message was parsed without errors');
127 $status = read_bug(bug=>10);
128 ok(is_deeply([sort split /\ /,$status->{blockedby}],[qw(2 3 4)]),'bug 10 is blocked by exactly 2, 3, and 4');
129 send_message(to => 'control@bugs.something',
130 headers => [To => 'control@bugs.something',
131 From => 'foo@bugs.something',
132 Subject => 'Munging a bug',
134 body => <<EOF) or fail 'message to control@bugs.something failed';
139 ok(system('sh','-c','find '.$sendmail_dir.q( -type f | xargs grep -q "Subject: Processed: Munging a bug")) == 0,
140 'control@bugs.something message was parsed without errors');
142 $status = read_bug(bug=>10);
143 ok(is_deeply([sort split /\ /,$status->{blockedby}],[qw(3 4)]),'bug 10 is blocked by exactly 3 and 4');
144 $status = read_bug(bug=>3);
145 ok($status->{blocks} eq '10','bug 3 blocks exactly 10');
147 send_message(to => 'control@bugs.something',
148 headers => [To => 'control@bugs.something',
149 From => 'foo@bugs.something',
150 Subject => 'Munging a bug',
152 body => <<EOF) or fail 'message to control@bugs.something failed';
156 ok(system('sh','-c','find '.$sendmail_dir.q( -type f | xargs grep -q "Subject: Processed: Munging a bug")) == 0,
157 'control@bugs.something message was parsed without errors');
160 $status = read_bug(bug=>3);
161 ok($status->{blockedby} eq '5','bug 3 is blocked by exactly 5');