Title: [100689] trunk/Tools
Revision
100689
Author
e...@webkit.org
Date
2011-11-17 15:22:42 -0800 (Thu, 17 Nov 2011)

Log Message

Give check-webkit-style a Host
https://bugs.webkit.org/show_bug.cgi?id=72670

Reviewed by Adam Barth.

* Scripts/webkitpy/common/checkout/scm/detection.py:
* Scripts/webkitpy/common/checkout/scm/scm_unittest.py:
 - We don't run these unittests, but this one was looking for the wrong exception.
* Scripts/webkitpy/style/main.py:
* Scripts/webkitpy/to_be_moved/rebaseline_chromium_webkit_tests.py:
 - This was create a new scm object even though it already had one?

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (100688 => 100689)


--- trunk/Tools/ChangeLog	2011-11-17 23:22:38 UTC (rev 100688)
+++ trunk/Tools/ChangeLog	2011-11-17 23:22:42 UTC (rev 100689)
@@ -1,5 +1,19 @@
 2011-11-17  Eric Seidel  <e...@webkit.org>
 
+        Give check-webkit-style a Host
+        https://bugs.webkit.org/show_bug.cgi?id=72670
+
+        Reviewed by Adam Barth.
+
+        * Scripts/webkitpy/common/checkout/scm/detection.py:
+        * Scripts/webkitpy/common/checkout/scm/scm_unittest.py:
+         - We don't run these unittests, but this one was looking for the wrong exception.
+        * Scripts/webkitpy/style/main.py:
+        * Scripts/webkitpy/to_be_moved/rebaseline_chromium_webkit_tests.py:
+         - This was create a new scm object even though it already had one?
+
+2011-11-17  Eric Seidel  <e...@webkit.org>
+
         Move check-webkit-style change_directory code to more modern mocks
         https://bugs.webkit.org/show_bug.cgi?id=72664
 

Modified: trunk/Tools/Scripts/webkitpy/common/checkout/scm/detection.py (100688 => 100689)


--- trunk/Tools/Scripts/webkitpy/common/checkout/scm/detection.py	2011-11-17 23:22:38 UTC (rev 100688)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/scm/detection.py	2011-11-17 23:22:42 UTC (rev 100689)
@@ -48,7 +48,6 @@
         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 = self._filesystem.getcwd()
         scm_system = self.detect_scm_system(cwd, patch_directories)

Modified: trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py (100688 => 100689)


--- trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py	2011-11-17 23:22:38 UTC (rev 100688)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py	2011-11-17 23:22:42 UTC (rev 100689)
@@ -281,7 +281,7 @@
 
         # Mock out abspath() to test being not in a checkout at all.
         os.path.abspath = lambda x: "/"
-        self.assertRaises(SystemExit, default_scm)
+        self.assertRaises(Exception, default_scm)
         os.path.abspath = self.orig_abspath
 
 

Modified: trunk/Tools/Scripts/webkitpy/style/main.py (100688 => 100689)


--- trunk/Tools/Scripts/webkitpy/style/main.py	2011-11-17 23:22:38 UTC (rev 100688)
+++ trunk/Tools/Scripts/webkitpy/style/main.py	2011-11-17 23:22:42 UTC (rev 100689)
@@ -29,7 +29,7 @@
 from webkitpy.style.patchreader import PatchReader
 from webkitpy.style.checker import StyleProcessor
 from webkitpy.style.filereader import TextFileReader
-from webkitpy.common.system.filesystem import FileSystem
+from webkitpy.common.host import Host
 
 
 _log = logging.getLogger(__name__)
@@ -133,11 +133,7 @@
 
 
 class CheckWebKitStyle(object):
-    # FIXME: This function is huge and needs to be split up.
-    def main(self):
-        # FIXME: We should get our FileSystem from a Host object.
-        filesystem = FileSystem()
-
+    def _engage_awesome_stderr_hacks(self):
         # Change stderr to write with replacement characters so we don't die
         # if we try to print something containing non-ASCII characters.
         stderr = codecs.StreamReaderWriter(sys.stderr,
@@ -154,9 +150,19 @@
         #        accept a stream parameter where necessary, and not calling
         #        sys.stderr explicitly anywhere.
         sys.stderr = stderr
+        return stderr
 
+    def main(self):
         args = sys.argv[1:]
 
+        host = Host()
+        # FIXME: Intentionally not calling host._initialize_scm() for now.
+        # _initialize_scm() would throw an exception if it failed to find the checkout_root.
+        # check-webkit-style seems designed to be run from outside a webkit checkout.
+        # Unclear if that's still a needed feature.
+
+        stderr = self._engage_awesome_stderr_hacks()
+
         # Checking for the verbose flag before calling check_webkit_style_parser()
         # lets us enable verbose logging earlier.
         is_verbose = "-v" in args or "--verbose" in args
@@ -167,9 +173,7 @@
         parser = checker.check_webkit_style_parser()
         (paths, options) = parser.parse(args)
 
-        cwd = filesystem.abspath(filesystem.getcwd())
-        scm = detect_scm_system(cwd)
-
+        scm = detect_scm_system(host.filesystem.getcwd())
         if scm is None:
             if not paths:
                 _log.error("WebKit checkout not found: You must run this script "
@@ -185,7 +189,7 @@
 
         configuration = checker.check_webkit_style_configuration(options)
 
-        paths = change_directory(filesystem, checkout_root=checkout_root, paths=paths)
+        paths = change_directory(host.filesystem, checkout_root=checkout_root, paths=paths)
 
         style_processor = StyleProcessor(configuration)
         file_reader = TextFileReader(style_processor)

Modified: trunk/Tools/Scripts/webkitpy/to_be_moved/rebaseline_chromium_webkit_tests.py (100688 => 100689)


--- trunk/Tools/Scripts/webkitpy/to_be_moved/rebaseline_chromium_webkit_tests.py	2011-11-17 23:22:38 UTC (rev 100688)
+++ trunk/Tools/Scripts/webkitpy/to_be_moved/rebaseline_chromium_webkit_tests.py	2011-11-17 23:22:42 UTC (rev 100689)
@@ -951,15 +951,14 @@
         return 1
 
     url_fetcher = urlfetcher.UrlFetcher(host_port_obj._filesystem)
-    scm_obj = scm.default_scm()
 
     # We use the default zip factory method.
     zip_factory = None
 
     # FIXME: SCM module doesn't handle paths that aren't relative to the checkout_root consistently.
-    host_port_obj._filesystem.chdir(scm_obj.checkout_root)
+    host_port_obj._filesystem.chdir(host.scm().checkout_root)
 
-    ret_code = real_main(options, target_options, host_port_obj, target_port_obj, url_fetcher, zip_factory, scm_obj)
+    ret_code = real_main(options, target_options, host_port_obj, target_port_obj, url_fetcher, zip_factory, host.scm())
     if not ret_code and log_handler.num_failures:
         ret_code = 1
     print ''
@@ -970,8 +969,7 @@
     return ret_code
 
 
-def real_main(options, target_options, host_port_obj, target_port_obj, url_fetcher,
-              zip_factory, scm_obj):
+def real_main(options, target_options, host_port_obj, target_port_obj, url_fetcher, zip_factory, scm_obj):
     """Main function to produce new baselines. The Rebaseliner object uses two
     different Port objects - one to represent the machine the object is running
     on, and one to represent the port whose expectations are being updated.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to