Title: [123538] trunk/Tools
Revision
123538
Author
[email protected]
Date
2012-07-24 15:20:10 -0700 (Tue, 24 Jul 2012)

Log Message

make test-webkitpy at least kinda work in parallel on win32
https://bugs.webkit.org/show_bug.cgi?id=91700

Reviewed by Adam Barth.

This change makes the hoop-jumping we have to do to make running
new-run-webkit-tests in parallel on win32 generic so that we can
re-use it for test-webkitpy as well.

* Scripts/new-run-webkit-tests:
* Scripts/test-webkitpy:
* Scripts/webkitpy/common/multiprocessing_bootstrap.py: Copied from Tools/Scripts/new-run-webkit-tests.
(run):
* Scripts/webkitpy/test/main.py:
(main):
(Tester._log_exception):

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (123537 => 123538)


--- trunk/Tools/ChangeLog	2012-07-24 22:19:44 UTC (rev 123537)
+++ trunk/Tools/ChangeLog	2012-07-24 22:20:10 UTC (rev 123538)
@@ -1,3 +1,22 @@
+2012-07-24  Dirk Pranke  <[email protected]>
+
+        make test-webkitpy at least kinda work in parallel on win32
+        https://bugs.webkit.org/show_bug.cgi?id=91700
+
+        Reviewed by Adam Barth.
+
+        This change makes the hoop-jumping we have to do to make running
+        new-run-webkit-tests in parallel on win32 generic so that we can
+        re-use it for test-webkitpy as well.
+
+        * Scripts/new-run-webkit-tests:
+        * Scripts/test-webkitpy:
+        * Scripts/webkitpy/common/multiprocessing_bootstrap.py: Copied from Tools/Scripts/new-run-webkit-tests.
+        (run):
+        * Scripts/webkitpy/test/main.py:
+        (main):
+        (Tester._log_exception):
+
 2012-07-24  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r123499.

Modified: trunk/Tools/Scripts/new-run-webkit-tests (123537 => 123538)


--- trunk/Tools/Scripts/new-run-webkit-tests	2012-07-24 22:19:44 UTC (rev 123537)
+++ trunk/Tools/Scripts/new-run-webkit-tests	2012-07-24 22:20:10 UTC (rev 123538)
@@ -28,39 +28,6 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 """Wrapper around webkitpy/layout_tests/run_webkit_tests.py"""
-import os
-import signal
-import subprocess
-import sys
+from webkitpy.common import multiprocessing_bootstrap
 
-import webkitpy.common.version_check
-
-if __name__ == '__main__':
-    # In order for the multiprocessing module to spawn children correctly on
-    # Windows, we need to be running a Python module that can be imported
-    # (which means a file in sys.path that ends in .py). We also make surei
-    # that sys.path / PYTHONPATH is set and propagating correctly.
-    script_dir = os.path.dirname(os.path.abspath(__file__))
-    env = os.environ
-    if env.has_key('PYTHONPATH'):
-        if script_dir not in env['PYTHONPATH']:
-            env['PYTHONPATH'] = env['PYTHONPATH'] + os.pathsep + script_dir
-    else:
-        env['PYTHONPATH'] = script_dir
-    module_path = os.path.join(script_dir, 'webkitpy', 'layout_tests', 'run_webkit_tests.py')
-    cmd = [sys.executable, module_path] + sys.argv[1:]
-
-    # Wrap the NRWT process in the jhbuild environment so DRT or WKTR
-    # doesn't need to do it and their process id as reported by
-    # subprocess.Popen is not jhbuild's.
-    if '--gtk' in sys.argv[1:] and os.path.exists(os.path.join(script_dir, '..', '..', 'WebKitBuild', 'Dependencies')):
-        cmd.insert(1, os.path.join(script_dir, '..', 'gtk', 'run-with-jhbuild'))
-
-    proc = subprocess.Popen(cmd, env=env)
-    try:
-        proc.wait()
-    except KeyboardInterrupt:
-        # We need a second wait in order to make sure the subprocess exits fully.
-        # FIXME: It would be nice if we could put a timeout on this.
-        proc.wait()
-    sys.exit(proc.returncode)
+multiprocessing_bootstrap.run('webkitpy', 'layout_tests', 'run_webkit_tests.py')

Modified: trunk/Tools/Scripts/test-webkitpy (123537 => 123538)


--- trunk/Tools/Scripts/test-webkitpy	2012-07-24 22:19:44 UTC (rev 123537)
+++ trunk/Tools/Scripts/test-webkitpy	2012-07-24 22:20:10 UTC (rev 123538)
@@ -27,38 +27,6 @@
 # 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.
+from webkitpy.common import multiprocessing_bootstrap
 
