Title: [150380] trunk/Tools
Revision
150380
Author
dpra...@chromium.org
Date
2013-05-20 13:42:39 -0700 (Mon, 20 May 2013)

Log Message

fix w3c test importer unit tests after r150324
https://bugs.webkit.org/show_bug.cgi?id=116459

Reviewed by Ryosuke Niwa.

This patch fixes the unit tests to not actually call out to
'hg' (by using a mock executive) and also changes the real
directory we crawl from Source/WebCore/css to
Tools/Scripts/webkitpy/w3c to run much more quickly. We should
still change this to a mock filesystem, but that's a separate change.

* Scripts/webkitpy/w3c/test_importer.py:
(main):
(TestImporter.__init__):
(TestImporter.load_changeset):
* Scripts/webkitpy/w3c/test_importer_unittest.py:
(TestImporterTest.test_import_dir_with_no_tests_and_no_hg):
(TestImporterTest.test_import_dir_with_no_tests):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (150379 => 150380)


--- trunk/Tools/ChangeLog	2013-05-20 20:34:19 UTC (rev 150379)
+++ trunk/Tools/ChangeLog	2013-05-20 20:42:39 UTC (rev 150380)
@@ -1,3 +1,24 @@
+2013-05-20  Dirk Pranke  <dpra...@chromium.org>
+
+        fix w3c test importer unit tests after r150324
+        https://bugs.webkit.org/show_bug.cgi?id=116459
+
+        Reviewed by Ryosuke Niwa.
+
+        This patch fixes the unit tests to not actually call out to
+        'hg' (by using a mock executive) and also changes the real
+        directory we crawl from Source/WebCore/css to
+        Tools/Scripts/webkitpy/w3c to run much more quickly. We should
+        still change this to a mock filesystem, but that's a separate change.
+
+        * Scripts/webkitpy/w3c/test_importer.py:
+        (main):
+        (TestImporter.__init__):
+        (TestImporter.load_changeset):
+        * Scripts/webkitpy/w3c/test_importer_unittest.py:
+        (TestImporterTest.test_import_dir_with_no_tests_and_no_hg):
+        (TestImporterTest.test_import_dir_with_no_tests):
+
 2013-05-20  Christophe Dumez  <ch.du...@sisa.samsung.com>
 
         Unreviewed EFL build fix.

Modified: trunk/Tools/Scripts/webkitpy/w3c/test_importer.py (150379 => 150380)


--- trunk/Tools/Scripts/webkitpy/w3c/test_importer.py	2013-05-20 20:34:19 UTC (rev 150379)
+++ trunk/Tools/Scripts/webkitpy/w3c/test_importer.py	2013-05-20 20:42:39 UTC (rev 150380)
@@ -112,7 +112,7 @@
 def main(_argv, _stdout, _stderr):
     options, args = parse_args()
     import_dir = validate_import_directory(args[0])
-    test_importer = TestImporter(import_dir, options)
+    test_importer = TestImporter(Host(), import_dir, options)
     test_importer.do_import()
 
 
@@ -147,14 +147,14 @@
 
 class TestImporter(object):
 
-    def __init__(self, source_directory, options):
+    def __init__(self, host, source_directory, options):
+        self.host = host
+        self.source_directory = source_directory
         self.options = options
 
-        self.host = Host()
         self.filesystem = self.host.filesystem
         self._webkit_root = __file__.split(self.filesystem.sep + 'Tools')[0]
 
-        self.source_directory = source_directory
         self.destination_directory = self.path_from_webkit_root("LayoutTests", "csswg")
 
         self.changeset = CHANGESET_NOT_AVAILABLE
@@ -171,12 +171,10 @@
         self.import_tests()
 
     def load_changeset(self):
-        """ Runs hg tip to get the current changeset and parses the output to get the changeset. If that doesn't workout for some reason, it just becomes 'Not Available' """
-
+        """Returns the current changeset from mercurial or "Not Available"."""
         try:
-            # Try to find the changeset using mercurial, but fail gracefully as we don't want to require it to be installed.
             self.changeset = self.host.executive.run_command(['hg', 'tip']).split('changeset:')[1]
-        except ScriptError:
+        except (OSError, ScriptError):
             self.changeset = CHANGESET_NOT_AVAILABLE
 
     def find_importable_tests(self, directory):

Modified: trunk/Tools/Scripts/webkitpy/w3c/test_importer_unittest.py (150379 => 150380)


--- trunk/Tools/Scripts/webkitpy/w3c/test_importer_unittest.py	2013-05-20 20:34:19 UTC (rev 150379)
+++ trunk/Tools/Scripts/webkitpy/w3c/test_importer_unittest.py	2013-05-20 20:42:39 UTC (rev 150380)
@@ -32,19 +32,38 @@
 import tempfile
 import unittest2 as unittest
 
+from webkitpy.common.host import Host
+from webkitpy.common.system.executive_mock import MockExecutive2, ScriptError
 from webkitpy.common.system.outputcapture import OutputCapture
 from webkitpy.w3c.test_importer import TestImporter
 
 
-@unittest.skip
 class TestImporterTest(unittest.TestCase):
 
-    # FIXME: This test tries to run hg.
+    def test_import_dir_with_no_tests_and_no_hg(self):
+        # FIXME: Use MockHosts instead.
+        host = Host()
+        host.executive = MockExecutive2(exception=OSError())
+
+        importer = TestImporter(host, None, optparse.Values({"overwrite": False}))
+        importer.source_directory = importer.path_from_webkit_root("Tools", "Scripts", "webkitpy", "w3c")
+        importer.destination_directory = tempfile.mkdtemp(prefix='csswg')
+
+        oc = OutputCapture()
+        oc.capture_output()
+        try:
+            importer.do_import()
+        finally:
+            oc.restore_output()
+            shutil.rmtree(importer.destination_directory, ignore_errors=True)
+
     def test_import_dir_with_no_tests(self):
-        """ Tests do_import() with a directory that contains no tests """
+        # FIXME: Use MockHosts instead.
+        host = Host()
+        host.executive = MockExecutive2(exception=ScriptError("abort: no repository found in '/Volumes/Source/src/wk/Tools/Scripts/webkitpy/w3c' (.hg not found)!"))
 
-        importer = TestImporter(None, optparse.Values({"overwrite": False}))
-        importer.source_directory = importer.path_from_webkit_root("Source", "WebCore", "css")
+        importer = TestImporter(host, None, optparse.Values({"overwrite": False}))
+        importer.source_directory = importer.path_from_webkit_root("Tools", "Scripts", "webkitpy", "w3c")
         importer.destination_directory = tempfile.mkdtemp(prefix='csswg')
 
         oc = OutputCapture()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to