Title: [132955] trunk/Tools
Revision
132955
Author
[email protected]
Date
2012-10-30 16:17:39 -0700 (Tue, 30 Oct 2012)

Log Message

test-webkitpy: fix import of coverage so that it works in a clean install
https://bugs.webkit.org/show_bug.cgi?id=100780

Reviewed by Tony Chang.

The coverage module is written so that the parent directory needs
to be in PYTHONPATH; work around that ...

* Scripts/webkitpy/test/main_unittest.py:
(TestStubs.test_empty):
(TesterTest.test_individual_names_are_not_run_twice):
(TesterTest):
(TesterTest.integration_test_coverage_works):
* Scripts/webkitpy/thirdparty/__init__.py:
(AutoinstallImportHook._install_coverage):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (132954 => 132955)


--- trunk/Tools/ChangeLog	2012-10-30 23:17:34 UTC (rev 132954)
+++ trunk/Tools/ChangeLog	2012-10-30 23:17:39 UTC (rev 132955)
@@ -1,3 +1,21 @@
+2012-10-30  Dirk Pranke  <[email protected]>
+
+        test-webkitpy: fix import of coverage so that it works in a clean install
+        https://bugs.webkit.org/show_bug.cgi?id=100780
+
+        Reviewed by Tony Chang.
+
+        The coverage module is written so that the parent directory needs
+        to be in PYTHONPATH; work around that ...
+
+        * Scripts/webkitpy/test/main_unittest.py:
+        (TestStubs.test_empty):
+        (TesterTest.test_individual_names_are_not_run_twice):
+        (TesterTest):
+        (TesterTest.integration_test_coverage_works):
+        * Scripts/webkitpy/thirdparty/__init__.py:
+        (AutoinstallImportHook._install_coverage):
+
 2012-10-30  Anders Carlsson  <[email protected]>
 
         Another build fix.

Modified: trunk/Tools/Scripts/webkitpy/test/main_unittest.py (132954 => 132955)


--- trunk/Tools/Scripts/webkitpy/test/main_unittest.py	2012-10-30 23:17:34 UTC (rev 132954)
+++ trunk/Tools/Scripts/webkitpy/test/main_unittest.py	2012-10-30 23:17:39 UTC (rev 132955)
@@ -21,13 +21,24 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 import logging
+import sys
 import unittest
 import StringIO
 
+from webkitpy.common.system.filesystem import FileSystem
+from webkitpy.common.system.executive import Executive
 from webkitpy.common.system.outputcapture import OutputCapture
 from webkitpy.test.main import Tester, _Loader
 
 
+STUBS_CLASS = __name__ + ".TestStubs"
+
+
+class TestStubs(unittest.TestCase):
+    def test_empty(self):
+        pass
+
+
 class TesterTest(unittest.TestCase):
 
     def test_no_tests_found(self):
@@ -59,3 +70,15 @@
         parallel_tests, serial_tests = tester._test_names(_Loader(), args)
         self.assertEquals(parallel_tests, args)
         self.assertEquals(serial_tests, [])
+
+    def integration_test_coverage_works(self):
+        filesystem = FileSystem()
+        executive = Executive()
+        module_path = filesystem.path_to_module(self.__module__)
+        script_dir = module_path[0:module_path.find('webkitpy') - 1]
+        proc = executive.popen([sys.executable, filesystem.join(script_dir, 'test-webkitpy'), '-c', STUBS_CLASS + '.test_empty'],
+                               stdout=executive.PIPE, stderr=executive.PIPE)
+        out, _ = proc.communicate()
+        retcode = proc.returncode
+        self.assertEquals(retcode, 0)
+        self.assertTrue('Cover' in out)

Modified: trunk/Tools/Scripts/webkitpy/thirdparty/__init__.py (132954 => 132955)


--- trunk/Tools/Scripts/webkitpy/thirdparty/__init__.py	2012-10-30 23:17:34 UTC (rev 132954)
+++ trunk/Tools/Scripts/webkitpy/thirdparty/__init__.py	2012-10-30 23:17:39 UTC (rev 132955)
@@ -98,11 +98,11 @@
                              "pep8-0.5.0/pep8.py")
 
     def _install_pylint(self):
-        installed_something = False
+        did_install_something = False
         if not self._fs.exists(self._fs.join(_AUTOINSTALLED_DIR, "pylint")):
