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

eric at webkit.org eric at webkit.org
Wed Apr 7 22:59:57 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit fb318dd7de2f3fe7fd37802834898b0ab3ac92a9
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Oct 22 06:20:26 2009 +0000

    2009-10-21  Eric Seidel  <eric at webkit.org>
    
            Reviewed by Adam Barth.
    
            bugzilla-tool's "patch failed to download an apply" error should give more information
            https://bugs.webkit.org/show_bug.cgi?id=30632
    
            * Scripts/modules/scm.py:
             - Use the common run_command method instead of custom POpen code.
             - Make run_command know how to take pipes as input.
            * Scripts/modules/scm_unittest.py:
             - Add new tests to cover change.
             - Also move test_error_handlers into new SCMClassTests so we don't run it 3 times.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@49931 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index ef74d18..a2d415e 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,17 @@
+2009-10-21  Eric Seidel  <eric at webkit.org>
+
+        Reviewed by Adam Barth.
+
+        bugzilla-tool's "patch failed to download an apply" error should give more information
+        https://bugs.webkit.org/show_bug.cgi?id=30632
+
+        * Scripts/modules/scm.py:
+         - Use the common run_command method instead of custom POpen code.
+         - Make run_command know how to take pipes as input.
+        * Scripts/modules/scm_unittest.py:
+         - Add new tests to cover change.
+         - Also move test_error_handlers into new SCMClassTests so we don't run it 3 times.
+
 2009-10-21  Kent Tamura  <tkent at chromium.org>
 
         Unreviewed.  Adding myself to the committers list.
diff --git a/WebKitTools/Scripts/modules/scm.py b/WebKitTools/Scripts/modules/scm.py
index 704f65c..3ffa23b 100644
--- a/WebKitTools/Scripts/modules/scm.py
+++ b/WebKitTools/Scripts/modules/scm.py
@@ -124,9 +124,14 @@ class SCM:
 
     @staticmethod
     def run_command(args, cwd=None, input=None, error_handler=default_error_handler, return_exit_code=False):
-        stdin = subprocess.PIPE if input else None
+        if hasattr(input, 'read'): # Check if the input is a file.
+            stdin = input
+            string_to_communicate = None
+        else:
+            stdin = subprocess.PIPE if input else None
+            string_to_communicate = input
         process = subprocess.Popen(args, stdin=stdin, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=cwd)
-        output = process.communicate(input)[0].rstrip()
+        output = process.communicate(string_to_communicate)[0].rstrip()
         exit_code = process.wait()
         if exit_code:
             script_error = ScriptError(script_args=args, exit_code=exit_code, output=output, cwd=cwd)
@@ -166,11 +171,8 @@ class SCM:
         args = [self.script_path('svn-apply'), '--reviewer', patch['reviewer']]
         if force:
             args.append('--force')
-        patch_apply_process = subprocess.Popen(args, stdin=curl_process.stdout)
 
-        return_code = patch_apply_process.wait()
-        if return_code:
-            raise ScriptError(message="Patch %s from bug %s failed to download and apply." % (patch['url'], patch['bug_id']))
+        self.run_command(args, input=curl_process.stdout)
 
     def run_status_and_extract_filenames(self, status_command, status_regexp):
         filenames = []
diff --git a/WebKitTools/Scripts/modules/scm_unittest.py b/WebKitTools/Scripts/modules/scm_unittest.py
index ed9066d..784303f 100644
--- a/WebKitTools/Scripts/modules/scm_unittest.py
+++ b/WebKitTools/Scripts/modules/scm_unittest.py
@@ -113,23 +113,30 @@ class SVNTestRepository:
         run(['rm', '-rf', test_object.svn_repo_path])
         run(['rm', '-rf', test_object.svn_checkout_path])
 
+# For testing the SCM baseclass directly.
+class SCMClassTests(unittest.TestCase):
+    def setUp(self):
+        self.dev_null = open(os.devnull, "w") # Used to make our Popen calls quiet.
 
