OLD | NEW |
1 #!/usr/bin/perl | 1 #!/usr/bin/perl |
2 # | 2 # |
3 # Copyright (C) 2009, 2010 Chris Jerdonek (chris.jerdonek@gmail.com) | 3 # Copyright (C) 2009, 2010 Chris Jerdonek (chris.jerdonek@gmail.com) |
4 # Copyright (C) Research In Motion 2010. All rights reserved. | 4 # Copyright (C) Research In Motion 2010. All rights reserved. |
5 # | 5 # |
6 # Redistribution and use in source and binary forms, with or without | 6 # Redistribution and use in source and binary forms, with or without |
7 # modification, are permitted provided that the following conditions are | 7 # modification, are permitted provided that the following conditions are |
8 # met: | 8 # met: |
9 # | 9 # |
10 # * Redistributions of source code must retain the above copyright | 10 # * Redistributions of source code must retain the above copyright |
11 # notice, this list of conditions and the following disclaimer. | 11 # notice, this list of conditions and the following disclaimer. |
12 # * Redistributions in binary form must reproduce the above | 12 # * Redistributions in binary form must reproduce the above |
13 # copyright notice, this list of conditions and the following disclaimer | 13 # copyright notice, this list of conditions and the following disclaimer |
14 # in the documentation and/or other materials provided with the | 14 # in the documentation and/or other materials provided with the |
15 # distribution. | 15 # distribution. |
16 # * Neither the name of Google Inc. nor the names of its | 16 # * Neither the name of Google Inc. nor the names of its |
17 # contributors may be used to endorse or promote products derived from | 17 # contributors may be used to endorse or promote products derived from |
18 # this software without specific prior written permission. | 18 # this software without specific prior written permission. |
19 # | 19 # |
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
21 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 21 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
22 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 22 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
23 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 23 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
24 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 24 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
25 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 25 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
26 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 26 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
27 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 27 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
28 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 28 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
29 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 29 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
30 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 30 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
31 | 31 |
32 # Unit tests of VCSUtils::fixChangeLogPatch(). | 32 # Unit tests of VCSUtils::fixChangeLogPatch(). |
33 | 33 |
34 use strict; | 34 use strict; |
35 use warnings; | 35 use warnings; |
36 | 36 |
37 use Test::More; | 37 use Test::More; |
38 use VCSUtils; | 38 use VCSUtils; |
39 | 39 |
40 # The source ChangeLog for these tests is the following: | 40 # The source ChangeLog for these tests is the following: |
41 # | 41 # |
42 # 2009-12-22 Alice <alice@email.address> | 42 # 2009-12-22 Alice <alice@email.address> |
43 # | 43 # |
44 # Reviewed by Ray. | 44 # Reviewed by Ray. |
45 # | 45 # |
46 # Changed some code on 2009-12-22. | 46 # Changed some code on 2009-12-22. |
47 # | 47 # |
48 # * File: | 48 # * File: |
49 # * File2: | 49 # * File2: |
50 # | 50 # |
51 # 2009-12-21 Alice <alice@email.address> | 51 # 2009-12-21 Alice <alice@email.address> |
52 # | 52 # |
53 # Reviewed by Ray. | 53 # Reviewed by Ray. |
54 # | 54 # |
55 # Changed some code on 2009-12-21. | 55 # Changed some code on 2009-12-21. |
56 # | 56 # |
57 # * File: | 57 # * File: |
58 # * File2: | 58 # * File2: |
59 | 59 |
60 my @testCaseHashRefs = ( | 60 my @testCaseHashRefs = ( |
61 { # New test | 61 { # New test |
62 diffName => "fixChangeLogPatch: [no change] In-place change.", | 62 diffName => "fixChangeLogPatch: [no change] In-place change.", |
63 inputText => <<'END', | 63 inputText => <<'END', |
64 --- ChangeLog | 64 --- ChangeLog |
65 +++ ChangeLog | 65 +++ ChangeLog |
66 @@ -1,5 +1,5 @@ | 66 @@ -1,5 +1,5 @@ |
67 2010-12-22 Bob <bob@email.address> | 67 2010-12-22 Bob <bob@email.address> |
68 | 68 |
69 - Reviewed by Sue. | 69 - Reviewed by Sue. |
70 + Reviewed by Ray. | 70 + Reviewed by Ray. |
71 | 71 |
72 Changed some code on 2010-12-22. | 72 Changed some code on 2010-12-22. |
73 END | 73 END |
74 expectedReturn => { | 74 expectedReturn => { |
75 patch => <<'END', | 75 patch => <<'END', |
76 --- ChangeLog | 76 --- ChangeLog |
77 +++ ChangeLog | 77 +++ ChangeLog |
78 @@ -1,5 +1,5 @@ | 78 @@ -1,5 +1,5 @@ |
79 2010-12-22 Bob <bob@email.address> | 79 2010-12-22 Bob <bob@email.address> |
80 | 80 |
81 - Reviewed by Sue. | 81 - Reviewed by Sue. |
82 + Reviewed by Ray. | 82 + Reviewed by Ray. |
83 | 83 |
84 Changed some code on 2010-12-22. | 84 Changed some code on 2010-12-22. |
85 END | 85 END |
86 } | 86 } |
87 }, | 87 }, |
88 { # New test | 88 { # New test |
89 diffName => "fixChangeLogPatch: [no change] Remove first entry.", | 89 diffName => "fixChangeLogPatch: [no change] Remove first entry.", |
90 inputText => <<'END', | 90 inputText => <<'END', |
91 --- ChangeLog | 91 --- ChangeLog |
92 +++ ChangeLog | 92 +++ ChangeLog |
93 @@ -1,11 +1,3 @@ | 93 @@ -1,11 +1,3 @@ |
94 -2010-12-22 Bob <bob@email.address> | 94 -2010-12-22 Bob <bob@email.address> |
95 - | 95 - |
96 - Reviewed by Ray. | 96 - Reviewed by Ray. |
97 - | 97 - |
98 - Changed some code on 2010-12-22. | 98 - Changed some code on 2010-12-22. |
99 - | 99 - |
100 - * File: | 100 - * File: |
101 - | 101 - |
102 2010-12-22 Alice <alice@email.address> | 102 2010-12-22 Alice <alice@email.address> |
103 | 103 |
104 Reviewed by Ray. | 104 Reviewed by Ray. |
105 END | 105 END |
106 expectedReturn => { | 106 expectedReturn => { |
107 patch => <<'END', | 107 patch => <<'END', |
108 --- ChangeLog | 108 --- ChangeLog |
109 +++ ChangeLog | 109 +++ ChangeLog |
110 @@ -1,11 +1,3 @@ | 110 @@ -1,11 +1,3 @@ |
111 -2010-12-22 Bob <bob@email.address> | 111 -2010-12-22 Bob <bob@email.address> |
112 - | 112 - |
113 - Reviewed by Ray. | 113 - Reviewed by Ray. |
114 - | 114 - |
115 - Changed some code on 2010-12-22. | 115 - Changed some code on 2010-12-22. |
116 - | 116 - |
117 - * File: | 117 - * File: |
118 - | 118 - |
119 2010-12-22 Alice <alice@email.address> | 119 2010-12-22 Alice <alice@email.address> |
120 | 120 |
121 Reviewed by Ray. | 121 Reviewed by Ray. |
122 END | 122 END |
123 } | 123 } |
124 }, | 124 }, |
125 { # New test | 125 { # New test |
126 diffName => "fixChangeLogPatch: [no change] Remove entry in the middle.", | 126 diffName => "fixChangeLogPatch: [no change] Remove entry in the middle.", |
127 inputText => <<'END', | 127 inputText => <<'END', |
128 --- ChangeLog | 128 --- ChangeLog |
129 +++ ChangeLog | 129 +++ ChangeLog |
130 @@@ -7,10 +7,6 @@ | 130 @@@ -7,10 +7,6 @@ |
131 | 131 |
132 * File: | 132 * File: |
133 | 133 |
134 -2010-12-22 Bob <bob@email.address> | 134 -2010-12-22 Bob <bob@email.address> |
135 - | 135 - |
136 - Changed some code on 2010-12-22. | 136 - Changed some code on 2010-12-22. |
137 - | 137 - |
138 2010-12-22 Alice <alice@email.address> | 138 2010-12-22 Alice <alice@email.address> |
139 | 139 |
140 Reviewed by Ray. | 140 Reviewed by Ray. |
141 END | 141 END |
142 expectedReturn => { | 142 expectedReturn => { |
143 patch => <<'END', | 143 patch => <<'END', |
144 --- ChangeLog | 144 --- ChangeLog |
145 +++ ChangeLog | 145 +++ ChangeLog |
146 @@@ -7,10 +7,6 @@ | 146 @@@ -7,10 +7,6 @@ |
147 | 147 |
148 * File: | 148 * File: |
149 | 149 |
150 -2010-12-22 Bob <bob@email.address> | 150 -2010-12-22 Bob <bob@email.address> |
151 - | 151 - |
152 - Changed some code on 2010-12-22. | 152 - Changed some code on 2010-12-22. |
153 - | 153 - |
154 2010-12-22 Alice <alice@email.address> | 154 2010-12-22 Alice <alice@email.address> |
155 | 155 |
156 Reviewed by Ray. | 156 Reviewed by Ray. |
157 END | 157 END |
158 } | 158 } |
159 }, | 159 }, |
160 { # New test | 160 { # New test |
161 diffName => "fixChangeLogPatch: [no change] Far apart changes (i.e. more tha
n one chunk).", | 161 diffName => "fixChangeLogPatch: [no change] Far apart changes (i.e. more tha
n one chunk).", |
162 inputText => <<'END', | 162 inputText => <<'END', |
163 --- ChangeLog | 163 --- ChangeLog |
164 +++ ChangeLog | 164 +++ ChangeLog |
165 @@ -7,7 +7,7 @@ | 165 @@ -7,7 +7,7 @@ |
166 | 166 |
167 * File: | 167 * File: |
168 | 168 |
169 -2010-12-22 Bob <bob@email.address> | 169 -2010-12-22 Bob <bob@email.address> |
170 +2010-12-22 Bobby <bob@email.address> | 170 +2010-12-22 Bobby <bob@email.address> |
171 | 171 |
172 Changed some code on 2010-12-22. | 172 Changed some code on 2010-12-22. |
173 | 173 |
174 @@ -21,7 +21,7 @@ | 174 @@ -21,7 +21,7 @@ |
175 | 175 |
176 * File2: | 176 * File2: |
177 | 177 |
178 -2010-12-21 Bob <bob@email.address> | 178 -2010-12-21 Bob <bob@email.address> |
179 +2010-12-21 Bobby <bob@email.address> | 179 +2010-12-21 Bobby <bob@email.address> |
180 | 180 |
181 Changed some code on 2010-12-21. | 181 Changed some code on 2010-12-21. |
182 END | 182 END |
183 expectedReturn => { | 183 expectedReturn => { |
184 patch => <<'END', | 184 patch => <<'END', |
185 --- ChangeLog | 185 --- ChangeLog |
186 +++ ChangeLog | 186 +++ ChangeLog |
187 @@ -7,7 +7,7 @@ | 187 @@ -7,7 +7,7 @@ |
188 | 188 |
189 * File: | 189 * File: |
190 | 190 |
191 -2010-12-22 Bob <bob@email.address> | 191 -2010-12-22 Bob <bob@email.address> |
192 +2010-12-22 Bobby <bob@email.address> | 192 +2010-12-22 Bobby <bob@email.address> |
193 | 193 |
194 Changed some code on 2010-12-22. | 194 Changed some code on 2010-12-22. |
195 | 195 |
196 @@ -21,7 +21,7 @@ | 196 @@ -21,7 +21,7 @@ |
197 | 197 |
198 * File2: | 198 * File2: |
199 | 199 |
200 -2010-12-21 Bob <bob@email.address> | 200 -2010-12-21 Bob <bob@email.address> |
201 +2010-12-21 Bobby <bob@email.address> | 201 +2010-12-21 Bobby <bob@email.address> |
202 | 202 |
203 Changed some code on 2010-12-21. | 203 Changed some code on 2010-12-21. |
204 END | 204 END |
205 } | 205 } |
206 }, | 206 }, |
207 { # New test | 207 { # New test |
208 diffName => "fixChangeLogPatch: [no change] First line is new line.", | 208 diffName => "fixChangeLogPatch: [no change] First line is new line.", |
209 inputText => <<'END', | 209 inputText => <<'END', |
210 --- ChangeLog | 210 --- ChangeLog |
211 +++ ChangeLog | 211 +++ ChangeLog |
212 @@ -1,3 +1,11 @@ | 212 @@ -1,3 +1,11 @@ |
213 +2009-12-22 Bob <bob@email.address> | 213 +2009-12-22 Bob <bob@email.address> |
214 + | 214 + |
215 + Reviewed by Ray. | 215 + Reviewed by Ray. |
216 + | 216 + |
217 + Changed some more code on 2009-12-22. | 217 + Changed some more code on 2009-12-22. |
218 + | 218 + |
219 + * File: | 219 + * File: |
220 + | 220 + |
221 2009-12-22 Alice <alice@email.address> | 221 2009-12-22 Alice <alice@email.address> |
222 | 222 |
223 Reviewed by Ray. | 223 Reviewed by Ray. |
224 END | 224 END |
225 expectedReturn => { | 225 expectedReturn => { |
226 patch => <<'END', | 226 patch => <<'END', |
227 --- ChangeLog | 227 --- ChangeLog |
228 +++ ChangeLog | 228 +++ ChangeLog |
229 @@ -1,3 +1,11 @@ | 229 @@ -1,3 +1,11 @@ |
230 +2009-12-22 Bob <bob@email.address> | 230 +2009-12-22 Bob <bob@email.address> |
231 + | 231 + |
232 + Reviewed by Ray. | 232 + Reviewed by Ray. |
233 + | 233 + |
234 + Changed some more code on 2009-12-22. | 234 + Changed some more code on 2009-12-22. |
235 + | 235 + |
236 + * File: | 236 + * File: |
237 + | 237 + |
238 2009-12-22 Alice <alice@email.address> | 238 2009-12-22 Alice <alice@email.address> |
239 | 239 |
240 Reviewed by Ray. | 240 Reviewed by Ray. |
241 END | 241 END |
242 } | 242 } |
243 }, | 243 }, |
244 { # New test | 244 { # New test |
245 diffName => "fixChangeLogPatch: [no change] No date string.", | 245 diffName => "fixChangeLogPatch: [no change] No date string.", |
246 inputText => <<'END', | 246 inputText => <<'END', |
247 --- ChangeLog | 247 --- ChangeLog |
248 +++ ChangeLog | 248 +++ ChangeLog |
249 @@ -6,6 +6,7 @@ | 249 @@ -6,6 +6,7 @@ |
250 | 250 |
251 * File: | 251 * File: |
252 * File2: | 252 * File2: |
253 + * File3: | 253 + * File3: |
254 | 254 |
255 2009-12-21 Alice <alice@email.address> | 255 2009-12-21 Alice <alice@email.address> |
256 | 256 |
257 END | 257 END |
258 expectedReturn => { | 258 expectedReturn => { |
259 patch => <<'END', | 259 patch => <<'END', |
260 --- ChangeLog | 260 --- ChangeLog |
261 +++ ChangeLog | 261 +++ ChangeLog |
262 @@ -6,6 +6,7 @@ | 262 @@ -6,6 +6,7 @@ |
263 | 263 |
264 * File: | 264 * File: |
265 * File2: | 265 * File2: |
266 + * File3: | 266 + * File3: |
267 | 267 |
268 2009-12-21 Alice <alice@email.address> | 268 2009-12-21 Alice <alice@email.address> |
269 | 269 |
270 END | 270 END |
271 } | 271 } |
272 }, | 272 }, |
273 { # New test | 273 { # New test |
274 diffName => "fixChangeLogPatch: New entry inserted in middle.", | 274 diffName => "fixChangeLogPatch: New entry inserted in middle.", |
275 inputText => <<'END', | 275 inputText => <<'END', |
276 --- ChangeLog | 276 --- ChangeLog |
277 +++ ChangeLog | 277 +++ ChangeLog |
278 @@ -11,6 +11,14 @@ | 278 @@ -11,6 +11,14 @@ |
279 | 279 |
280 Reviewed by Ray. | 280 Reviewed by Ray. |
281 | 281 |
282 + Changed some more code on 2009-12-21. | 282 + Changed some more code on 2009-12-21. |
283 + | 283 + |
284 + * File: | 284 + * File: |
285 + | 285 + |
286 +2009-12-21 Alice <alice@email.address> | 286 +2009-12-21 Alice <alice@email.address> |
287 + | 287 + |
288 + Reviewed by Ray. | 288 + Reviewed by Ray. |
289 + | 289 + |
290 Changed some code on 2009-12-21. | 290 Changed some code on 2009-12-21. |
291 | 291 |
292 * File: | 292 * File: |
293 END | 293 END |
294 expectedReturn => { | 294 expectedReturn => { |
295 patch => <<'END', | 295 patch => <<'END', |
296 --- ChangeLog | 296 --- ChangeLog |
297 +++ ChangeLog | 297 +++ ChangeLog |
298 @@ -1,3 +1,11 @@ | 298 @@ -1,3 +1,11 @@ |
299 +2009-12-21 Alice <alice@email.address> | 299 +2009-12-21 Alice <alice@email.address> |
300 + | 300 + |
301 + Reviewed by Ray. | 301 + Reviewed by Ray. |
302 + | 302 + |
303 + Changed some more code on 2009-12-21. | 303 + Changed some more code on 2009-12-21. |
304 + | 304 + |
305 + * File: | 305 + * File: |
306 + | 306 + |
307 2009-12-21 Alice <alice@email.address> | 307 2009-12-21 Alice <alice@email.address> |
308 | 308 |
309 Reviewed by Ray. | 309 Reviewed by Ray. |
310 END | 310 END |
311 } | 311 } |
312 }, | 312 }, |
313 { # New test | 313 { # New test |
314 diffName => "fixChangeLogPatch: New entry inserted earlier in the file, but
after an entry with the same author and date.", | 314 diffName => "fixChangeLogPatch: New entry inserted earlier in the file, but
after an entry with the same author and date.", |
315 inputText => <<'END', | 315 inputText => <<'END', |
316 --- ChangeLog | 316 --- ChangeLog |
317 +++ ChangeLog | 317 +++ ChangeLog |
318 @@ -70,6 +70,14 @@ | 318 @@ -70,6 +70,14 @@ |
319 | 319 |
320 2009-12-22 Alice <alice@email.address> | 320 2009-12-22 Alice <alice@email.address> |
321 | 321 |
322 + Reviewed by Sue. | 322 + Reviewed by Sue. |
323 + | 323 + |
324 + Changed some more code on 2009-12-22. | 324 + Changed some more code on 2009-12-22. |
325 + | 325 + |
326 + * File: | 326 + * File: |
327 + | 327 + |
328 +2009-12-22 Alice <alice@email.address> | 328 +2009-12-22 Alice <alice@email.address> |
329 + | 329 + |
330 Reviewed by Ray. | 330 Reviewed by Ray. |
331 | 331 |
332 Changed some code on 2009-12-22. | 332 Changed some code on 2009-12-22. |
333 END | 333 END |
334 expectedReturn => { | 334 expectedReturn => { |
335 patch => <<'END', | 335 patch => <<'END', |
336 --- ChangeLog | 336 --- ChangeLog |
337 +++ ChangeLog | 337 +++ ChangeLog |
338 @@ -1,3 +1,11 @@ | 338 @@ -1,3 +1,11 @@ |
339 +2009-12-22 Alice <alice@email.address> | 339 +2009-12-22 Alice <alice@email.address> |
340 + | 340 + |
341 + Reviewed by Sue. | 341 + Reviewed by Sue. |
342 + | 342 + |
343 + Changed some more code on 2009-12-22. | 343 + Changed some more code on 2009-12-22. |
344 + | 344 + |
345 + * File: | 345 + * File: |
346 + | 346 + |
347 2009-12-22 Alice <alice@email.address> | 347 2009-12-22 Alice <alice@email.address> |
348 | 348 |
349 Reviewed by Ray. | 349 Reviewed by Ray. |
350 END | 350 END |
351 } | 351 } |
352 }, | 352 }, |
353 { # New test | 353 { # New test |
354 diffName => "fixChangeLogPatch: Leading context includes first line.", | 354 diffName => "fixChangeLogPatch: Leading context includes first line.", |
355 inputText => <<'END', | 355 inputText => <<'END', |
356 --- ChangeLog | 356 --- ChangeLog |
357 +++ ChangeLog | 357 +++ ChangeLog |
358 @@ -1,5 +1,13 @@ | 358 @@ -1,5 +1,13 @@ |
359 2009-12-22 Alice <alice@email.address> | 359 2009-12-22 Alice <alice@email.address> |
360 | 360 |
361 + Reviewed by Sue. | 361 + Reviewed by Sue. |
362 + | 362 + |
363 + Changed some more code on 2009-12-22. | 363 + Changed some more code on 2009-12-22. |
364 + | 364 + |
365 + * File: | 365 + * File: |
366 + | 366 + |
367 +2009-12-22 Alice <alice@email.address> | 367 +2009-12-22 Alice <alice@email.address> |
368 + | 368 + |
369 Reviewed by Ray. | 369 Reviewed by Ray. |
370 | 370 |
371 Changed some code on 2009-12-22. | 371 Changed some code on 2009-12-22. |
372 END | 372 END |
373 expectedReturn => { | 373 expectedReturn => { |
374 patch => <<'END', | 374 patch => <<'END', |
375 --- ChangeLog | 375 --- ChangeLog |
376 +++ ChangeLog | 376 +++ ChangeLog |
377 @@ -1,3 +1,11 @@ | 377 @@ -1,3 +1,11 @@ |
378 +2009-12-22 Alice <alice@email.address> | 378 +2009-12-22 Alice <alice@email.address> |
379 + | 379 + |
380 + Reviewed by Sue. | 380 + Reviewed by Sue. |
381 + | 381 + |
382 + Changed some more code on 2009-12-22. | 382 + Changed some more code on 2009-12-22. |
383 + | 383 + |
384 + * File: | 384 + * File: |
385 + | 385 + |
386 2009-12-22 Alice <alice@email.address> | 386 2009-12-22 Alice <alice@email.address> |
387 | 387 |
388 Reviewed by Ray. | 388 Reviewed by Ray. |
389 END | 389 END |
390 } | 390 } |
391 }, | 391 }, |
392 { # New test | 392 { # New test |
393 diffName => "fixChangeLogPatch: Leading context does not include first line.
", | 393 diffName => "fixChangeLogPatch: Leading context does not include first line.
", |
394 inputText => <<'END', | 394 inputText => <<'END', |
395 @@ -2,6 +2,14 @@ | 395 @@ -2,6 +2,14 @@ |
396 | 396 |
397 Reviewed by Ray. | 397 Reviewed by Ray. |
398 | 398 |
399 + Changed some more code on 2009-12-22. | 399 + Changed some more code on 2009-12-22. |
400 + | 400 + |
401 + * File: | 401 + * File: |
402 + | 402 + |
403 +2009-12-22 Alice <alice@email.address> | 403 +2009-12-22 Alice <alice@email.address> |
404 + | 404 + |
405 + Reviewed by Ray. | 405 + Reviewed by Ray. |
406 + | 406 + |
407 Changed some code on 2009-12-22. | 407 Changed some code on 2009-12-22. |
408 | 408 |
409 * File: | 409 * File: |
410 END | 410 END |
411 expectedReturn => { | 411 expectedReturn => { |
412 patch => <<'END', | 412 patch => <<'END', |
413 @@ -1,3 +1,11 @@ | 413 @@ -1,3 +1,11 @@ |
414 +2009-12-22 Alice <alice@email.address> | 414 +2009-12-22 Alice <alice@email.address> |
415 + | 415 + |
416 + Reviewed by Ray. | 416 + Reviewed by Ray. |
417 + | 417 + |
418 + Changed some more code on 2009-12-22. | 418 + Changed some more code on 2009-12-22. |
419 + | 419 + |
420 + * File: | 420 + * File: |
421 + | 421 + |
422 2009-12-22 Alice <alice@email.address> | 422 2009-12-22 Alice <alice@email.address> |
423 | 423 |
424 Reviewed by Ray. | 424 Reviewed by Ray. |
425 END | 425 END |
426 } | 426 } |
427 }, | 427 }, |
428 { # New test | 428 { # New test |
429 diffName => "fixChangeLogPatch: Non-consecutive line additions.", | 429 diffName => "fixChangeLogPatch: Non-consecutive line additions.", |
430 | 430 |
431 # This can occur, for example, if the new ChangeLog entry includes | 431 # This can occur, for example, if the new ChangeLog entry includes |
432 # trailing white space in the first blank line but not the second. | 432 # trailing white space in the first blank line but not the second. |
433 # A diff command can then match the second blank line of the new | 433 # A diff command can then match the second blank line of the new |
434 # ChangeLog entry with the first blank line of the old. | 434 # ChangeLog entry with the first blank line of the old. |
435 # The svn diff command with the default --diff-cmd has done this. | 435 # The svn diff command with the default --diff-cmd has done this. |
436 inputText => <<'END', | 436 inputText => <<'END', |
437 @@ -1,5 +1,11 @@ | 437 @@ -1,5 +1,11 @@ |
438 2009-12-22 Alice <alice@email.address> | 438 2009-12-22 Alice <alice@email.address> |
439 + <pretend-whitespace> | 439 + <pretend-whitespace> |
440 + Reviewed by Ray. | 440 + Reviewed by Ray. |
441 | 441 |
442 + Changed some more code on 2009-12-22. | 442 + Changed some more code on 2009-12-22. |
443 + | 443 + |
444 +2009-12-22 Alice <alice@email.address> | 444 +2009-12-22 Alice <alice@email.address> |
445 + | 445 + |
446 Reviewed by Ray. | 446 Reviewed by Ray. |
447 | 447 |
448 Changed some code on 2009-12-22. | 448 Changed some code on 2009-12-22. |
449 END | 449 END |
450 expectedReturn => { | 450 expectedReturn => { |
451 patch => <<'END', | 451 patch => <<'END', |
452 @@ -1,3 +1,9 @@ | 452 @@ -1,3 +1,9 @@ |
453 +2009-12-22 Alice <alice@email.address> | 453 +2009-12-22 Alice <alice@email.address> |
454 + <pretend-whitespace> | 454 + <pretend-whitespace> |
455 + Reviewed by Ray. | 455 + Reviewed by Ray. |
456 + | 456 + |
457 + Changed some more code on 2009-12-22. | 457 + Changed some more code on 2009-12-22. |
458 + | 458 + |
459 2009-12-22 Alice <alice@email.address> | 459 2009-12-22 Alice <alice@email.address> |
460 | 460 |
461 Reviewed by Ray. | 461 Reviewed by Ray. |
462 END | 462 END |
463 } | 463 } |
464 }, | 464 }, |
465 { # New test | 465 { # New test |
466 diffName => "fixChangeLogPatch: Additional edits after new entry.", | 466 diffName => "fixChangeLogPatch: Additional edits after new entry.", |
467 inputText => <<'END', | 467 inputText => <<'END', |
468 @@ -2,10 +2,17 @@ | 468 @@ -2,10 +2,17 @@ |
469 | 469 |
470 Reviewed by Ray. | 470 Reviewed by Ray. |
471 | 471 |
472 + Changed some more code on 2009-12-22. | 472 + Changed some more code on 2009-12-22. |
473 + | 473 + |
474 + * File: | 474 + * File: |
475 + | 475 + |
476 +2009-12-22 Alice <alice@email.address> | 476 +2009-12-22 Alice <alice@email.address> |
477 + | 477 + |
478 + Reviewed by Ray. | 478 + Reviewed by Ray. |
479 + | 479 + |
480 Changed some code on 2009-12-22. | 480 Changed some code on 2009-12-22. |
481 | 481 |
482 * File: | 482 * File: |
483 - * File2: | 483 - * File2: |
484 | 484 |
485 2009-12-21 Alice <alice@email.address> | 485 2009-12-21 Alice <alice@email.address> |
486 | 486 |
487 END | 487 END |
488 expectedReturn => { | 488 expectedReturn => { |
489 patch => <<'END', | 489 patch => <<'END', |
490 @@ -1,11 +1,18 @@ | 490 @@ -1,11 +1,18 @@ |
491 +2009-12-22 Alice <alice@email.address> | 491 +2009-12-22 Alice <alice@email.address> |
492 + | 492 + |
493 + Reviewed by Ray. | 493 + Reviewed by Ray. |
494 + | 494 + |
495 + Changed some more code on 2009-12-22. | 495 + Changed some more code on 2009-12-22. |
496 + | 496 + |
497 + * File: | 497 + * File: |
498 + | 498 + |
499 2009-12-22 Alice <alice@email.address> | 499 2009-12-22 Alice <alice@email.address> |
500 | 500 |
501 Reviewed by Ray. | 501 Reviewed by Ray. |
502 | 502 |
503 Changed some code on 2009-12-22. | 503 Changed some code on 2009-12-22. |
504 | 504 |
505 * File: | 505 * File: |
506 - * File2: | 506 - * File2: |
507 | 507 |
508 2009-12-21 Alice <alice@email.address> | 508 2009-12-21 Alice <alice@email.address> |
509 | 509 |
510 END | 510 END |
511 } | 511 } |
512 }, | 512 }, |
513 ); | 513 ); |
514 | 514 |
515 my $testCasesCount = @testCaseHashRefs; | 515 my $testCasesCount = @testCaseHashRefs; |
516 plan(tests => $testCasesCount); # Total number of assertions. | 516 plan(tests => $testCasesCount); # Total number of assertions. |
517 | 517 |
518 foreach my $testCase (@testCaseHashRefs) { | 518 foreach my $testCase (@testCaseHashRefs) { |
519 my $testNameStart = "fixChangeLogPatch(): $testCase->{diffName}: comparing"; | 519 my $testNameStart = "fixChangeLogPatch(): $testCase->{diffName}: comparing"; |
520 | 520 |
521 my $got = VCSUtils::fixChangeLogPatch($testCase->{inputText}); | 521 my $got = VCSUtils::fixChangeLogPatch($testCase->{inputText}); |
522 my $expectedReturn = $testCase->{expectedReturn}; | 522 my $expectedReturn = $testCase->{expectedReturn}; |
523 | 523 |
524 is_deeply($got, $expectedReturn, "$testNameStart return value."); | 524 is_deeply($got, $expectedReturn, "$testNameStart return value."); |
525 } | 525 } |
OLD | NEW |