-            installed_something = self._install('http://pypi.python.org/packages/source/p/pylint/pylint-0.25.1.tar.gz#md5=728bbc2b339bc3749af013709a7f87a5', 'pylint-0.25.1')
+            did_install_something = self._install('http://pypi.python.org/packages/source/p/pylint/pylint-0.25.1.tar.gz#md5=728bbc2b339bc3749af013709a7f87a5', 'pylint-0.25.1')
             self._fs.move(self._fs.join(_AUTOINSTALLED_DIR, "pylint-0.25.1"), self._fs.join(_AUTOINSTALLED_DIR, "pylint"))
-        return installed_something
+        return did_install_something
 
     # autoinstalled.buildbot is used by BuildSlaveSupport/build.webkit.org-config/mastercfg_unittest.py
     # and should ideally match the version of BuildBot used at build.webkit.org.
@@ -114,21 +114,27 @@
         # without including other modules as a side effect.
         jinja_dir = self._fs.join(_AUTOINSTALLED_DIR, "jinja2")
         installer = AutoInstaller(append_to_search_path=True, target_dir=jinja_dir)
-        installed_something = installer.install(url=""
+        did_install_something = installer.install(url=""
                                                 url_subpath="Jinja2-2.6/jinja2")
 
         SQLAlchemy_dir = self._fs.join(_AUTOINSTALLED_DIR, "sqlalchemy")
         installer = AutoInstaller(append_to_search_path=True, target_dir=SQLAlchemy_dir)
-        installed_something |= installer.install(url=""
+        did_install_something |= installer.install(url=""
                                                  url_subpath="SQLAlchemy-0.7.7/lib/sqlalchemy")
 
-        installed_something |= self._install("http://pypi.python.org/packages/source/b/buildbot/buildbot-0.8.6p1.tar.gz#md5=b6727d2810c692062c657492bcbeac6a", "buildbot-0.8.6p1/buildbot")
-        return installed_something
+        did_install_something |= self._install("http://pypi.python.org/packages/source/b/buildbot/buildbot-0.8.6p1.tar.gz#md5=b6727d2810c692062c657492bcbeac6a", "buildbot-0.8.6p1/buildbot")
+        return did_install_something
 
     def _install_coverage(self):
         installer = AutoInstaller(target_dir=_AUTOINSTALLED_DIR)
-        return installer.install(url="" url_subpath="coverage-3.5.1/coverage")
+        did_install_something = installer.install(url="" url_subpath="coverage-3.5.1/coverage")
 
+        # Note that coverage needs to be under a directory already in sys.path for its
+        # internal imports to work correctly :(.
+        if not _AUTOINSTALLED_DIR in sys.path:
+            sys.path.append(_AUTOINSTALLED_DIR)
+        return did_install_something
+
     def _install_eliza(self):
         installer = AutoInstaller(target_dir=_AUTOINSTALLED_DIR)
         return installer.install(url="" target_name="eliza.py")
@@ -139,22 +145,22 @@
         # organization purposes.
         irc_dir = self._fs.join(_AUTOINSTALLED_DIR, "irc")
         installer = AutoInstaller(target_dir=irc_dir)
-        installed_something = installer.install(url=""
+        did_install_something = installer.install(url=""
                                                 url_subpath="irclib.py")
-        installed_something |= installer.install(url=""
+        did_install_something |= installer.install(url=""
                           url_subpath="ircbot.py")
-        return installed_something
+        return did_install_something
 
     def _install_webpagereplay(self):
-        installed_something = False
+        did_install_something = False
         if not self._fs.exists(self._fs.join(_AUTOINSTALLED_DIR, "webpagereplay")):
-            installed_something = self._install("http://web-page-replay.googlecode.com/files/webpagereplay-1.1.2.tar.gz", "webpagereplay-1.1.2")
+            did_install_something = self._install("http://web-page-replay.googlecode.com/files/webpagereplay-1.1.2.tar.gz", "webpagereplay-1.1.2")
             self._fs.move(self._fs.join(_AUTOINSTALLED_DIR, "webpagereplay-1.1.2"), self._fs.join(_AUTOINSTALLED_DIR, "webpagereplay"))
 
         init_path = self._fs.join(_AUTOINSTALLED_DIR, "webpagereplay", "__init__.py")
         if not self._fs.exists(init_path):
             self._fs.write_text_file(init_path, "")
-        return installed_something
+        return did_install_something
 
     def _install(self, url, url_subpath):
         installer = AutoInstaller(target_dir=_AUTOINSTALLED_DIR)
@@ -167,7 +173,7 @@
 
 def autoinstall_everything():
     install_methods = [method for method in dir(_hook.__class__) if method.startswith('_install_')]
-    installed_something = False
+    did_install_something = False
     for method in install_methods:
-        installed_something |= getattr(_hook, method)()
-    return installed_something
+        did_install_something |= getattr(_hook, method)()
+    return did_install_something
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to