-import logging
-import os
-import sys
-
-# NOTE: We intentionally limit imports from webkitpy here to minimize the
-# chances of breaking test-webkitpy itself.
-from webkitpy.common import version_check
-from webkitpy.test import main
-
-
-_log = logging.getLogger("test-webkitpy")
-
-
-if __name__ == "__main__":
-    webkit_root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-
-    tester = main.Tester()
-    tester.add_tree(os.path.join(webkit_root, 'Tools', 'Scripts'), 'webkitpy')
-    tester.add_tree(os.path.join(webkit_root, 'Source', 'WebKit2', 'Scripts'), 'webkit2')
-
-    # FIXME: Do we need to be able to test QueueStatusServer on Windows as well?
-    appengine_sdk_path = '/usr/local/google_appengine'
-    if os.path.exists(appengine_sdk_path):
-        if not appengine_sdk_path in sys.path:
-            sys.path.append(appengine_sdk_path)
-        import dev_appserver
-        from google.appengine.dist import use_library
-        use_library('django', '1.2')
-        dev_appserver.fix_sys_path()
-        tester.add_tree(os.path.join(webkit_root, 'Tools', 'QueueStatusServer'))
-    else:
-        _log.info('Skipping QueueStatusServer tests; the Google AppEngine Python SDK is not installed.')
-
-    sys.exit(not tester.run())
+multiprocessing_bootstrap.run('webkitpy', 'test', 'main.py')

Copied: trunk/Tools/Scripts/webkitpy/common/multiprocessing_bootstrap.py (from rev 123536, trunk/Tools/Scripts/new-run-webkit-tests) (0 => 123538)


--- trunk/Tools/Scripts/webkitpy/common/multiprocessing_bootstrap.py	                        (rev 0)
+++ trunk/Tools/Scripts/webkitpy/common/multiprocessing_bootstrap.py	2012-07-24 22:20:10 UTC (rev 123538)
@@ -0,0 +1,70 @@
+#!/usr/bin/env python
+# Copyright (c) 2011 Google Inc. All rights reserved.
+# Copyright (C) 2010 Chris Jerdonek ([email protected])
+#
+# 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.
+
+"""In order for the multiprocessing module to spawn children correctly on
+Windows, we need to be running a Python module that can be imported
+(which means a file in sys.path that ends in .py). In addition, we need to
+ensure that sys.path / PYTHONPATH is set and propagating correctly.
+
+This module enforces that."""
+
+import os
+import subprocess
+import sys
+
+from webkitpy.common import version_check   # 'unused import' pylint: disable=W0611
+
+
+def run(*parts):
+    up = os.path.dirname
+    script_dir = up(up(up(os.path.abspath(__file__))))
+    env = os.environ
+    if 'PYTHONPATH' in env:
+        if script_dir not in env['PYTHONPATH']:
+            env['PYTHONPATH'] = env['PYTHONPATH'] + os.pathsep + script_dir
+    else:
+        env['PYTHONPATH'] = script_dir
+    module_path = os.path.join(script_dir, *parts)
+    cmd = [sys.executable, module_path] + sys.argv[1:]
+
+    # Wrap processes in the jhbuild environment so DRT or WKTR
+    # doesn't need to do it and their process id as reported by
+    # subprocess.Popen is not jhbuild's.
+    if '--gtk' in sys.argv[1:] and os.path.exists(os.path.join(script_dir, '..', '..', 'WebKitBuild', 'Dependencies')):
+        cmd.insert(1, os.path.join(script_dir, '..', 'gtk', 'run-with-jhbuild'))
+
+    proc = subprocess.Popen(cmd, env=env)
+    try:
+        proc.wait()
+    except KeyboardInterrupt:
+        # We need a second wait in order to make sure the subprocess exits fully.
+        # FIXME: It would be nice if we could put a timeout on this.
+        proc.wait()
+    sys.exit(proc.returncode)

Modified: trunk/Tools/Scripts/webkitpy/test/main.py (123537 => 123538)


--- trunk/Tools/Scripts/webkitpy/test/main.py	2012-07-24 22:19:44 UTC (rev 123537)
+++ trunk/Tools/Scripts/webkitpy/test/main.py	2012-07-24 22:20:10 UTC (rev 123538)
@@ -26,6 +26,7 @@
 import logging
 import multiprocessing
 import optparse
+import os
 import StringIO
 import sys
 import traceback
@@ -39,6 +40,30 @@
 _log = logging.getLogger(__name__)
 
 
+def main():
+    up = os.path.dirname
+    webkit_root = up(up(up(up(up(os.path.abspath(__file__))))))
+
+    tester = Tester()
+    tester.add_tree(os.path.join(webkit_root, 'Tools', 'Scripts'), 'webkitpy')
+    tester.add_tree(os.path.join(webkit_root, 'Source', 'WebKit2', 'Scripts'), 'webkit2')
+
+    # FIXME: Do we need to be able to test QueueStatusServer on Windows as well?
+    appengine_sdk_path = '/usr/local/google_appengine'
+    if os.path.exists(appengine_sdk_path):
+        if not appengine_sdk_path in sys.path:
+            sys.path.append(appengine_sdk_path)
+        import dev_appserver
+        from google.appengine.dist import use_library
+        use_library('django', '1.2')
+        dev_appserver.fix_sys_path()
+        tester.add_tree(os.path.join(webkit_root, 'Tools', 'QueueStatusServer'))
+    else:
+        _log.info('Skipping QueueStatusServer tests; the Google AppEngine Python SDK is not installed.')
+
+    return not tester.run()
+
+
 class Tester(object):
     def __init__(self, filesystem=None):
         self.finder = Finder(filesystem or FileSystem())
@@ -132,3 +157,6 @@
         traceback.print_exc(file=s)
         for l in s.buflist:
             _log.error('  ' + l.rstrip())
+
+if __name__ == '__main__':
+    sys.exit(main())
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to