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

dbates at webkit.org dbates at webkit.org
Thu Apr 8 00:50:47 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 9f04d87950b85ba799015b1c85a805f4e3141545
Author: dbates at webkit.org <dbates at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Dec 28 02:01:57 2009 +0000

    2009-12-27  Daniel Bates  <dbates at webkit.org>
    
            Reviewed by Adam Barth.
    
            https://bugs.webkit.org/show_bug.cgi?id=32896
    
            Fixes an issue where bugzilla-tool tries to read the username and password from
            Git regardless of whether Git is installed. In particular, if Git is not
            installed then bugzilla-tool dies (with a trace) when it attempts to query Git
            for the authentication credentials to log into bugs.webkit.org.
    
            Moreover, modifies Executive.run_command to catch and pass OSError exceptions to
            the specified error handler. For instance, the specified error handler will now
            be called when the command does not exist (i.e. OSError errno 2).
    
            * Scripts/modules/credentials.py: Added check for Git.
            * Scripts/modules/credentials_unittest.py: Added test method
            test_read_credentials_with_SVN.
            * Scripts/modules/executive.py: Modified method run_command to catch
            OSError exceptions (i.e [Errno 2] No such file or directory) and call
            the specified error handler.
            * Scripts/modules/executive_unittest.py: Added.
            * Scripts/run-webkit-unittests: Added import executive_unittest.py.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52587 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index abe7b94..a8d12a3 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,5 +1,29 @@
 2009-12-27  Daniel Bates  <dbates at webkit.org>
 
