[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

dpranke at chromium.org dpranke at chromium.org
Wed Dec 22 12:15:55 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit ebd690cc3eeb0d0e0159b6aa196a23e3279c31f8
Author: dpranke at chromium.org <dpranke at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Aug 17 23:11:25 2010 +0000

    2010-08-17  Dirk Pranke  <dpranke at chromium.org>
    
            Reviewed by Eric Seidel.
    
            fix test-webkitpy, add easy way to find a checkout root
    
            test-webkitpy currently doesn't work right if run from someplace other
            than the checkout root, and it spews a bunch of debug logging because
            the deduplicate_tests tests contaminates the test environment.
    
            This patch cleans up the deduplicate_tests unit tests, and creates
            two new methods in scm.py: find_checkout_root() and default_scm(),
            both of which use a single algorithm for guessing what checkout root
            to use if you aren't explicitly told one from a path.
    
            https://bugs.webkit.org/show_bug.cgi?id=44001
    
            * Scripts/deduplicate-tests:
            * Scripts/webkitpy/common/checkout/scm.py:
            * Scripts/webkitpy/common/checkout/scm_unittest.py:
            * Scripts/webkitpy/layout_tests/deduplicate_tests.py:
            * Scripts/webkitpy/layout_tests/deduplicate_tests_unittest.py:
            * Scripts/webkitpy/layout_tests/port/test.py:
            * Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests.py:
            * Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests_unittest.py:
            * Scripts/webkitpy/tool/main.py:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65572 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 4a30149..0bc80e5 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,30 @@
+2010-08-17  Dirk Pranke  <dpranke at chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        fix test-webkitpy, add easy way to find a checkout root
+
+        test-webkitpy currently doesn't work right if run from someplace other
+        than the checkout root, and it spews a bunch of debug logging because
+        the deduplicate_tests tests contaminates the test environment.
+
+        This patch cleans up the deduplicate_tests unit tests, and creates
+        two new methods in scm.py: find_checkout_root() and default_scm(),
+        both of which use a single algorithm for guessing what checkout root
+        to use if you aren't explicitly told one from a path.
+
+        https://bugs.webkit.org/show_bug.cgi?id=44001
+
+        * Scripts/deduplicate-tests:
+        * Scripts/webkitpy/common/checkout/scm.py:
+        * Scripts/webkitpy/common/checkout/scm_unittest.py:
+        * Scripts/webkitpy/layout_tests/deduplicate_tests.py:
+        * Scripts/webkitpy/layout_tests/deduplicate_tests_unittest.py:
+        * Scripts/webkitpy/layout_tests/port/test.py:
+        * Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests.py:
+        * Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests_unittest.py:
+        * Scripts/webkitpy/tool/main.py:
+
 2010-08-17  Victor Wang  <victorw at chromium.org>
 
         Reviewed by Ojan Vafai.
diff --git a/WebKitTools/Scripts/deduplicate-tests b/WebKitTools/Scripts/deduplicate-tests
index 11ba7c2..f0afe13 100644
--- a/WebKitTools/Scripts/deduplicate-tests
+++ b/WebKitTools/Scripts/deduplicate-tests
@@ -36,6 +36,7 @@ This command dumps out all such files.  You can use it like this:
 
 
 import optparse
+import webkitpy.common.system.logutils as logutils
 import webkitpy.layout_tests.deduplicate_tests as deduplicate_tests
 
 
@@ -62,6 +63,7 @@ def parse_args():
 
 
 def run(options):
+    logutils.configure_logging()
     if options.verbose:
         format = ("* %(test)s\n"
                   "\tredundantly on %(platform)s and %(fallback)s\n"
diff --git a/WebKitTools/Scripts/webkitpy/common/checkout/scm.py b/WebKitTools/Scripts/webkitpy/common/checkout/scm.py
index 569558a..5a6c48c 100644
--- a/WebKitTools/Scripts/webkitpy/common/checkout/scm.py
+++ b/WebKitTools/Scripts/webkitpy/common/checkout/scm.py
@@ -38,6 +38,40 @@ from webkitpy.common.system.executive import Executive, run_command, ScriptError
 from webkitpy.common.system.deprecated_logging import error, log
 
 
+def find_checkout_root():
+    """Returns the current checkout root (as determined by default_scm().
+
+    Returns the absolute path to the top of the WebKit checkout, or None
+    if it cannot be determined.
+
+    """
+    scm_system = default_scm()
+    if scm_system:
+        return scm_system.checkout_root
+    return None
+
+
+def default_scm():
+    """Return the default SCM object as determined by the CWD and running code.
+
+    Returns the default SCM object for the current working directory; if the
+    CWD is not in a checkout, then we attempt to figure out if the SCM module
+    itself is part of a checkout, and return that one. If neither is part of
+    a checkout, None is returned.
+
+    """
+    cwd = os.getcwd()
+    scm_system = detect_scm_system(cwd)
+    if not scm_system:
+        script_directory = os.path.abspath(sys.path[0])
+        scm_system = detect_scm_system(script_directory)
+        if scm_system:
+            log("The current directory (%s) is not a WebKit checkout, using %s" % (cwd, scm_system.checkout_root))
+        else:
+            error("FATAL: Failed to determine the SCM system for either %s or %s" % (cwd, script_directory))
+    return scm_system
+
+
 def detect_scm_system(path):
     absolute_path = os.path.abspath(path)
 
diff --git a/WebKitTools/Scripts/webkitpy/common/checkout/scm_unittest.py b/WebKitTools/Scripts/webkitpy/common/checkout/scm_unittest.py
index 852f838..87d5539 100644
--- a/WebKitTools/Scripts/webkitpy/common/checkout/scm_unittest.py
+++ b/WebKitTools/Scripts/webkitpy/common/checkout/scm_unittest.py
@@ -36,6 +36,7 @@ import os
 import os.path
 import re
 import stat
+import sys
 import subprocess
 import tempfile
 import unittest
@@ -44,10 +45,11 @@ import shutil
 
 from datetime import date
 from webkitpy.common.checkout.api import Checkout
-from webkitpy.common.checkout.scm import detect_scm_system, SCM, SVN, CheckoutNeedsUpdate, commit_error_handler, AuthenticationError, AmbiguousCommitError
+from webkitpy.common.checkout.scm import detect_scm_system, SCM, SVN, CheckoutNeedsUpdate, commit_error_handler, AuthenticationError, AmbiguousCommitError, find_checkout_root, default_scm
 from webkitpy.common.config.committers import Committer  # FIXME: This should not be needed
 from webkitpy.common.net.bugzilla import Attachment # FIXME: This should not be needed
 from webkitpy.common.system.executive import Executive, run_command, ScriptError
+from webkitpy.common.system.outputcapture import OutputCapture
 
 # Eventually we will want to write tests which work for both scms. (like update_webkit, changed_files, etc.)
 # Perhaps through some SCMTest base-class which both SVNTest and GitTest inherit from.
@@ -174,6 +176,57 @@ class SVNTestRepository:
         # Change back to a valid directory so that later calls to os.getcwd() do not fail.
         os.chdir(detect_scm_system(os.path.dirname(__file__)).checkout_root)
 
+
+class StandaloneFunctionsTest(unittest.TestCase):
+    """This class tests any standalone/top-level functions in the package."""
+    def setUp(self):
+        self.orig_cwd = os.path.abspath(os.getcwd())
+        self.orig_abspath = os.path.abspath
+
+        # We capture but ignore the output from stderr to reduce unwanted
+        # logging.
+        self.output = OutputCapture()
+        self.output.capture_output()
+
+    def tearDown(self):
+        os.chdir(self.orig_cwd)
+        os.path.abspath = self.orig_abspath
+        self.output.restore_output()
+
+    def test_find_checkout_root(self):
+        # Test from inside the tree.
+        os.chdir(sys.path[0])
+        dir = find_checkout_root()
+        self.assertNotEqual(dir, None)
+        self.assertTrue(os.path.exists(dir))
+
+        # Test from outside the tree.
+        os.chdir(os.path.expanduser("~"))
+        dir = find_checkout_root()
+        self.assertNotEqual(dir, None)
+        self.assertTrue(os.path.exists(dir))
+
+        # Mock out abspath() to test being not in a checkout at all.
+        os.path.abspath = lambda x: "/"
+        self.assertRaises(SystemExit, find_checkout_root)
+        os.path.abspath = self.orig_abspath
+
+    def test_default_scm(self):
+        # Test from inside the tree.
+        os.chdir(sys.path[0])
+        scm = default_scm()
+        self.assertNotEqual(scm, None)
+
+        # Test from outside the tree.
+        os.chdir(os.path.expanduser("~"))
+        dir = find_checkout_root()
+        self.assertNotEqual(dir, None)
+
+        # Mock out abspath() to test being not in a checkout at all.
+        os.path.abspath = lambda x: "/"
+        self.assertRaises(SystemExit, default_scm)
+        os.path.abspath = self.orig_abspath
+
 # For testing the SCM baseclass directly.
 class SCMClassTests(unittest.TestCase):
     def setUp(self):
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/deduplicate_tests.py b/WebKitTools/Scripts/webkitpy/layout_tests/deduplicate_tests.py
index 7a9cdae..bb63f5e 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/deduplicate_tests.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/deduplicate_tests.py
@@ -41,7 +41,6 @@ import webkitpy.common.system.logutils as logutils
 import webkitpy.layout_tests.port.factory as port_factory
 
 _log = logutils.get_logger(__file__)
-logutils.configure_logging()
 
 _BASE_PLATFORM = 'base'
 
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/deduplicate_tests_unittest.py b/WebKitTools/Scripts/webkitpy/layout_tests/deduplicate_tests_unittest.py
index 878331a..66dda32 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/deduplicate_tests_unittest.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/deduplicate_tests_unittest.py
@@ -27,6 +27,7 @@
 import deduplicate_tests
 import os
 import unittest
+import webkitpy.common.checkout.scm as scm
 
 
 class MockExecutive(object):
@@ -51,6 +52,13 @@ class ListDuplicatesTest(unittest.TestCase):
         MockExecutive.last_run_command = []
         MockExecutive.response = ''
         deduplicate_tests.executive = MockExecutive
+        self._original_cwd = os.getcwd()
+        checkout_root = scm.find_checkout_root()
+        self.assertNotEqual(checkout_root, None)
+        os.chdir(checkout_root)
+
+    def tearDown(self):
+        os.chdir(self._original_cwd)
 
     def test_parse_git_output(self):
         git_output = (
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/port/test.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/test.py
index 6eef54e..9c9ab0a 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/port/test.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/test.py
@@ -124,6 +124,9 @@ class TestPort(base.Port):
     def test_platform_names(self):
         return self.test_base_platform_names()
 
+    def test_platform_name_to_name(self, test_platform_name):
+        return test_platform_name
+
     def version():
         return ''
 
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests.py b/WebKitTools/Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests.py
index fa4df9b..92f1032 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests.py
@@ -59,7 +59,6 @@ import webbrowser
 import zipfile
 
 from webkitpy.common.system.executive import run_command, ScriptError
-from webkitpy.common.checkout.scm import detect_scm_system
 import webkitpy.common.checkout.scm as scm
 
 import port
@@ -240,7 +239,7 @@ class Rebaseliner(object):
                                                self._platform,
                                                False,
                                                False)
-        self._scm = detect_scm_system(os.getcwd())
+        self._scm = scm.default_scm()
 
     def run(self, backup):
         """Run rebaseline process."""
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests_unittest.py b/WebKitTools/Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests_unittest.py
index fa03238..121b64e 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests_unittest.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests_unittest.py
@@ -84,5 +84,19 @@ class TestGetHostPortObject(unittest.TestCase):
         port.get = old_get
 
 
+class TestRebaseliner(unittest.TestCase):
+
+    def test_noop(self):
+        # this method tests that was can at least instantiate an object, even
+        # if there is nothing to do.
+        options = MockOptions()
+        host_port_obj = port.get('test', options)
+        target_options = options
+        target_port_obj = port.get('test', target_options)
+        platform = 'test'
+        rebaseliner = rebaseline_chromium_webkit_tests.Rebaseliner(
+            host_port_obj, target_port_obj, platform, options)
+        self.assertNotEqual(rebaseliner, None)
+
 if __name__ == '__main__':
     unittest.main()
diff --git a/WebKitTools/Scripts/webkitpy/tool/main.py b/WebKitTools/Scripts/webkitpy/tool/main.py
index 1f43145..0dd5017 100755
--- a/WebKitTools/Scripts/webkitpy/tool/main.py
+++ b/WebKitTools/Scripts/webkitpy/tool/main.py
@@ -33,7 +33,7 @@ import os
 import threading
 
 from webkitpy.common.checkout.api import Checkout
-from webkitpy.common.checkout.scm import detect_scm_system
+from webkitpy.common.checkout.scm import default_scm
 from webkitpy.common.net.bugzilla import Bugzilla
 from webkitpy.common.net.buildbot import BuildBot
 from webkitpy.common.net.rietveld import Rietveld
@@ -79,18 +79,8 @@ class WebKitPatch(MultiCommandTool):
 
     def scm(self):
         # Lazily initialize SCM to not error-out before command line parsing (or when running non-scm commands).
-        original_cwd = os.path.abspath(".")
         if not self._scm:
-            self._scm = detect_scm_system(original_cwd)
-
-        if not self._scm:
-            script_directory = os.path.abspath(sys.path[0])
-            self._scm = detect_scm_system(script_directory)
-            if self._scm:
-                log("The current directory (%s) is not a WebKit checkout, using %s" % (original_cwd, self._scm.checkout_root))
-            else:
-                error("FATAL: Failed to determine the SCM system for either %s or %s" % (original_cwd, script_directory))
-
+            self._scm = default_scm()
         return self._scm
 
     def checkout(self):

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list