[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

ddkilzer at apple.com ddkilzer at apple.com
Thu Apr 8 00:53:26 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 34d546755b3bdd51d8098346ad403c73756f9d44
Author: ddkilzer at apple.com <ddkilzer at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Jan 4 14:59:29 2010 +0000

    Divided the Perl unit tests into separate files and put
    them in a separate directory, and renamed test-webkit-perl
    to test-webkitperl.
    
    Patch by Chris Jerdonek <chris.jerdonek at gmail.com> on 2010-01-04
    Reviewed by David Kilzer.
    
    https://bugs.webkit.org/show_bug.cgi?id=33124
    
    * Scripts/VCSUtils.pm:
      - Renamed generateRunPatchCommand() to generatePatchCommand().
    
    * Scripts/VCSUtils_unittest.pl: Removed.
      - Divided into three files in Scripts/webkitperl/VCSUtils_unittest.
    
    * Scripts/test-webkit-perl: Removed.
      - Renamed to test-webkitperl.
    
    * Scripts/test-webkit-scripts:
      - Updated paths to test-webkitpy and test-webkitperl.
    
    * Scripts/test-webkitperl: Copied from Scripts/test-webkit-perl.
      - Added paths to new test files.
    
    * Scripts/webkitperl: Added.
    * Scripts/webkitperl/VCSUtils_unittest: Added.
    * Scripts/webkitperl/VCSUtils_unittest/fixChangeLogPatch.pl: Added.
    * Scripts/webkitperl/VCSUtils_unittest/generatePatchCommand.pl: Added.
    * Scripts/webkitperl/VCSUtils_unittest/runPatchCommand.pl: Copied from Scripts/VCSUtils_unittest.pl.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52732 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 7c9796b..1eca884 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,34 @@
+2010-01-04  Chris Jerdonek  <chris.jerdonek at gmail.com>
+
+        Reviewed by David Kilzer.
+
+        Divided the Perl unit tests into separate files and put
+        them in a separate directory, and renamed test-webkit-perl
+        to test-webkitperl.
+
+        https://bugs.webkit.org/show_bug.cgi?id=33124
+
+        * Scripts/VCSUtils.pm:
+          - Renamed generateRunPatchCommand() to generatePatchCommand().
+
+        * Scripts/VCSUtils_unittest.pl: Removed.
+          - Divided into three files in Scripts/webkitperl/VCSUtils_unittest.
+
+        * Scripts/test-webkit-perl: Removed.
+          - Renamed to test-webkitperl.
+
+        * Scripts/test-webkit-scripts:
+          - Updated paths to test-webkitpy and test-webkitperl.
+
+        * Scripts/test-webkitperl: Copied from Scripts/test-webkit-perl.
+          - Added paths to new test files.
+
+        * Scripts/webkitperl: Added.
+        * Scripts/webkitperl/VCSUtils_unittest: Added.
+        * Scripts/webkitperl/VCSUtils_unittest/fixChangeLogPatch.pl: Added.
+        * Scripts/webkitperl/VCSUtils_unittest/generatePatchCommand.pl: Added.
+        * Scripts/webkitperl/VCSUtils_unittest/runPatchCommand.pl: Copied from Scripts/VCSUtils_unittest.pl.
+
 2010-01-04  Eric Seidel  <eric at webkit.org>
 
         Reviewed by Adam Barth.
diff --git a/WebKitTools/Scripts/VCSUtils.pm b/WebKitTools/Scripts/VCSUtils.pm
index c1db3c0..3879264 100644
--- a/WebKitTools/Scripts/VCSUtils.pm
+++ b/WebKitTools/Scripts/VCSUtils.pm
@@ -520,7 +520,7 @@ sub fixChangeLogPatch($)
 # Returns ($patchCommand, $isForcing).
 #
 # This subroutine has unit tests in VCSUtils_unittest.pl.
-sub generateRunPatchCommand($)
+sub generatePatchCommand($)
 {
     my ($passedArgsHashRef) = @_;
 
@@ -592,7 +592,7 @@ sub runPatchCommand($$$;$)
 {
     my ($patch, $repositoryRootPath, $pathRelativeToRoot, $args) = @_;
 
-    my ($patchCommand, $isForcing) = generateRunPatchCommand($args);
+    my ($patchCommand, $isForcing) = generatePatchCommand($args);
 
     # Temporarily change the working directory since the path found
     # in the patch's "Index:" line is relative to the repository root
diff --git a/WebKitTools/Scripts/VCSUtils_unittest.pl b/WebKitTools/Scripts/VCSUtils_unittest.pl
deleted file mode 100755
index 17dadcb..0000000
--- a/WebKitTools/Scripts/VCSUtils_unittest.pl
+++ /dev/null
@@ -1,424 +0,0 @@
-#!/usr/bin/perl
-#
-# Copyright (C) 2009, 2010 Chris Jerdonek (chris.jerdonek at gmail.com)
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-# 
-#     * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#     * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-#     * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-# 
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-# Unit tests of VCSUtils.pm.
-
-use Test::Simple tests => 21;
-
-use FindBin;
-use lib $FindBin::Bin; # so this script can be run from any directory.
-
-use VCSUtils;
-
-# Call a function while suppressing STDERR.
-sub callSilently($@) {
-    my ($func, @args) = @_;
-
-    open(OLDERR, ">&STDERR");
-    close(STDERR);
-    my @returnValue = &$func(@args);
-    open(STDERR, ">&OLDERR");
-    close(OLDERR); # FIXME: Is this necessary?
-
-    return @returnValue;
-}
-
-# fixChangeLogPatch
-#
-# The source ChangeLog for these tests is the following:
-# 
-# 2009-12-22  Alice  <alice at email.address>
-# 
-#         Reviewed by Ray.
-# 
-#         Changed some code on 2009-12-22.
-# 
-#         * File:
-#         * File2:
-# 
-# 2009-12-21  Alice  <alice at email.address>
-# 
-#         Reviewed by Ray.
-# 
-#         Changed some code on 2009-12-21.
-# 
-#         * File:
-#         * File2:
-
-my $title;
-my $in;
-my $out;
-
-# New test
-$title = "fixChangeLogPatch: [no change] First line is new line.";
-
-$in = <<'END';
---- ChangeLog
-+++ ChangeLog
-@@ -1,3 +1,11 @@
-+2009-12-22  Bob  <bob at email.address>
-+
-+        Reviewed by Ray.
-+
-+        Changed some more code on 2009-12-22.
-+
-+        * File:
-+
- 2009-12-22  Alice  <alice at email.address>
- 
-         Reviewed by Ray.
-END
-
-ok(fixChangeLogPatch($in) eq $in, $title);
-
-# New test
-$title = "fixChangeLogPatch: [no change] No date string.";
-
-$in = <<'END';
---- ChangeLog
-+++ ChangeLog
-@@ -6,6 +6,7 @@
- 
-         * File:
-         * File2:
-+        * File3:
- 
- 2009-12-21  Alice  <alice at email.address>
- 
-END
-
-ok(fixChangeLogPatch($in) eq $in, $title);
-
-# New test
-$title = "fixChangeLogPatch: [no change] New entry inserted in middle.";
-
-$in = <<'END';
---- ChangeLog
-+++ ChangeLog
-@@ -11,6 +11,14 @@
- 
-         Reviewed by Ray.
- 
-+        Changed some more code on 2009-12-21.
-+
-+        * File:
-+
-+2009-12-21  Alice  <alice at email.address>
-+
-+        Reviewed by Ray.
-+
-         Changed some code on 2009-12-21.
- 
-         * File:
-END
-
-ok(fixChangeLogPatch($in) eq $in, $title);
-
-# New test
-$title = "fixChangeLogPatch: Leading context includes first line.";
-
-$in = <<'END';
---- ChangeLog
-+++ ChangeLog
-@@ -1,5 +1,13 @@
- 2009-12-22  Alice  <alice at email.address>
- 
-+        Reviewed by Sue.
-+
-+        Changed some more code on 2009-12-22.
-+
-+        * File:
-+
-+2009-12-22  Alice  <alice at email.address>
-+
-         Reviewed by Ray.
- 
-         Changed some code on 2009-12-22.
-END
-
-$out = <<'END';
---- ChangeLog
-+++ ChangeLog
-@@ -1,3 +1,11 @@
-+2009-12-22  Alice  <alice at email.address>
-+
-+        Reviewed by Sue.
-+
-+        Changed some more code on 2009-12-22.
-+
-+        * File:
-+
- 2009-12-22  Alice  <alice at email.address>
- 
-         Reviewed by Ray.
-END
-
-ok(fixChangeLogPatch($in) eq $out, $title);
-
-# New test
-$title = "fixChangeLogPatch: Leading context does not include first line.";
-
-$in = <<'END';
-@@ -2,6 +2,14 @@
- 
-         Reviewed by Ray.
- 
-+        Changed some more code on 2009-12-22.
-+
-+        * File:
-+
-+2009-12-22  Alice  <alice at email.address>
-+
-+        Reviewed by Ray.
-+
-         Changed some code on 2009-12-22.
- 
-         * File:
-END
-
-$out = <<'END';
-@@ -1,3 +1,11 @@
-+2009-12-22  Alice  <alice at email.address>
-+
-+        Reviewed by Ray.
-+
-+        Changed some more code on 2009-12-22.
-+
-+        * File:
-+
- 2009-12-22  Alice  <alice at email.address>
- 
-         Reviewed by Ray.
-END
-
-ok(fixChangeLogPatch($in) eq $out, $title);
-
-# New test
-$title = "fixChangeLogPatch: Non-consecutive line additions.";
-
-# This can occur, for example, if the new ChangeLog entry includes
-# trailing white space in the first blank line but not the second.
-# A diff command can then match the second blank line of the new
-# ChangeLog entry with the first blank line of the old.
-# The svn diff command with the default --diff-cmd has done this.
-$in = <<'END';
-@@ -1,5 +1,11 @@
- 2009-12-22  Alice  <alice at email.address>
-+ <pretend-whitespace>
-+        Reviewed by Ray.
- 
-+        Changed some more code on 2009-12-22.
-+
-+2009-12-22  Alice  <alice at email.address>
-+
-         Reviewed by Ray.
- 
-         Changed some code on 2009-12-22.
-END
-
-$out = <<'END';
-@@ -1,3 +1,9 @@
-+2009-12-22  Alice  <alice at email.address>
-+ <pretend-whitespace>
-+        Reviewed by Ray.
-+
-+        Changed some more code on 2009-12-22.
-+
- 2009-12-22  Alice  <alice at email.address>
- 
-         Reviewed by Ray.
-END
-
-ok(fixChangeLogPatch($in) eq $out, $title);
-
-# New test
-$title = "fixChangeLogPatch: Additional edits after new entry.";
-
-$in = <<'END';
-@@ -2,10 +2,17 @@
- 
-         Reviewed by Ray.
- 
-+        Changed some more code on 2009-12-22.
-+
-+        * File:
-+
-+2009-12-22  Alice  <alice at email.address>
-+
-+        Reviewed by Ray.
-+
-         Changed some code on 2009-12-22.
- 
-         * File:
--        * File2:
- 
- 2009-12-21  Alice  <alice at email.address>
- 
-END
-
-$out = <<'END';
-@@ -1,11 +1,18 @@
-+2009-12-22  Alice  <alice at email.address>
-+
-+        Reviewed by Ray.
-+
-+        Changed some more code on 2009-12-22.
-+
-+        * File:
-+
- 2009-12-22  Alice  <alice at email.address>
- 
-         Reviewed by Ray.
- 
-         Changed some code on 2009-12-22.
- 
-         * File:
--        * File2:
- 
- 2009-12-21  Alice  <alice at email.address>
- 
-END
-
-ok(fixChangeLogPatch($in) eq $out, $title);
-
-# Tests: generateRunPatchCommand
-
-# New test
-$title = "generateRunPatchCommand: Undefined optional arguments.";
-
-my $argsHashRef;
-my ($patchCommand, $isForcing) = VCSUtils::generateRunPatchCommand($argsHashRef);
-
-ok($patchCommand eq "patch -p0", $title);
-ok($isForcing == 0, $title);
-
-# New test
-$title = "generateRunPatchCommand: Undefined options.";
-
-my $options;
-$argsHashRef = {options => $options};
-($patchCommand, $isForcing) = VCSUtils::generateRunPatchCommand($argsHashRef);
-
-ok($patchCommand eq "patch -p0", $title);
-ok($isForcing == 0, $title);
-
-# New test
-$title = "generateRunPatchCommand: --force and no \"ensure force\".";
-
-$argsHashRef = {options => ["--force"]};
-($patchCommand, $isForcing) = VCSUtils::generateRunPatchCommand($argsHashRef);
-
-ok($patchCommand eq "patch -p0 --force", $title);
-ok($isForcing == 1, $title);
-
-# New test
-$title = "generateRunPatchCommand: no --force and \"ensure force\".";
-
-$argsHashRef = {ensureForce => 1};
-($patchCommand, $isForcing) = VCSUtils::generateRunPatchCommand($argsHashRef);
-
-ok($patchCommand eq "patch -p0 --force", $title);
-ok($isForcing == 1, $title);
-
-# New test
-$title = "generateRunPatchCommand: \"should reverse\".";
-
-$argsHashRef = {shouldReverse => 1};
-($patchCommand, $isForcing) = VCSUtils::generateRunPatchCommand($argsHashRef);
-
-ok($patchCommand eq "patch -p0 --reverse", $title);
-
-# New test
-$title = "generateRunPatchCommand: --fuzz=3, --force.";
-
-$argsHashRef = {options => ["--fuzz=3", "--force"]};
-($patchCommand, $isForcing) = VCSUtils::generateRunPatchCommand($argsHashRef);
-
-ok($patchCommand eq "patch -p0 --force --fuzz=3", $title);
-
-# Tests: runPatchCommand
-
-# New test
-$title = "runPatchCommand: Unsuccessful patch, forcing.";
-
-# Since $patch has no "Index:" path, passing this to runPatchCommand
-# should not affect any files.
-my $patch = <<'END';
-Garbage patch contents
-END
-
-# We call via callSilently() to avoid output like the following to STDERR:
-# patch: **** Only garbage was found in the patch input.
-$argsHashRef = {ensureForce => 1};
-$exitStatus = callSilently(\&runPatchCommand, $patch, ".", "file_to_patch.txt", $argsHashRef);
-
-ok($exitStatus != 0, $title);
-
-# New test
-$title = "runPatchCommand: New file, --dry-run.";
-
-# This file should not exist after the tests, but we take care with the
-# file name and contents just in case.
-my $fileToPatch = "temp_OK_TO_ERASE__README_FOR_MORE.txt";
-$patch = <<END;
-Index: $fileToPatch
-===================================================================
---- $fileToPatch	(revision 0)
-+++ $fileToPatch	(revision 0)
-@@ -0,0 +1,5 @@
-+This is a test file for WebKitTools/Scripts/VCSUtils_unittest.pl.
-+This file should not have gotten created on your system.
-+If it did, some unit tests don't seem to be working quite right:
-+It would be great if you could file a bug report. Thanks!
-+---------------------------------------------------------------------
-END
-
-# --dry-run prevents creating any files.
-# --silent suppresses the success message to STDOUT.
-$argsHashRef = {options => ["--dry-run", "--silent"]};
-$exitStatus = runPatchCommand($patch, ".", $fileToPatch, $argsHashRef);
-
-ok($exitStatus == 0, $title);
-
-# New test
-$title = "runPatchCommand: New file: \"$fileToPatch\".";
-
-$argsHashRef = {options => ["--silent"]};
-$exitStatus = runPatchCommand($patch, ".", $fileToPatch, $argsHashRef);
-
-ok($exitStatus == 0, $title);
-
-# New test
-$title = "runPatchCommand: Reverse new file (clean up previous).";
-
-$argsHashRef = {shouldReverse => 1,
-                options => ["--silent", "--remove-empty-files"]}; # To clean up.
-$exitStatus = runPatchCommand($patch, ".", $fileToPatch, $argsHashRef);
-ok($exitStatus == 0, $title);
diff --git a/WebKitTools/Scripts/test-webkit-perl b/WebKitTools/Scripts/test-webkit-perl
deleted file mode 100755
index e4e5836..0000000
--- a/WebKitTools/Scripts/test-webkit-perl
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/perl
-#
-# Copyright (C) 2009 Chris Jerdonek (chris.jerdonek at gmail.com)
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-# 
-#     * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#     * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-#     * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-# 
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-# Runs unit tests of WebKit Perl code.
-
-use FindBin;
-use Test::Harness;
-
-# Use an absolute path so this script can be run from any directory.
-$scriptsDir = $FindBin::Bin;
-$scriptsDir =~ s|/+$||; # Remove trailing '/'
-
-runtests("$scriptsDir/VCSUtils_unittest.pl");
diff --git a/WebKitTools/Scripts/test-webkit-scripts b/WebKitTools/Scripts/test-webkit-scripts
index fbe27fa..af8cd20 100755
--- a/WebKitTools/Scripts/test-webkit-scripts
+++ b/WebKitTools/Scripts/test-webkit-scripts
@@ -71,10 +71,10 @@ if __name__ == '__main__':
     # Use absolute paths so this script can be run from any directory.
     scripts_directory = sys.path[0]
 
-    test_script('Perl scripts', os.path.join(scripts_directory, 'test-webkit-perl'))
+    test_script('Perl scripts', os.path.join(scripts_directory, 'test-webkitperl'))
 
     test_script('Python scripts',
-                os.path.join(scripts_directory, 'test-webkit-python'),
+                os.path.join(scripts_directory, 'test-webkitpy'),
                 ['--all'] if should_include_all else None)
 
     # FIXME: Display a cumulative indication of success or failure.
diff --git a/WebKitTools/Scripts/test-webkitperl b/WebKitTools/Scripts/test-webkitperl
new file mode 100755
index 0000000..94caeb3
--- /dev/null
+++ b/WebKitTools/Scripts/test-webkitperl
@@ -0,0 +1,51 @@
+#!/usr/bin/perl
+#
+# Copyright (C) 2009 Chris Jerdonek (chris.jerdonek at gmail.com)
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+# 
+#     * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#     * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# Runs unit tests of WebKit Perl code.
+
+use FindBin;
+use Test::Harness;
+use lib $FindBin::Bin; # so this script can be run from any directory.
+use VCSUtils;
+
+# Use an absolute path so this script can be run from any directory.
+$scriptsDir = $FindBin::Bin;
+$scriptsDir =~ s|/+$||; # Remove trailing '/'
+
+# VCSUtils subroutines
+my @files = (
+    "fixChangeLogPatch.pl",
+    "generatePatchCommand.pl",
+    "runPatchCommand.pl",
+);
+
+ at files = map "$scriptsDir/webkitperl/VCSUtils_unittest/$_", @files; # prepend
+
+runtests(@files);
diff --git a/WebKitTools/Scripts/webkitperl/VCSUtils_unittest/fixChangeLogPatch.pl b/WebKitTools/Scripts/webkitperl/VCSUtils_unittest/fixChangeLogPatch.pl
new file mode 100644
index 0000000..d21c706
--- /dev/null
+++ b/WebKitTools/Scripts/webkitperl/VCSUtils_unittest/fixChangeLogPatch.pl
@@ -0,0 +1,290 @@
+#!/usr/bin/perl
+#
+# Copyright (C) 2009, 2010 Chris Jerdonek (chris.jerdonek at gmail.com)
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+# 
+#     * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#     * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# Unit tests of VCSUtils::fixChangeLogPatch().
+
+use Test::Simple tests => 7;
+use VCSUtils;
+
+# The source ChangeLog for these tests is the following:
+# 
+# 2009-12-22  Alice  <alice at email.address>
+# 
+#         Reviewed by Ray.
+# 
+#         Changed some code on 2009-12-22.
+# 
+#         * File:
+#         * File2:
+# 
+# 2009-12-21  Alice  <alice at email.address>
+# 
+#         Reviewed by Ray.
+# 
+#         Changed some code on 2009-12-21.
+# 
+#         * File:
+#         * File2:
+
+my $title;
+my $in;
+my $out;
+
+# New test
+$title = "fixChangeLogPatch: [no change] First line is new line.";
+
+$in = <<'END';
+--- ChangeLog
++++ ChangeLog
+@@ -1,3 +1,11 @@
++2009-12-22  Bob  <bob at email.address>
++
++        Reviewed by Ray.
++
++        Changed some more code on 2009-12-22.
++
++        * File:
++
+ 2009-12-22  Alice  <alice at email.address>
+ 
+         Reviewed by Ray.
+END
+
+ok(fixChangeLogPatch($in) eq $in, $title);
+
+# New test
+$title = "fixChangeLogPatch: [no change] No date string.";
+
+$in = <<'END';
+--- ChangeLog
++++ ChangeLog
+@@ -6,6 +6,7 @@
+ 
+         * File:
+         * File2:
++        * File3:
+ 
+ 2009-12-21  Alice  <alice at email.address>
+ 
+END
+
+ok(fixChangeLogPatch($in) eq $in, $title);
+
+# New test
+$title = "fixChangeLogPatch: [no change] New entry inserted in middle.";
+
+$in = <<'END';
+--- ChangeLog
++++ ChangeLog
+@@ -11,6 +11,14 @@
+ 
+         Reviewed by Ray.
+ 
++        Changed some more code on 2009-12-21.
++
++        * File:
++
++2009-12-21  Alice  <alice at email.address>
++
++        Reviewed by Ray.
++
+         Changed some code on 2009-12-21.
+ 
+         * File:
+END
+
+ok(fixChangeLogPatch($in) eq $in, $title);
+
+# New test
+$title = "fixChangeLogPatch: Leading context includes first line.";
+
+$in = <<'END';
+--- ChangeLog
++++ ChangeLog
+@@ -1,5 +1,13 @@
+ 2009-12-22  Alice  <alice at email.address>
+ 
++        Reviewed by Sue.
++
++        Changed some more code on 2009-12-22.
++
++        * File:
++
++2009-12-22  Alice  <alice at email.address>
++
+         Reviewed by Ray.
+ 
+         Changed some code on 2009-12-22.
+END
+
+$out = <<'END';
+--- ChangeLog
++++ ChangeLog
+@@ -1,3 +1,11 @@
++2009-12-22  Alice  <alice at email.address>
++
++        Reviewed by Sue.
++
++        Changed some more code on 2009-12-22.
++
++        * File:
++
+ 2009-12-22  Alice  <alice at email.address>
+ 
+         Reviewed by Ray.
+END
+
+ok(fixChangeLogPatch($in) eq $out, $title);
+
+# New test
+$title = "fixChangeLogPatch: Leading context does not include first line.";
+
+$in = <<'END';
+@@ -2,6 +2,14 @@
+ 
+         Reviewed by Ray.
+ 
++        Changed some more code on 2009-12-22.
++
++        * File:
++
++2009-12-22  Alice  <alice at email.address>
++
++        Reviewed by Ray.
++
+         Changed some code on 2009-12-22.
+ 
+         * File:
+END
+
+$out = <<'END';
+@@ -1,3 +1,11 @@
++2009-12-22  Alice  <alice at email.address>
++
++        Reviewed by Ray.
++
++        Changed some more code on 2009-12-22.
++
++        * File:
++
+ 2009-12-22  Alice  <alice at email.address>
+ 
+         Reviewed by Ray.
+END
+
+ok(fixChangeLogPatch($in) eq $out, $title);
+
+# New test
+$title = "fixChangeLogPatch: Non-consecutive line additions.";
+
+# This can occur, for example, if the new ChangeLog entry includes
+# trailing white space in the first blank line but not the second.
+# A diff command can then match the second blank line of the new
+# ChangeLog entry with the first blank line of the old.
+# The svn diff command with the default --diff-cmd has done this.
+$in = <<'END';
+@@ -1,5 +1,11 @@
+ 2009-12-22  Alice  <alice at email.address>
++ <pretend-whitespace>
++        Reviewed by Ray.
+ 
++        Changed some more code on 2009-12-22.
++
++2009-12-22  Alice  <alice at email.address>
++
+         Reviewed by Ray.
+ 
+         Changed some code on 2009-12-22.
+END
+
+$out = <<'END';
+@@ -1,3 +1,9 @@
++2009-12-22  Alice  <alice at email.address>
++ <pretend-whitespace>
++        Reviewed by Ray.
++
++        Changed some more code on 2009-12-22.
++
+ 2009-12-22  Alice  <alice at email.address>
+ 
+         Reviewed by Ray.
+END
+
+ok(fixChangeLogPatch($in) eq $out, $title);
+
+# New test
+$title = "fixChangeLogPatch: Additional edits after new entry.";
+
+$in = <<'END';
+@@ -2,10 +2,17 @@
+ 
+         Reviewed by Ray.
+ 
++        Changed some more code on 2009-12-22.
++
++        * File:
++
++2009-12-22  Alice  <alice at email.address>
++
++        Reviewed by Ray.
++
+         Changed some code on 2009-12-22.
+ 
+         * File:
+-        * File2:
+ 
+ 2009-12-21  Alice  <alice at email.address>
+ 
+END
+
+$out = <<'END';
+@@ -1,11 +1,18 @@
++2009-12-22  Alice  <alice at email.address>
++
++        Reviewed by Ray.
++
++        Changed some more code on 2009-12-22.
++
++        * File:
++
+ 2009-12-22  Alice  <alice at email.address>
+ 
+         Reviewed by Ray.
+ 
+         Changed some code on 2009-12-22.
+ 
+         * File:
+-        * File2:
+ 
+ 2009-12-21  Alice  <alice at email.address>
+ 
+END
+
+ok(fixChangeLogPatch($in) eq $out, $title);
diff --git a/WebKitTools/Scripts/webkitperl/VCSUtils_unittest/generatePatchCommand.pl b/WebKitTools/Scripts/webkitperl/VCSUtils_unittest/generatePatchCommand.pl
new file mode 100644
index 0000000..483a0a8
--- /dev/null
+++ b/WebKitTools/Scripts/webkitperl/VCSUtils_unittest/generatePatchCommand.pl
@@ -0,0 +1,87 @@
+#!/usr/bin/perl
+#
+# Copyright (C) 2009, 2010 Chris Jerdonek (chris.jerdonek at gmail.com)
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+# 
+#     * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#     * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# Unit tests of VCSUtils::generatePatchCommand().
+
+use Test::Simple tests => 10;
+use VCSUtils;
+
+# New test
+$title = "generatePatchCommand: Undefined optional arguments.";
+
+my $argsHashRef;
+my ($patchCommand, $isForcing) = VCSUtils::generatePatchCommand($argsHashRef);
+
+ok($patchCommand eq "patch -p0", $title);
+ok($isForcing == 0, $title);
+
+# New test
+$title = "generatePatchCommand: Undefined options.";
+
+my $options;
+$argsHashRef = {options => $options};
+($patchCommand, $isForcing) = VCSUtils::generatePatchCommand($argsHashRef);
+
+ok($patchCommand eq "patch -p0", $title);
+ok($isForcing == 0, $title);
+
+# New test
+$title = "generatePatchCommand: --force and no \"ensure force\".";
+
+$argsHashRef = {options => ["--force"]};
+($patchCommand, $isForcing) = VCSUtils::generatePatchCommand($argsHashRef);
+
+ok($patchCommand eq "patch -p0 --force", $title);
+ok($isForcing == 1, $title);
+
+# New test
+$title = "generatePatchCommand: no --force and \"ensure force\".";
+
+$argsHashRef = {ensureForce => 1};
+($patchCommand, $isForcing) = VCSUtils::generatePatchCommand($argsHashRef);
+
+ok($patchCommand eq "patch -p0 --force", $title);
+ok($isForcing == 1, $title);
+
+# New test
+$title = "generatePatchCommand: \"should reverse\".";
+
+$argsHashRef = {shouldReverse => 1};
+($patchCommand, $isForcing) = VCSUtils::generatePatchCommand($argsHashRef);
+
+ok($patchCommand eq "patch -p0 --reverse", $title);
+
+# New test
+$title = "generatePatchCommand: --fuzz=3, --force.";
+
+$argsHashRef = {options => ["--fuzz=3", "--force"]};
+($patchCommand, $isForcing) = VCSUtils::generatePatchCommand($argsHashRef);
+
+ok($patchCommand eq "patch -p0 --force --fuzz=3", $title);
diff --git a/WebKitTools/Scripts/webkitperl/VCSUtils_unittest/runPatchCommand.pl b/WebKitTools/Scripts/webkitperl/VCSUtils_unittest/runPatchCommand.pl
new file mode 100644
index 0000000..8111def
--- /dev/null
+++ b/WebKitTools/Scripts/webkitperl/VCSUtils_unittest/runPatchCommand.pl
@@ -0,0 +1,105 @@
+#!/usr/bin/perl
+#
+# Copyright (C) 2009, 2010 Chris Jerdonek (chris.jerdonek at gmail.com)
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+# 
+#     * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#     * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# Unit tests of VCSUtils::runPatchCommand().
+
+use Test::Simple tests => 4;
+use VCSUtils;
+
+# Call a function while suppressing STDERR.
+sub callSilently($@) {
+    my ($func, @args) = @_;
+
+    open(OLDERR, ">&STDERR");
+    close(STDERR);
+    my @returnValue = &$func(@args);
+    open(STDERR, ">&OLDERR");
+    close(OLDERR); # FIXME: Is this necessary?
+
+    return @returnValue;
+}
+
+# New test
+$title = "runPatchCommand: Unsuccessful patch, forcing.";
+
+# Since $patch has no "Index:" path, passing this to runPatchCommand
+# should not affect any files.
+my $patch = <<'END';
+Garbage patch contents
+END
+
+# We call via callSilently() to avoid output like the following to STDERR:
+# patch: **** Only garbage was found in the patch input.
+$argsHashRef = {ensureForce => 1};
+$exitStatus = callSilently(\&runPatchCommand, $patch, ".", "file_to_patch.txt", $argsHashRef);
+
+ok($exitStatus != 0, $title);
+
+# New test
+$title = "runPatchCommand: New file, --dry-run.";
+
+# This file should not exist after the tests, but we take care with the
+# file name and contents just in case.
+my $fileToPatch = "temp_OK_TO_ERASE__README_FOR_MORE.txt";
+$patch = <<END;
+Index: $fileToPatch
+===================================================================
+--- $fileToPatch	(revision 0)
++++ $fileToPatch	(revision 0)
+@@ -0,0 +1,5 @@
++This is a test file for WebKitTools/Scripts/VCSUtils_unittest.pl.
++This file should not have gotten created on your system.
++If it did, some unit tests don't seem to be working quite right:
++It would be great if you could file a bug report. Thanks!
++---------------------------------------------------------------------
+END
+
+# --dry-run prevents creating any files.
+# --silent suppresses the success message to STDOUT.
+$argsHashRef = {options => ["--dry-run", "--silent"]};
+$exitStatus = runPatchCommand($patch, ".", $fileToPatch, $argsHashRef);
+
+ok($exitStatus == 0, $title);
+
+# New test
+$title = "runPatchCommand: New file: \"$fileToPatch\".";
+
+$argsHashRef = {options => ["--silent"]};
+$exitStatus = runPatchCommand($patch, ".", $fileToPatch, $argsHashRef);
+
+ok($exitStatus == 0, $title);
+
+# New test
+$title = "runPatchCommand: Reverse new file (clean up previous).";
+
+$argsHashRef = {shouldReverse => 1,
+                options => ["--silent", "--remove-empty-files"]}; # To clean up.
+$exitStatus = runPatchCommand($patch, ".", $fileToPatch, $argsHashRef);
+ok($exitStatus == 0, $title);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list