]> git.donarmstrong.com Git - debbugs.git/blob - t/12_merge.t
modify merge tests to test merging blocking bugs
[debbugs.git] / t / 12_merge.t
1 # -*- mode: cperl;-*-
2
3 use Test::More;
4
5 use warnings;
6 use strict;
7
8 # Here, we're going to shoot messages through a set of things that can
9 # happen.
10
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.
14
15 use IO::File;
16 use File::Temp qw(tempdir);
17 use Cwd qw(getcwd);
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
21 use lib qw(t/lib);
22 use DebbugsTest qw(:all);
23 use Data::Dumper;
24
25 # HTTP::Server:::Simple defines a SIG{CHLD} handler that breaks system; undef it here.
26 $SIG{CHLD} = sub {};
27 my %config = create_debbugs_configuration();
28
29
30 my $sendmail_dir = $config{sendmail_dir};
31 my $spool_dir = $config{spool_dir};
32 my $config_dir = $config{config_dir};
33
34
35
36 # We're going to use create mime message to create these messages, and
37 # then just send them to receive.
38
39 send_message(to=>'submit@bugs.something',
40              headers => [To   => 'submit@bugs.something',
41                          From => 'foo@bugs.something',
42                          Subject => 'Submiting a bug',
43                         ],
44              body => <<EOF) or fail('Unable to send message');
45 Package: foo
46 Severity: normal
47
48 This is a silly bug
49 EOF
50
51 # now we check to see that we have a bug, and nextnumber has been incremented
52 ok(-e "$spool_dir/db-h/01/1.log",'log file created');
53 ok(-e "$spool_dir/db-h/01/1.summary",'sumary file created');
54 ok(-e "$spool_dir/db-h/01/1.status",'status file created');
55 ok(-e "$spool_dir/db-h/01/1.report",'report file created');
56
57 # next, we check to see that (at least) the proper messages have been
58 # sent out. 1) ack to submitter 2) mail to maintainer
59
60 # This keeps track of the previous size of the sendmail directory
61 my $SD_SIZE = 0;
62 $SD_SIZE =
63     num_messages_sent($SD_SIZE,2,
64                       $sendmail_dir,
65                       'submit messages appear to have been sent out properly',
66                      );
67
68
69 # now send a message to the bug
70
71 send_message(to => '1@bugs.something',
72              headers => [To   => '1@bugs.something',
73                          From => 'foo@bugs.something',
74                          Subject => 'Sending a message to a bug',
75                         ],
76              body => <<EOF) or fail('sending message to 1@bugs.someting failed');
77 Package: foo
78 Severity: normal
79
80 This is a silly bug
81 EOF
82
83 $SD_SIZE =
84     num_messages_sent($SD_SIZE,2,
85                       $sendmail_dir,
86                       '1@bugs.something messages appear to have been sent out properly');
87
88 # just check to see that control doesn't explode
89 send_message(to => 'control@bugs.something',
90              headers => [To   => 'control@bugs.something',
91                          From => 'foo@bugs.something',
92                          Subject => 'Munging a bug',
93                         ],
94              body => <<EOF) or fail 'message to control@bugs.something failed';
95 severity 1 wishlist
96 retitle 1 new title
97 thanks
98 EOF
99
100 $SD_SIZE =
101    num_messages_sent($SD_SIZE,1,
102                      $sendmail_dir,
103                      'control@bugs.something messages appear to have been sent out properly');
104 # now we need to check to make sure the control message was processed without errors
105 ok(system('sh','-c','find '.$sendmail_dir.q( -type f | xargs grep -q "Subject: Processed: Munging a bug")) == 0,
106    'control@bugs.something message was parsed without errors');
107 # now we need to check to make sure that the control message actually did anything
108 # This is an eval because $ENV{DEBBUGS_CONFIG_FILE} isn't set at BEGIN{} time
109 eval "use Debbugs::Status qw(read_bug writebug);";
110 my $status = read_bug(bug=>1);
111 ok($status->{subject} eq 'new title','bug 1 retitled');
112 ok($status->{severity} eq 'wishlist','bug 1 wishlisted');
113
114 # now we're going to go through and methododically test all of the control commands.
115 my @control_commands =
116      (
117       clone        => {command => 'clone',
118                        value   => '1 -1',
119                        status_key => 'package',
120                        status_value => 'foo',
121                        bug          => '2',
122                       },
123       merge        => {command => 'merge',
124                        value   => '1 2',
125                        status_key => 'mergedwith',
126                        status_value => '2',
127                       },
128       unmerge      => {command => 'unmerge',
129                        value   => '1',
130                        status_key => 'mergedwith',
131                        status_value => '',
132                       },
133      );
134
135 test_control_commands(\%config,
136                       @control_commands);
137
138 send_message(to => 'control@bugs.something',
139              headers => [To   => 'control@bugs.something',
140                          From => 'foo@bugs.something',
141                          Subject => "Munging a bug with lots of stuff",
142                         ],
143              body => <<'EOF') or fail 'message to control@bugs.something failed';
144 debug 10
145 clone 2 -1 -2 -3 -4 -5 -6
146 retitle 2 foo
147 owner 2 bar@baz.com
148 submitter 2 fleb@bleh.com
149 tag 2 unreproducible moreinfo
150 severity 2 grave
151 block -1 by 2
152 block 2 by -2
153 summary 2 4
154 affects 2 bleargh
155 forwarded 2 http://example.com/2
156 close 2
157 tag -3 wontfix
158 fixed -4 1.2-3
159 found -4 1.2-1
160 found -5 1.2-5
161 fixed -5 1.2-6
162 thanks
163 EOF
164
165 test_control_commands(\%config,
166                       forcemerge   => {command => 'forcemerge',
167                                        value   => "2 3\nseverity 2 minor",
168                                        status_key => 'mergedwith',
169                                        status_value => '3',
170                                        bug => 2,
171                                       },
172                       unmerge      => {command => 'unmerge',
173                                        value   => '2',
174                                        status_key => 'mergedwith',
175                                        status_value => '',
176                                        bug => 2,
177                                       },
178                       forcemerge   => {command => 'forcemerge',
179                                        value   => '1 2 5',
180                                        status_key => 'mergedwith',
181                                        status_value => '2 5',
182                                       },
183                       forcemerge   => {command => 'forcemerge',
184                                        value   => '1 2 6',
185                                        status_key => 'mergedwith',
186                                        status_value => '2 5 6',
187                                       },
188                       merge        => {command => 'merge',
189                                        value   => '7 8',
190                                        status_key => 'mergedwith',
191                                        status_value => '8',
192                                        bug => '7',
193                                       },
194                      );
195
196 done_testing();