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

Side by Side Diff: Tools/Scripts/webkitperl/VCSUtils_unittest/runPatchCommand.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
2 #
3 # Copyright (C) 2009, 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 are
7 # met:
8 #
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # * Redistributions in binary form must reproduce the above
12 # copyright notice, this list of conditions and the following disclaimer
13 # in the documentation and/or other materials provided with the
14 # distribution.
15 # * Neither the name of Google Inc. nor the names of its
16 # contributors may be used to endorse or promote products derived from
17 # this software without specific prior written permission.
18 #
19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31 # Unit tests of VCSUtils::runPatchCommand().
32
33 use Test::Simple tests => 4;
34 use VCSUtils;
35
36 # New test
37 $title = "runPatchCommand: Unsuccessful patch, forcing.";
38
39 # Since $patch has no "Index:" path, passing this to runPatchCommand
40 # should not affect any files.
41 my $patch = <<'END';
42 Garbage patch contents
43 END
44
45 # We call via callSilently() to avoid output like the following to STDERR:
46 # patch: **** Only garbage was found in the patch input.
47 $argsHashRef = {ensureForce => 1};
48 $exitStatus = callSilently(\&runPatchCommand, $patch, ".", "file_to_patch.txt", $argsHashRef);
49
50 ok($exitStatus != 0, $title);
51
52 # New test
53 $title = "runPatchCommand: New file, --dry-run.";
54
55 # This file should not exist after the tests, but we take care with the
56 # file name and contents just in case.
57 my $fileToPatch = "temp_OK_TO_ERASE__README_FOR_MORE.txt";
58 $patch = <<END;
59 Index: $fileToPatch
60 ===================================================================
61 --- $fileToPatch (revision 0)
62 +++ $fileToPatch (revision 0)
63 @@ -0,0 +1,5 @@
64 +This is a test file for WebKitTools/Scripts/VCSUtils_unittest.pl.
65 +This file should not have gotten created on your system.
66 +If it did, some unit tests don't seem to be working quite right:
67 +It would be great if you could file a bug report. Thanks!
68 +---------------------------------------------------------------------
69 END
70
71 # --dry-run prevents creating any files.
72 # --silent suppresses the success message to STDOUT.
73 $argsHashRef = {options => ["--dry-run", "--silent"]};
74 $exitStatus = runPatchCommand($patch, ".", $fileToPatch, $argsHashRef);
75
76 ok($exitStatus == 0, $title);
77
78 # New test
79 $title = "runPatchCommand: New file: \"$fileToPatch\".";
80
81 $argsHashRef = {options => ["--silent"]};
82 $exitStatus = runPatchCommand($patch, ".", $fileToPatch, $argsHashRef);
83
84 ok($exitStatus == 0, $title);
85
86 # New test
87 $title = "runPatchCommand: Reverse new file (clean up previous).";
88
89 $argsHashRef = {shouldReverse => 1,
90 options => ["--silent", "--remove-empty-files"]}; # To clean up.
91 $exitStatus = runPatchCommand($patch, ".", $fileToPatch, $argsHashRef);
92 ok($exitStatus == 0, $title);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698