-class SCMTest(unittest.TestCase):
-    def _create_patch(self, patch_contents):
-        patch_path = os.path.join(self.svn_checkout_path, 'patch.diff')
-        write_into_file_at_path(patch_path, patch_contents)
-        patch = {}
-        patch['reviewer'] = 'Joe Cool'
-        patch['bug_id'] = '12345'
-        patch['url'] = 'file://%s' % urllib.pathname2url(patch_path)
-        return patch
+    def tearDown(self):
+        self.dev_null.close()
 
-    def _setup_webkittools_scripts_symlink(self, local_scm):
-        webkit_scm = detect_scm_system(os.path.dirname(os.path.abspath(__file__)))
-        webkit_scripts_directory = webkit_scm.scripts_directory()
-        local_scripts_directory = local_scm.scripts_directory()
-        os.mkdir(os.path.dirname(local_scripts_directory))
-        os.symlink(webkit_scripts_directory, local_scripts_directory)
+    def test_run_command_with_pipe(self):
+        input_process = subprocess.Popen(['/bin/echo', 'foo\nbar'], stdout=subprocess.PIPE, stderr=self.dev_null)
+        self.assertEqual(SCM.run_command(['/usr/bin/grep', 'bar'], input=input_process.stdout), "bar")
+
+        # Test the non-pipe case too:
+        self.assertEqual(SCM.run_command(['/usr/bin/grep', 'bar'], input="foo\nbar"), "bar")
+
+        command_returns_non_zero = ['/bin/sh', '--invalid-option']
+        # Test when the input pipe process fails.
+        input_process = subprocess.Popen(command_returns_non_zero, stdout=subprocess.PIPE, stderr=self.dev_null)
+        self.assertTrue(input_process.poll() != 0)
+        self.assertRaises(ScriptError, SCM.run_command, ['/usr/bin/grep', 'bar'], input=input_process.stdout)
+
+        # Test when the run_command process fails.
+        input_process = subprocess.Popen(['/bin/echo', 'foo\nbar'], stdout=subprocess.PIPE, stderr=self.dev_null) # grep shows usage and calls exit(2) when called w/o arguments.
+        self.assertRaises(ScriptError, SCM.run_command, command_returns_non_zero, input=input_process.stdout)
 
     def test_error_handlers(self):
         git_failure_message="Merge conflict during commit: Your file or directory 'WebCore/ChangeLog' is probably out-of-date: resource out of date; try updating at /usr/local/libexec/git-core//git-svn line 469"
@@ -150,6 +157,24 @@ svn: resource out of date; try updating
         self.assertRaises(ScriptError, commit_error_handler, ScriptError(output='blah blah blah'))
 
 
+# GitTest and SVNTest inherit from this so any test_ methods here will be run once for this class and then once for each subclass.
+class SCMTest(unittest.TestCase):
+    def _create_patch(self, patch_contents):
+        patch_path = os.path.join(self.svn_checkout_path, 'patch.diff')
+        write_into_file_at_path(patch_path, patch_contents)
+        patch = {}
+        patch['reviewer'] = 'Joe Cool'
+        patch['bug_id'] = '12345'
+        patch['url'] = 'file://%s' % urllib.pathname2url(patch_path)
+        return patch
+
+    def _setup_webkittools_scripts_symlink(self, local_scm):
+        webkit_scm = detect_scm_system(os.path.dirname(os.path.abspath(__file__)))
+        webkit_scripts_directory = webkit_scm.scripts_directory()
+        local_scripts_directory = local_scm.scripts_directory()
+        os.mkdir(os.path.dirname(local_scripts_directory))
+        os.symlink(webkit_scripts_directory, local_scripts_directory)
+
     # Tests which both GitTest and SVNTest should run.
     # FIXME: There must be a simpler way to add these w/o adding a wrapper method to both subclasses
     def _shared_test_commit_with_message(self):

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list