+        Reviewed by Adam Barth.
+
+        https://bugs.webkit.org/show_bug.cgi?id=32896
+
+        Fixes an issue where bugzilla-tool tries to read the username and password from
+        Git regardless of whether Git is installed. In particular, if Git is not
+        installed then bugzilla-tool dies (with a trace) when it attempts to query Git
+        for the authentication credentials to log into bugs.webkit.org.
+
+        Moreover, modifies Executive.run_command to catch and pass OSError exceptions to
+        the specified error handler. For instance, the specified error handler will now
+        be called when the command does not exist (i.e. OSError errno 2).
+
+        * Scripts/modules/credentials.py: Added check for Git.
+        * Scripts/modules/credentials_unittest.py: Added test method
+        test_read_credentials_with_SVN.
+        * Scripts/modules/executive.py: Modified method run_command to catch
+        OSError exceptions (i.e [Errno 2] No such file or directory) and call
+        the specified error handler.
+        * Scripts/modules/executive_unittest.py: Added.
+        * Scripts/run-webkit-unittests: Added import executive_unittest.py.
+
+2009-12-27  Daniel Bates  <dbates at webkit.org>
+
         Unreviewed. Added missing file style_unittest.py that wasn't committed
         in change set 52541 (http://trac.webkit.org/changeset/52541) as part of
         the patch for bug #32592.
diff --git a/WebKitTools/Scripts/modules/credentials.py b/WebKitTools/Scripts/modules/credentials.py
index 2226228..55ac11a 100644
--- a/WebKitTools/Scripts/modules/credentials.py
+++ b/WebKitTools/Scripts/modules/credentials.py
@@ -30,17 +30,20 @@
 # Python module for reading stored web credentials from the OS.
 
 import getpass
+import os
 import platform
 import re
 
 from modules.executive import Executive
 from modules.logging import log
+from modules.scm import Git
 
 class Credentials(object):
-    def __init__(self, host, git_prefix=None, executive=None):
+    def __init__(self, host, git_prefix=None, executive=None, cwd=os.getcwd()):
         self.host = host
         self.git_prefix = git_prefix
         self.executive = executive or Executive()
+        self.cwd = cwd
 
     def _credentials_from_git(self):
         return [self._read_git_config("username"), self._read_git_config("password")]
@@ -78,7 +81,11 @@ class Credentials(object):
         return self._parse_security_tool_output(security_output)
 
     def read_credentials(self):
-        (username, password) = self._credentials_from_git()
+        username = None
+        password = None
+
+        if Git.in_working_directory(self.cwd):
+            (username, password) = self._credentials_from_git()
 
         if not username or not password:
             (username, password) = self._credentials_from_keychain(username)
diff --git a/WebKitTools/Scripts/modules/credentials_unittest.py b/WebKitTools/Scripts/modules/credentials_unittest.py
index 3dec4d5..e8d4f7e 100644
--- a/WebKitTools/Scripts/modules/credentials_unittest.py
+++ b/WebKitTools/Scripts/modules/credentials_unittest.py
@@ -30,6 +30,7 @@ import unittest
 from modules.credentials import Credentials
 from modules.executive import Executive
 from modules.outputcapture import OutputCapture
+from modules.scm_unittest import SVNTestRepository
 from modules.mock import Mock
 
 class CredentialsTest(unittest.TestCase):
@@ -97,6 +98,20 @@ password: "SECRETSAUCE"
         credentials._read_git_config("foo")
         executive_mock.run_command.assert_called_with(["git", "config", "--get", "test_prefix.foo"], error_handler=Executive.ignore_error)
 
+    def test_read_credentials_with_SVN(self):
+        # Note, this test assumes that SVN is installed as listed on 
+        # <http://webkit.org/building/tools.html> as of 12/27/2009.
+
+        class FakeCredentials(Credentials):
+            def _is_mac_os_x(self):
+                return True
+            def _credentials_from_keychain(self, username):
+                return ["test at webkit.org", "SECRETSAUCE"]
+
+        SVNTestRepository.setup(self)
+        credentials = FakeCredentials("bugs.webkit.org", cwd=self.svn_checkout_path)
+        self.assertEqual(credentials.read_credentials(), ["test at webkit.org", "SECRETSAUCE"])
+        SVNTestRepository.tear_down(self)
 
 if __name__ == '__main__':
     unittest.main()
diff --git a/WebKitTools/Scripts/modules/executive.py b/WebKitTools/Scripts/modules/executive.py
index 6bd3515..8f294aa 100644
--- a/WebKitTools/Scripts/modules/executive.py
+++ b/WebKitTools/Scripts/modules/executive.py
@@ -119,9 +119,15 @@ class Executive(object):
             stderr = subprocess.STDOUT
         else:
             stderr = None
-        process = subprocess.Popen(args, stdin=stdin, stdout=subprocess.PIPE, stderr=stderr, cwd=cwd)
-        output = process.communicate(string_to_communicate)[0]
-        exit_code = process.wait()
+        try:
+            process = subprocess.Popen(args, stdin=stdin, stdout=subprocess.PIPE, stderr=stderr, cwd=cwd)
+            output = process.communicate(string_to_communicate)[0]
+            exit_code = process.wait()
+        except OSError, e:
+            # Catch OSError exceptions. For example, "no such file or directory" (i.e. OSError errno 2),
+            # when the command cannot be found.
+            output = e.strerror
+            exit_code = e.errno
         if exit_code:
             script_error = ScriptError(script_args=args, exit_code=exit_code, output=output, cwd=cwd)
             (error_handler or self.default_error_handler)(script_error)
diff --git a/WebKitTools/Scripts/modules/executive_unittest.py b/WebKitTools/Scripts/modules/executive_unittest.py
new file mode 100644
index 0000000..580a2e8
--- /dev/null
+++ b/WebKitTools/Scripts/modules/executive_unittest.py
@@ -0,0 +1,48 @@
+# Copyright (C) 2009 Google Inc. All rights reserved.
+# Copyright (C) 2009 Daniel Bates (dbates at intudata.com). All rights reserved.
+#
+# 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.
+
+import unittest
+from modules.executive import Executive, ScriptError, run_command
+
+class ExecutiveTest(unittest.TestCase):
+
+    def test_run_command_with_bad_command_check_return_code(self):
+        self.assertEqual(run_command(["foo_bar_command_blah"], error_handler=Executive.ignore_error, return_exit_code=True), 2)
+
+    def test_run_command_with_bad_command_check_calls_error_handler(self):
+        self.didHandleErrorGetCalled = False
+        def handleError(scriptError):
+            self.didHandleErrorGetCalled = True
+            self.assertEqual(scriptError.exit_code, 2)
+
+        run_command(["foo_bar_command_blah"], error_handler=handleError)
+        self.assertTrue(self.didHandleErrorGetCalled)
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/WebKitTools/Scripts/run-webkit-unittests b/WebKitTools/Scripts/run-webkit-unittests
index 11f863a..8f987bc 100755
--- a/WebKitTools/Scripts/run-webkit-unittests
+++ b/WebKitTools/Scripts/run-webkit-unittests
@@ -43,6 +43,7 @@ from modules.committers_unittest import *
 from modules.credentials_unittest import *
 from modules.cpp_style_unittest import *
 from modules.diff_parser_unittest import *
+from modules.executive_unittest import *
 from modules.logging_unittest import *
 from modules.multicommandtool_unittest import *
 from modules.queueengine_unittest import *

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list