Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Side by Side Diff: Tools/Scripts/webkitperl/VCSUtils_unittest/parseDiff.pl

Issue 1253013003: Remove all perl scripts from Tools/Scripts (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove the python code to invoke Perl \o/ Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/perl -w
2 #
3 # Copyright (C) 2010 Chris Jerdonek (chris.jerdonek@gmail.com)
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
7 # are met:
8 # 1. Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
13 #
14 # THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
15 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 # DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
25 # Unit tests of parseDiff().
26
27 use strict;
28 use warnings;
29
30 use Test::More;
31 use VCSUtils;
32
33 # The array of test cases.
34 my @testCaseHashRefs = (
35 {
36 # New test
37 diffName => "SVN: simple",
38 inputText => <<'END',
39 Index: Makefile
40 ===================================================================
41 --- Makefile (revision 53052)
42 +++ Makefile (working copy)
43 @@ -1,3 +1,4 @@
44 +
45 MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKitTools
46
47 all:
48 END
49 expectedReturn => [
50 [{
51 svnConvertedText => <<'END', # Same as input text
52 Index: Makefile
53 ===================================================================
54 --- Makefile (revision 53052)
55 +++ Makefile (working copy)
56 @@ -1,3 +1,4 @@
57 +
58 MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKitTools
59
60 all:
61 END
62 indexPath => "Makefile",
63 isSvn => 1,
64 numTextChunks => 1,
65 sourceRevision => "53052",
66 }],
67 undef],
68 expectedNextLine => undef,
69 },
70 {
71 # New test
72 diffName => "SVN: binary file (isBinary true)",
73 inputText => <<'END',
74 Index: test_file.swf
75 ===================================================================
76 Cannot display: file marked as a binary type.
77 svn:mime-type = application/octet-stream
78
79 Property changes on: test_file.swf
80 ___________________________________________________________________
81 Name: svn:mime-type
82 + application/octet-stream
83
84
85 Q1dTBx0AAAB42itg4GlgYJjGwMDDyODMxMDw34GBgQEAJPQDJA==
86 END
87 expectedReturn => [
88 [{
89 svnConvertedText => <<'END', # Same as input text
90 Index: test_file.swf
91 ===================================================================
92 Cannot display: file marked as a binary type.
93 svn:mime-type = application/octet-stream
94
95
96
97 Q1dTBx0AAAB42itg4GlgYJjGwMDDyODMxMDw34GBgQEAJPQDJA==
98 END
99 indexPath => "test_file.swf",
100 isBinary => 1,
101 isSvn => 1,
102 }],
103 undef],
104 expectedNextLine => undef,
105 },
106 {
107 # New test
108 diffName => "SVN: binary file (isBinary true) using Windows line endings",
109 inputText => toWindowsLineEndings(<<'END',
110 Index: test_file.swf
111 ===================================================================
112 Cannot display: file marked as a binary type.
113 svn:mime-type = application/octet-stream
114
115 Property changes on: test_file.swf
116 ___________________________________________________________________
117 Name: svn:mime-type
118 + application/octet-stream
119
120
121 Q1dTBx0AAAB42itg4GlgYJjGwMDDyODMxMDw34GBgQEAJPQDJA==
122 END
123 ),
124 expectedReturn => [
125 [{
126 svnConvertedText => toWindowsLineEndings(<<'END', # Same as input text
127 Index: test_file.swf
128 ===================================================================
129 Cannot display: file marked as a binary type.
130 svn:mime-type = application/octet-stream
131
132
133
134 Q1dTBx0AAAB42itg4GlgYJjGwMDDyODMxMDw34GBgQEAJPQDJA==
135 END
136 ),
137 indexPath => "test_file.swf",
138 isBinary => 1,
139 isSvn => 1,
140 }],
141 undef],
142 expectedNextLine => undef,
143 },
144 {
145 # New test
146 diffName => "SVN: leading junk",
147 inputText => <<'END',
148
149 LEADING JUNK
150
151 Index: Makefile
152 ===================================================================
153 --- Makefile (revision 53052)
154 +++ Makefile (working copy)
155 @@ -1,3 +1,4 @@
156 +
157 MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKitTools
158
159 all:
160 END
161 expectedReturn => [
162 [{
163 svnConvertedText => <<'END', # Same as input text
164
165 LEADING JUNK
166
167 Index: Makefile
168 ===================================================================
169 --- Makefile (revision 53052)
170 +++ Makefile (working copy)
171 @@ -1,3 +1,4 @@
172 +
173 MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKitTools
174
175 all:
176 END
177 indexPath => "Makefile",
178 isSvn => 1,
179 numTextChunks => 1,
180 sourceRevision => "53052",
181 }],
182 undef],
183 expectedNextLine => undef,
184 },
185 {
186 # New test
187 diffName => "SVN: copied file",
188 inputText => <<'END',
189 Index: Makefile_new
190 ===================================================================
191 --- Makefile_new (revision 53131) (from Makefile:53131)
192 +++ Makefile_new (working copy)
193 @@ -0,0 +1,1 @@
194 +MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKitTools
195 END
196 expectedReturn => [
197 [{
198 copiedFromPath => "Makefile",
199 indexPath => "Makefile_new",
200 sourceRevision => "53131",
201 }],
202 undef],
203 expectedNextLine => undef,
204 },
205 {
206 # New test
207 diffName => "SVN: two diffs",
208 inputText => <<'END',
209 Index: Makefile
210 ===================================================================
211 --- Makefile (revision 53131)
212 +++ Makefile (working copy)
213 @@ -1,1 +0,0 @@
214 -MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKitTools
215 Index: Makefile_new
216 ===================================================================
217 --- Makefile_new (revision 53131) (from Makefile:53131)
218 END
219 expectedReturn => [
220 [{
221 svnConvertedText => <<'END',
222 Index: Makefile
223 ===================================================================
224 --- Makefile (revision 53131)
225 +++ Makefile (working copy)
226 @@ -1,1 +0,0 @@
227 -MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKitTools
228 END
229 indexPath => "Makefile",
230 isSvn => 1,
231 numTextChunks => 1,
232 sourceRevision => "53131",
233 }],
234 "Index: Makefile_new\n"],
235 expectedNextLine => "======================================================= ============\n",
236 },
237 {
238 # New test
239 diffName => "SVN: SVN diff followed by Git diff", # Should not recognize Git start
240 inputText => <<'END',
241 Index: Makefile
242 ===================================================================
243 --- Makefile (revision 53131)
244 +++ Makefile (working copy)
245 @@ -1,1 +0,0 @@
246 -MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKitTools
247 diff --git a/Makefile b/Makefile
248 index f5d5e74..3b6aa92 100644
249 --- a/Makefile
250 +++ b/Makefile
251 @@ -1,1 1,1 @@ public:
252 END
253 expectedReturn => [
254 [{
255 svnConvertedText => <<'END', # Same as input text
256 Index: Makefile
257 ===================================================================
258 --- Makefile (revision 53131)
259 +++ Makefile (working copy)
260 @@ -1,1 +0,0 @@
261 -MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKitTools
262 diff --git a/Makefile b/Makefile
263 index f5d5e74..3b6aa92 100644
264 --- a/Makefile
265 +++ b/Makefile
266 @@ -1,1 1,1 @@ public:
267 END
268 indexPath => "Makefile",
269 isSvn => 1,
270 numTextChunks => 1,
271 sourceRevision => "53131",
272 }],
273 undef],
274 expectedNextLine => undef,
275 },
276 ####
277 # Property Changes: Simple
278 ##
279 {
280 # New test
281 diffName => "SVN: file change diff with property change diff",
282 inputText => <<'END',
283 Index: Makefile
284 ===================================================================
285 --- Makefile (revision 60021)
286 +++ Makefile (working copy)
287 @@ -1,3 +1,4 @@
288 +
289 MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKit2 WebKitTools
290
291 all:
292
293 Property changes on: Makefile
294 ___________________________________________________________________
295 Name: svn:executable
296 + *
297 END
298 expectedReturn => [
299 [{
300 svnConvertedText => <<'END', # Same as input text
301 Index: Makefile
302 ===================================================================
303 --- Makefile (revision 60021)
304 +++ Makefile (working copy)
305 @@ -1,3 +1,4 @@
306 +
307 MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKit2 WebKitTools
308
309 all:
310
311 END
312 executableBitDelta => 1,
313 indexPath => "Makefile",
314 isSvn => 1,
315 numTextChunks => 1,
316 sourceRevision => "60021",
317 }],
318 undef],
319 expectedNextLine => undef,
320 },
321 {
322 # New test
323 diffName => "SVN: file change diff, followed by property change diff on diff erent file",
324 inputText => <<'END',
325 Index: Makefile
326 ===================================================================
327 --- Makefile (revision 60021)
328 +++ Makefile (working copy)
329 @@ -1,3 +1,4 @@
330 +
331 MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKit2 WebKitTools
332
333 all:
334
335 Property changes on: Makefile.shared
336 ___________________________________________________________________
337 Name: svn:executable
338 + *
339 END
340 expectedReturn => [
341 [{
342 svnConvertedText => <<'END', # Same as input text
343 Index: Makefile
344 ===================================================================
345 --- Makefile (revision 60021)
346 +++ Makefile (working copy)
347 @@ -1,3 +1,4 @@
348 +
349 MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKit2 WebKitTools
350
351 all:
352
353 END
354 indexPath => "Makefile",
355 isSvn => 1,
356 numTextChunks => 1,
357 sourceRevision => "60021",
358 }],
359 "Property changes on: Makefile.shared\n"],
360 expectedNextLine => "_______________________________________________________ ____________\n",
361 },
362 {
363 # New test
364 diffName => "SVN: property diff, followed by file change diff",
365 inputText => <<'END',
366 Property changes on: Makefile
367 ___________________________________________________________________
368 Deleted: svn:executable
369 - *
370
371 Index: Makefile.shared
372 ===================================================================
373 --- Makefile.shared (revision 60021)
374 +++ Makefile.shared (working copy)
375 @@ -1,3 +1,4 @@
376 +
377 SCRIPTS_PATH ?= ../WebKitTools/Scripts
378 XCODE_OPTIONS = `perl -I$(SCRIPTS_PATH) -Mwebkitdirs -e 'print XcodeOptionString ()'` $(ARGS)
379 END
380 expectedReturn => [
381 [{
382 executableBitDelta => -1,
383 indexPath => "Makefile",
384 isSvn => 1,
385 }],
386 "Index: Makefile.shared\n"],
387 expectedNextLine => "======================================================= ============\n",
388 },
389 {
390 # New test
391 diffName => "SVN: property diff, followed by file change diff using Windows line endings",
392 inputText => toWindowsLineEndings(<<'END',
393 Property changes on: Makefile
394 ___________________________________________________________________
395 Deleted: svn:executable
396 - *
397
398 Index: Makefile.shared
399 ===================================================================
400 --- Makefile.shared (revision 60021)
401 +++ Makefile.shared (working copy)
402 @@ -1,3 +1,4 @@
403 +
404 SCRIPTS_PATH ?= ../WebKitTools/Scripts
405 XCODE_OPTIONS = `perl -I$(SCRIPTS_PATH) -Mwebkitdirs -e 'print XcodeOptionString ()'` $(ARGS)
406 END
407 ),
408 expectedReturn => [
409 [{
410 executableBitDelta => -1,
411 indexPath => "Makefile",
412 isSvn => 1,
413 }],
414 "Index: Makefile.shared\r\n"],
415 expectedNextLine => "======================================================= ============\r\n",
416 },
417 {
418 # New test
419 diffName => "SVN: copied file with property change",
420 inputText => <<'END',
421 Index: NMakefile
422 ===================================================================
423 --- NMakefile (revision 60021) (from Makefile:60021)
424 +++ NMakefile (working copy)
425 @@ -0,0 +1,1 @@
426 +MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKit2 WebKitTools
427
428 Property changes on: NMakefile
429 ___________________________________________________________________
430 Added: svn:executable
431 + *
432 END
433 expectedReturn => [
434 [{
435 copiedFromPath => "Makefile",
436 executableBitDelta => 1,
437 indexPath => "NMakefile",
438 sourceRevision => "60021",
439 }],
440 undef],
441 expectedNextLine => undef,
442 },
443 {
444 # New test
445 diffName => "SVN: two consecutive property diffs",
446 inputText => <<'END',
447 Property changes on: Makefile
448 ___________________________________________________________________
449 Added: svn:executable
450 + *
451
452
453 Property changes on: Makefile.shared
454 ___________________________________________________________________
455 Added: svn:executable
456 + *
457 END
458 expectedReturn => [
459 [{
460 executableBitDelta => 1,
461 indexPath => "Makefile",
462 isSvn => 1,
463 }],
464 "Property changes on: Makefile.shared\n"],
465 expectedNextLine => "_______________________________________________________ ____________\n",
466 },
467 {
468 # New test
469 diffName => "SVN: two consecutive property diffs using Windows line endings" ,
470 inputText => toWindowsLineEndings(<<'END',
471 Property changes on: Makefile
472 ___________________________________________________________________
473 Added: svn:executable
474 + *
475
476
477 Property changes on: Makefile.shared
478 ___________________________________________________________________
479 Added: svn:executable
480 + *
481 END
482 ),
483 expectedReturn => [
484 [{
485 executableBitDelta => 1,
486 indexPath => "Makefile",
487 isSvn => 1,
488 }],
489 "Property changes on: Makefile.shared\r\n"],
490 expectedNextLine => "_______________________________________________________ ____________\r\n",
491 },
492 ####
493 # Property Changes: Binary files
494 ##
495 {
496 # New test
497 diffName => "SVN: binary file with executable bit change",
498 inputText => <<'END',
499 Index: test_file.swf
500 ===================================================================
501 Cannot display: file marked as a binary type.
502 svn:mime-type = application/octet-stream
503
504 Property changes on: test_file.swf
505 ___________________________________________________________________
506 Name: svn:mime-type
507 + application/octet-stream
508 Name: svn:executable
509 + *
510
511
512 Q1dTBx0AAAB42itg4GlgYJjGwMDDyODMxMDw34GBgQEAJPQDJA==
513 END
514 expectedReturn => [
515 [{
516 svnConvertedText => <<'END', # Same as input text
517 Index: test_file.swf
518 ===================================================================
519 Cannot display: file marked as a binary type.
520 svn:mime-type = application/octet-stream
521
522
523
524 Q1dTBx0AAAB42itg4GlgYJjGwMDDyODMxMDw34GBgQEAJPQDJA==
525 END
526 executableBitDelta => 1,
527 indexPath => "test_file.swf",
528 isBinary => 1,
529 isSvn => 1,
530 }],
531 undef],
532 expectedNextLine => undef,
533 },
534 {
535 # New test
536 diffName => "SVN: binary file with executable bit change usng Windows line e ndings",
537 inputText => toWindowsLineEndings(<<'END',
538 Index: test_file.swf
539 ===================================================================
540 Cannot display: file marked as a binary type.
541 svn:mime-type = application/octet-stream
542
543 Property changes on: test_file.swf
544 ___________________________________________________________________
545 Name: svn:mime-type
546 + application/octet-stream
547 Name: svn:executable
548 + *
549
550
551 Q1dTBx0AAAB42itg4GlgYJjGwMDDyODMxMDw34GBgQEAJPQDJA==
552 END
553 ),
554 expectedReturn => [
555 [{
556 svnConvertedText => toWindowsLineEndings(<<'END', # Same as input text
557 Index: test_file.swf
558 ===================================================================
559 Cannot display: file marked as a binary type.
560 svn:mime-type = application/octet-stream
561
562
563
564 Q1dTBx0AAAB42itg4GlgYJjGwMDDyODMxMDw34GBgQEAJPQDJA==
565 END
566 ),
567 executableBitDelta => 1,
568 indexPath => "test_file.swf",
569 isBinary => 1,
570 isSvn => 1,
571 }],
572 undef],
573 expectedNextLine => undef,
574 },
575 {
576 # New test
577 diffName => "SVN: binary file followed by property change on different file" ,
578 inputText => <<'END',
579 Index: test_file.swf
580 ===================================================================
581 Cannot display: file marked as a binary type.
582 svn:mime-type = application/octet-stream
583
584 Property changes on: test_file.swf
585 ___________________________________________________________________
586 Name: svn:mime-type
587 + application/octet-stream
588
589
590 Q1dTBx0AAAB42itg4GlgYJjGwMDDyODMxMDw34GBgQEAJPQDJA==
591
592 Property changes on: Makefile
593 ___________________________________________________________________
594 Added: svn:executable
595 + *
596 END
597 expectedReturn => [
598 [{
599 svnConvertedText => <<'END', # Same as input text
600 Index: test_file.swf
601 ===================================================================
602 Cannot display: file marked as a binary type.
603 svn:mime-type = application/octet-stream
604
605
606
607 Q1dTBx0AAAB42itg4GlgYJjGwMDDyODMxMDw34GBgQEAJPQDJA==
608
609 END
610 indexPath => "test_file.swf",
611 isBinary => 1,
612 isSvn => 1,
613 }],
614 "Property changes on: Makefile\n"],
615 expectedNextLine => "_______________________________________________________ ____________\n",
616 },
617 {
618 # New test
619 diffName => "SVN: binary file followed by property change on different file using Windows line endings",
620 inputText => toWindowsLineEndings(<<'END',
621 Index: test_file.swf
622 ===================================================================
623 Cannot display: file marked as a binary type.
624 svn:mime-type = application/octet-stream
625
626 Property changes on: test_file.swf
627 ___________________________________________________________________
628 Name: svn:mime-type
629 + application/octet-stream
630
631
632 Q1dTBx0AAAB42itg4GlgYJjGwMDDyODMxMDw34GBgQEAJPQDJA==
633
634 Property changes on: Makefile
635 ___________________________________________________________________
636 Added: svn:executable
637 + *
638 END
639 ),
640 expectedReturn => [
641 [{
642 svnConvertedText => toWindowsLineEndings(<<'END', # Same as input text
643 Index: test_file.swf
644 ===================================================================
645 Cannot display: file marked as a binary type.
646 svn:mime-type = application/octet-stream
647
648
649
650 Q1dTBx0AAAB42itg4GlgYJjGwMDDyODMxMDw34GBgQEAJPQDJA==
651
652 END
653 ),
654 indexPath => "test_file.swf",
655 isBinary => 1,
656 isSvn => 1,
657 }],
658 "Property changes on: Makefile\r\n"],
659 expectedNextLine => "_______________________________________________________ ____________\r\n",
660 },
661 {
662 # New test
663 diffName => "SVN: binary file followed by file change on different file",
664 inputText => <<'END',
665 Index: test_file.swf
666 ===================================================================
667 Cannot display: file marked as a binary type.
668 svn:mime-type = application/octet-stream
669
670 Property changes on: test_file.swf
671 ___________________________________________________________________
672 Name: svn:mime-type
673 + application/octet-stream
674
675
676 Q1dTBx0AAAB42itg4GlgYJjGwMDDyODMxMDw34GBgQEAJPQDJA==
677
678 Index: Makefile
679 ===================================================================
680 --- Makefile (revision 60021)
681 +++ Makefile (working copy)
682 @@ -1,3 +1,4 @@
683 +
684 MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKit2 WebKitTools
685
686 all:
687 END
688 expectedReturn => [
689 [{
690 svnConvertedText => <<'END', # Same as input text
691 Index: test_file.swf
692 ===================================================================
693 Cannot display: file marked as a binary type.
694 svn:mime-type = application/octet-stream
695
696
697
698 Q1dTBx0AAAB42itg4GlgYJjGwMDDyODMxMDw34GBgQEAJPQDJA==
699
700 END
701 indexPath => "test_file.swf",
702 isBinary => 1,
703 isSvn => 1,
704 }],
705 "Index: Makefile\n"],
706 expectedNextLine => "======================================================= ============\n",
707 },
708 {
709 # New test
710 diffName => "SVN: binary file followed by file change on different file usin g Windows line endings",
711 inputText => toWindowsLineEndings(<<'END',
712 Index: test_file.swf
713 ===================================================================
714 Cannot display: file marked as a binary type.
715 svn:mime-type = application/octet-stream
716
717 Property changes on: test_file.swf
718 ___________________________________________________________________
719 Name: svn:mime-type
720 + application/octet-stream
721
722
723 Q1dTBx0AAAB42itg4GlgYJjGwMDDyODMxMDw34GBgQEAJPQDJA==
724
725 Index: Makefile
726 ===================================================================
727 --- Makefile (revision 60021)
728 +++ Makefile (working copy)
729 @@ -1,3 +1,4 @@
730 +
731 MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKit2 WebKitTools
732
733 all:
734 END
735 ),
736 expectedReturn => [
737 [{
738 svnConvertedText => toWindowsLineEndings(<<'END', # Same as input text
739 Index: test_file.swf
740 ===================================================================
741 Cannot display: file marked as a binary type.
742 svn:mime-type = application/octet-stream
743
744
745
746 Q1dTBx0AAAB42itg4GlgYJjGwMDDyODMxMDw34GBgQEAJPQDJA==
747
748 END
749 ),
750 indexPath => "test_file.swf",
751 isBinary => 1,
752 isSvn => 1,
753 }],
754 "Index: Makefile\r\n"],
755 expectedNextLine => "======================================================= ============\r\n",
756 },
757 ####
758 # Property Changes: File change with property change
759 ##
760 {
761 # New test
762 diffName => "SVN: file change diff with property change, followed by propert y change diff",
763 inputText => <<'END',
764 Index: Makefile
765 ===================================================================
766 --- Makefile (revision 60021)
767 +++ Makefile (working copy)
768 @@ -1,3 +1,4 @@
769 +
770 MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKit2 WebKitTools
771
772 all:
773
774 Property changes on: Makefile
775 ___________________________________________________________________
776 Added: svn:executable
777 + *
778
779
780 Property changes on: Makefile.shared
781 ___________________________________________________________________
782 Deleted: svn:executable
783 - *
784 END
785 expectedReturn => [
786 [{
787 svnConvertedText => <<'END', # Same as input text
788 Index: Makefile
789 ===================================================================
790 --- Makefile (revision 60021)
791 +++ Makefile (working copy)
792 @@ -1,3 +1,4 @@
793 +
794 MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKit2 WebKitTools
795
796 all:
797
798
799
800 END
801 executableBitDelta => 1,
802 indexPath => "Makefile",
803 isSvn => 1,
804 numTextChunks => 1,
805 sourceRevision => "60021",
806 }],
807 "Property changes on: Makefile.shared\n"],
808 expectedNextLine => "_______________________________________________________ ____________\n",
809 },
810 {
811 # New test
812 diffName => "SVN: file change diff with property change, followed by propert y change diff using Windows line endings",
813 inputText => toWindowsLineEndings(<<'END',
814 Index: Makefile
815 ===================================================================
816 --- Makefile (revision 60021)
817 +++ Makefile (working copy)
818 @@ -1,3 +1,4 @@
819 +
820 MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKit2 WebKitTools
821
822 all:
823
824 Property changes on: Makefile
825 ___________________________________________________________________
826 Added: svn:executable
827 + *
828
829
830 Property changes on: Makefile.shared
831 ___________________________________________________________________
832 Deleted: svn:executable
833 - *
834 END
835 ),
836 expectedReturn => [
837 [{
838 svnConvertedText => toWindowsLineEndings(<<'END', # Same as input text
839 Index: Makefile
840 ===================================================================
841 --- Makefile (revision 60021)
842 +++ Makefile (working copy)
843 @@ -1,3 +1,4 @@
844 +
845 MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKit2 WebKitTools
846
847 all:
848
849
850
851 END
852 ),
853 executableBitDelta => 1,
854 indexPath => "Makefile",
855 isSvn => 1,
856 numTextChunks => 1,
857 sourceRevision => "60021",
858 }],
859 "Property changes on: Makefile.shared\r\n"],
860 expectedNextLine => "_______________________________________________________ ____________\r\n",
861 },
862 {
863 # New test
864 diffName => "SVN: file change diff with property change, followed by file ch ange diff",
865 inputText => <<'END',
866 Index: Makefile
867 ===================================================================
868 --- Makefile (revision 60021)
869 +++ Makefile (working copy)
870 @@ -1,3 +1,4 @@
871 +
872 MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKit2 WebKitTools
873
874 all:
875
876 Property changes on: Makefile
877 ___________________________________________________________________
878 Name: svn:executable
879 - *
880
881 Index: Makefile.shared
882 ===================================================================
883 --- Makefile.shared (revision 60021)
884 +++ Makefile.shared (working copy)
885 @@ -1,3 +1,4 @@
886 +
887 SCRIPTS_PATH ?= ../WebKitTools/Scripts
888 XCODE_OPTIONS = `perl -I$(SCRIPTS_PATH) -Mwebkitdirs -e 'print XcodeOptionString ()'` $(ARGS)
889 END
890 expectedReturn => [
891 [{
892 svnConvertedText => <<'END', # Same as input text
893 Index: Makefile
894 ===================================================================
895 --- Makefile (revision 60021)
896 +++ Makefile (working copy)
897 @@ -1,3 +1,4 @@
898 +
899 MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKit2 WebKitTools
900
901 all:
902
903
904 END
905 executableBitDelta => -1,
906 indexPath => "Makefile",
907 isSvn => 1,
908 numTextChunks => 1,
909 sourceRevision => "60021",
910 }],
911 "Index: Makefile.shared\n"],
912 expectedNextLine => "======================================================= ============\n",
913 },
914 {
915 # New test
916 diffName => "SVN: file change diff with property change, followed by file ch ange diff using Windows line endings",
917 inputText => toWindowsLineEndings(<<'END',
918 Index: Makefile
919 ===================================================================
920 --- Makefile (revision 60021)
921 +++ Makefile (working copy)
922 @@ -1,3 +1,4 @@
923 +
924 MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKit2 WebKitTools
925
926 all:
927
928 Property changes on: Makefile
929 ___________________________________________________________________
930 Name: svn:executable
931 - *
932
933 Index: Makefile.shared
934 ===================================================================
935 --- Makefile.shared (revision 60021)
936 +++ Makefile.shared (working copy)
937 @@ -1,3 +1,4 @@
938 +
939 SCRIPTS_PATH ?= ../WebKitTools/Scripts
940 XCODE_OPTIONS = `perl -I$(SCRIPTS_PATH) -Mwebkitdirs -e 'print XcodeOptionString ()'` $(ARGS)
941 END
942 ),
943 expectedReturn => [
944 [{
945 svnConvertedText => toWindowsLineEndings(<<'END', # Same as input text
946 Index: Makefile
947 ===================================================================
948 --- Makefile (revision 60021)
949 +++ Makefile (working copy)
950 @@ -1,3 +1,4 @@
951 +
952 MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKit2 WebKitTools
953
954 all:
955
956
957 END
958 ),
959 executableBitDelta => -1,
960 indexPath => "Makefile",
961 isSvn => 1,
962 numTextChunks => 1,
963 sourceRevision => "60021",
964 }],
965 "Index: Makefile.shared\r\n"],
966 expectedNextLine => "======================================================= ============\r\n",
967 },
968 ####
969 # Git test cases
970 ##
971 {
972 # New test
973 diffName => "Git: simple",
974 inputText => <<'END',
975 diff --git a/Makefile b/Makefile
976 index f5d5e74..3b6aa92 100644
977 --- a/Makefile
978 +++ b/Makefile
979 @@ -1,1 +1,1 @@ public:
980 END
981 expectedReturn => [
982 [{
983 svnConvertedText => <<'END',
984 Index: Makefile
985 index f5d5e74..3b6aa92 100644
986 --- Makefile
987 +++ Makefile
988 @@ -1,1 +1,1 @@ public:
989 END
990 indexPath => "Makefile",
991 isGit => 1,
992 numTextChunks => 1,
993 }],
994 undef],
995 expectedNextLine => undef,
996 },
997 {
998 # New test
999 diffName => "Git: Append new line to the end of an existing file",
1000 inputText => <<'END',
1001 diff --git a/foo b/foo
1002 index 863339f..db418b2 100644
1003 --- a/foo
1004 +++ b/foo
1005 @@ -1 +1,2 @@
1006 Passed
1007 +
1008 END
1009 expectedReturn => [
1010 [{
1011 svnConvertedText => <<'END',
1012 Index: foo
1013 index 863339f..db418b2 100644
1014 --- foo
1015 +++ foo
1016 @@ -1 +1,2 @@
1017 Passed
1018 +
1019 END
1020 indexPath => "foo",
1021 isGit => 1,
1022 numTextChunks => 1,
1023 }],
1024 undef],
1025 expectedNextLine => undef,
1026 },
1027 { # New test
1028 diffName => "Git: new file",
1029 inputText => <<'END',
1030 diff --git a/foo.h b/foo.h
1031 new file mode 100644
1032 index 0000000..3c9f114
1033 --- /dev/null
1034 +++ b/foo.h
1035 @@ -0,0 +1,34 @@
1036 +<html>
1037 diff --git a/bar b/bar
1038 index d45dd40..3494526 100644
1039 END
1040 expectedReturn => [
1041 [{
1042 svnConvertedText => <<'END',
1043 Index: foo.h
1044 new file mode 100644
1045 index 0000000..3c9f114
1046 --- foo.h
1047 +++ foo.h
1048 @@ -0,0 +1,34 @@
1049 +<html>
1050 END
1051 indexPath => "foo.h",
1052 isGit => 1,
1053 isNew => 1,
1054 numTextChunks => 1,
1055 }],
1056 "diff --git a/bar b/bar\n"],
1057 expectedNextLine => "index d45dd40..3494526 100644\n",
1058 },
1059 { # New test
1060 diffName => "Git: file deletion",
1061 inputText => <<'END',
1062 diff --git a/foo b/foo
1063 deleted file mode 100644
1064 index 1e50d1d..0000000
1065 --- a/foo
1066 +++ /dev/null
1067 @@ -1,1 +0,0 @@
1068 -line1
1069 diff --git a/bar b/bar
1070 index d45dd40..3494526 100644
1071 END
1072 expectedReturn => [
1073 [{
1074 svnConvertedText => <<'END',
1075 Index: foo
1076 deleted file mode 100644
1077 index 1e50d1d..0000000
1078 --- foo
1079 +++ foo
1080 @@ -1,1 +0,0 @@
1081 -line1
1082 END
1083 indexPath => "foo",
1084 isDeletion => 1,
1085 isGit => 1,
1086 numTextChunks => 1,
1087 }],
1088 "diff --git a/bar b/bar\n"],
1089 expectedNextLine => "index d45dd40..3494526 100644\n",
1090 },
1091 {
1092 # New test
1093 diffName => "Git: Git diff followed by SVN diff", # Should not recognize SVN start
1094 inputText => <<'END',
1095 diff --git a/Makefile b/Makefile
1096 index f5d5e74..3b6aa92 100644
1097 --- a/Makefile
1098 +++ b/Makefile
1099 @@ -1,1 +1,1 @@ public:
1100 Index: Makefile_new
1101 ===================================================================
1102 --- Makefile_new (revision 53131) (from Makefile:53131)
1103 END
1104 expectedReturn => [
1105 [{
1106 svnConvertedText => <<'END',
1107 Index: Makefile
1108 index f5d5e74..3b6aa92 100644
1109 --- Makefile
1110 +++ Makefile
1111 @@ -1,1 +1,1 @@ public:
1112 Index: Makefile_new
1113 ===================================================================
1114 --- Makefile_new (revision 53131) (from Makefile:53131)
1115 END
1116 indexPath => "Makefile",
1117 isGit => 1,
1118 numTextChunks => 1,
1119 }],
1120 undef],
1121 expectedNextLine => undef,
1122 },
1123 {
1124 # New test
1125 diffName => "Git: file that only has an executable bit change",
1126 inputText => <<'END',
1127 diff --git a/foo b/foo
1128 old mode 100644
1129 new mode 100755
1130 END
1131 expectedReturn => [
1132 [{
1133 svnConvertedText => <<'END',
1134 Index: foo
1135 old mode 100644
1136 new mode 100755
1137 END
1138 executableBitDelta => 1,
1139 indexPath => "foo",
1140 isGit => 1,
1141 numTextChunks => 0,
1142 }],
1143 undef],
1144 expectedNextLine => undef,
1145 },
1146 ####
1147 # Git test cases: file moves (multiple return values)
1148 ##
1149 {
1150 diffName => "Git: rename (with similarity index 100%)",
1151 inputText => <<'END',
1152 diff --git a/foo b/foo_new
1153 similarity index 100%
1154 rename from foo
1155 rename to foo_new
1156 diff --git a/bar b/bar
1157 index d45dd40..3494526 100644
1158 END
1159 expectedReturn => [
1160 [{
1161 indexPath => "foo",
1162 isDeletion => 1,
1163 },
1164 {
1165 copiedFromPath => "foo",
1166 indexPath => "foo_new",
1167 }],
1168 "diff --git a/bar b/bar\n"],
1169 expectedNextLine => "index d45dd40..3494526 100644\n",
1170 },
1171 {
1172 diffName => "rename (with similarity index < 100%)",
1173 inputText => <<'END',
1174 diff --git a/foo b/foo_new
1175 similarity index 99%
1176 rename from foo
1177 rename to foo_new
1178 index 1e50d1d..1459d21 100644
1179 --- a/foo
1180 +++ b/foo_new
1181 @@ -15,3 +15,4 @@ release r deployment dep deploy:
1182 line1
1183 line2
1184 line3
1185 +line4
1186 diff --git a/bar b/bar
1187 index d45dd40..3494526 100644
1188 END
1189 expectedReturn => [
1190 [{
1191 indexPath => "foo",
1192 isDeletion => 1,
1193 },
1194 {
1195 copiedFromPath => "foo",
1196 indexPath => "foo_new",
1197 },
1198 {
1199 indexPath => "foo_new",
1200 isGit => 1,
1201 numTextChunks => 1,
1202 svnConvertedText => <<'END',
1203 Index: foo_new
1204 similarity index 99%
1205 rename from foo
1206 rename to foo_new
1207 index 1e50d1d..1459d21 100644
1208 --- foo_new
1209 +++ foo_new
1210 @@ -15,3 +15,4 @@ release r deployment dep deploy:
1211 line1
1212 line2
1213 line3
1214 +line4
1215 END
1216 }],
1217 "diff --git a/bar b/bar\n"],
1218 expectedNextLine => "index d45dd40..3494526 100644\n",
1219 },
1220 {
1221 diffName => "rename (with executable bit change)",
1222 inputText => <<'END',
1223 diff --git a/foo b/foo_new
1224 old mode 100644
1225 new mode 100755
1226 similarity index 100%
1227 rename from foo
1228 rename to foo_new
1229 diff --git a/bar b/bar
1230 index d45dd40..3494526 100644
1231 END
1232 expectedReturn => [
1233 [{
1234 indexPath => "foo",
1235 isDeletion => 1,
1236 },
1237 {
1238 copiedFromPath => "foo",
1239 indexPath => "foo_new",
1240 },
1241 {
1242 executableBitDelta => 1,
1243 indexPath => "foo_new",
1244 isGit => 1,
1245 numTextChunks => 0,
1246 svnConvertedText => <<'END',
1247 Index: foo_new
1248 old mode 100644
1249 new mode 100755
1250 similarity index 100%
1251 rename from foo
1252 rename to foo_new
1253 END
1254 }],
1255 "diff --git a/bar b/bar\n"],
1256 expectedNextLine => "index d45dd40..3494526 100644\n",
1257 },
1258 );
1259
1260 my $testCasesCount = @testCaseHashRefs;
1261 plan(tests => 2 * $testCasesCount); # Total number of assertions.
1262
1263 foreach my $testCase (@testCaseHashRefs) {
1264 my $testNameStart = "parseDiff(): $testCase->{diffName}: comparing";
1265
1266 my $fileHandle;
1267 open($fileHandle, "<", \$testCase->{inputText});
1268 my $line = <$fileHandle>;
1269
1270 my @got = VCSUtils::parseDiff($fileHandle, $line, {"shouldNotUseIndexPathEOL " => 1});
1271 my $expectedReturn = $testCase->{expectedReturn};
1272
1273 is_deeply(\@got, $expectedReturn, "$testNameStart return value.");
1274
1275 my $gotNextLine = <$fileHandle>;
1276 is($gotNextLine, $testCase->{expectedNextLine}, "$testNameStart next read l ine.");
1277 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698