Title: [136443] trunk/Tools
Revision
136443
Author
[email protected]
Date
2012-12-03 15:08:07 -0800 (Mon, 03 Dec 2012)

Log Message

webkitpy's run_webkit_tests should initialize the printer earlier on
https://bugs.webkit.org/show_bug.cgi?id=103661

Reviewed by Eric Seidel.

Initialize the printer before computing the derived options
from the command line arguments, so that we can safely log from
port methods.

Also clean up a few miscellaneous lint warnings.

* Scripts/webkitpy/layout_tests/port/chromium_android.py:
(ChromiumAndroidPort.path_to_adb):
* Scripts/webkitpy/layout_tests/port/mac.py:
(MacPort.default_child_processes):
(MacPort.sample_process):
(MacPort.start_helper):
(MacPort.stop_helper):
(MacPort.nm_command):
* Scripts/webkitpy/layout_tests/port/mac_unittest.py:
(test_default_child_processes):
* Scripts/webkitpy/layout_tests/run_webkit_tests.py:
(run):
(_set_up_derived_options):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (136442 => 136443)


--- trunk/Tools/ChangeLog	2012-12-03 23:07:54 UTC (rev 136442)
+++ trunk/Tools/ChangeLog	2012-12-03 23:08:07 UTC (rev 136443)
@@ -1,5 +1,32 @@
 2012-12-03  Dirk Pranke  <[email protected]>
 
+        webkitpy's run_webkit_tests should initialize the printer earlier on
+        https://bugs.webkit.org/show_bug.cgi?id=103661
+
+        Reviewed by Eric Seidel.
+
+        Initialize the printer before computing the derived options
+        from the command line arguments, so that we can safely log from
+        port methods.
+
+        Also clean up a few miscellaneous lint warnings.
+
+        * Scripts/webkitpy/layout_tests/port/chromium_android.py:
+        (ChromiumAndroidPort.path_to_adb):
+        * Scripts/webkitpy/layout_tests/port/mac.py:
+        (MacPort.default_child_processes):
+        (MacPort.sample_process):
+        (MacPort.start_helper):
+        (MacPort.stop_helper):
+        (MacPort.nm_command):
+        * Scripts/webkitpy/layout_tests/port/mac_unittest.py:
+        (test_default_child_processes):
+        * Scripts/webkitpy/layout_tests/run_webkit_tests.py:
+        (run):
+        (_set_up_derived_options):
+
+2012-12-03  Dirk Pranke  <[email protected]>
+
         webkitpy: autoinstaller is failing on windows
         https://bugs.webkit.org/show_bug.cgi?id=103699
 

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py (136442 => 136443)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py	2012-12-03 23:07:54 UTC (rev 136442)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py	2012-12-03 23:08:07 UTC (rev 136443)
@@ -32,7 +32,6 @@
 import os
 import re
 import subprocess
-import sys
 import threading
 import time
 
@@ -276,8 +275,7 @@
         if not path_version:
             ChromiumAndroidPort._adb_path = provided_adb_path
         elif provided_version > path_version:
-            # FIXME: The Printer isn't initialized when this is called, so using _log would just show an unitialized logger error.
-            print >> sys.stderr, 'The "adb" version in your path is older than the one checked in, consider updating your local Android SDK. Using the checked in one.'
+            _log.warning('The "adb" version in your path is older than the one checked in, consider updating your local Android SDK. Using the checked in one.')
             ChromiumAndroidPort._adb_path = provided_adb_path
         else:
             ChromiumAndroidPort._adb_path = 'adb'

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/mac.py (136442 => 136443)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/mac.py	2012-12-03 23:07:54 UTC (rev 136442)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/mac.py	2012-12-03 23:08:07 UTC (rev 136443)
@@ -29,9 +29,6 @@
 
 import logging
 import os
-import re
-import subprocess
-import sys
 import time
 
 from webkitpy.common.system.crashlogs import CrashLogs
@@ -107,10 +104,8 @@
         return self._version == "lion"
 
     def default_child_processes(self):
-        # FIXME: The Printer isn't initialized when this is called, so using _log would just show an unitialized logger error.
-
         if self._version == "snowleopard":
-            print >> sys.stderr, "Cannot run tests in parallel on Snow Leopard due to rdar://problem/10621525."
+            _log.warning("Cannot run tests in parallel on Snow Leopard due to rdar://problem/10621525.")
             return 1
 
         default_count = super(MacPort, self).default_child_processes()
@@ -127,7 +122,7 @@
         overhead = 2048 * 1024 * 1024  # Assume we need 2GB free for the O/S
         supportable_instances = max((total_memory - overhead) / bytes_per_drt, 1)  # Always use one process, even if we don't have space for it.
         if supportable_instances < default_count:
-            print >> sys.stderr, "This machine could support %s child processes, but only has enough memory for %s." % (default_count, supportable_instances)
+            _log.warning("This machine could support %s child processes, but only has enough memory for %s." % (default_count, supportable_instances))
         return min(supportable_instances, default_count)
 
     def _build_java_test_support(self):
@@ -242,8 +237,8 @@
                 "-file",
                 hang_report,
             ])
-        except ScriptError, e:
-            _log.warning('Unable to sample process.')
+        except ScriptError as e:
+            _log.warning('Unable to sample process:' + str(e))
 
     def _path_to_helper(self):
         binary_name = 'LayoutTestHelper'
@@ -253,9 +248,8 @@
         helper_path = self._path_to_helper()
         if helper_path:
             _log.debug("Starting layout helper %s" % helper_path)
-            # Note: Not thread safe: http://bugs.python.org/issue2320
             self._helper = self._executive.popen([helper_path],
-                stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=None)
+                stdin=self._executive.PIPE, stdout=self._executive.PIPE, stderr=None)
             is_ready = self._helper.stdout.readline()
             if not is_ready.startswith('ready'):
                 _log.error("LayoutTestHelper failed to be ready")
@@ -269,12 +263,11 @@
                 self._helper.wait()
             except IOError, e:
                 _log.debug("IOError raised while stopping helper: %s" % str(e))
-                pass
             self._helper = None
 
     def nm_command(self):
         try:
             return self._executive.run_command(['xcrun', '-find', 'nm']).rstrip()
-        except ScriptError, e:
+        except ScriptError:
             _log.warn("xcrun failed; falling back to 'nm'.")
             return 'nm'

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/mac_unittest.py (136442 => 136443)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/mac_unittest.py	2012-12-03 23:07:54 UTC (rev 136442)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/mac_unittest.py	2012-12-03 23:08:07 UTC (rev 136443)
@@ -152,20 +152,20 @@
 
         bytes_for_drt = 200 * 1024 * 1024
         port.host.platform.total_bytes_memory = lambda: bytes_for_drt
-        expected_stderr = "This machine could support 2 child processes, but only has enough memory for 1.\n"
-        child_processes = OutputCapture().assert_outputs(self, port.default_child_processes, (), expected_stderr=expected_stderr)
+        expected_logs = "This machine could support 2 child processes, but only has enough memory for 1.\n"
+        child_processes = OutputCapture().assert_outputs(self, port.default_child_processes, (), expected_logs=expected_logs)
         self.assertEqual(child_processes, 1)
 
         # Make sure that we always use one process, even if we don't have the memory for it.
         port.host.platform.total_bytes_memory = lambda: bytes_for_drt - 1
-        expected_stderr = "This machine could support 2 child processes, but only has enough memory for 1.\n"
-        child_processes = OutputCapture().assert_outputs(self, port.default_child_processes, (), expected_stderr=expected_stderr)
+        expected_logs = "This machine could support 2 child processes, but only has enough memory for 1.\n"
+        child_processes = OutputCapture().assert_outputs(self, port.default_child_processes, (), expected_logs=expected_logs)
         self.assertEqual(child_processes, 1)
 
         # SnowLeopard has a CFNetwork bug which causes crashes if we execute more than one copy of DRT at once.
         port = self.make_port(port_name='mac-snowleopard')
-        expected_stderr = "Cannot run tests in parallel on Snow Leopard due to rdar://problem/10621525.\n"
-        child_processes = OutputCapture().assert_outputs(self, port.default_child_processes, (), expected_stderr=expected_stderr)
+        expected_logs = "Cannot run tests in parallel on Snow Leopard due to rdar://problem/10621525.\n"
+        child_processes = OutputCapture().assert_outputs(self, port.default_child_processes, (), expected_logs=expected_logs)
         self.assertEqual(child_processes, 1)
 
     def test_get_crash_log(self):

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py (136442 => 136443)


--- trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py	2012-12-03 23:07:54 UTC (rev 136442)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py	2012-12-03 23:08:07 UTC (rev 136443)
@@ -29,7 +29,6 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-import errno
 import logging
 import optparse
 import os
@@ -38,7 +37,6 @@
 import traceback
 
 from webkitpy.common.host import Host
-from webkitpy.common.system import stack_utils
 from webkitpy.layout_tests.controllers.manager import Manager
 from webkitpy.layout_tests.models import test_expectations
 from webkitpy.layout_tests.port import configuration_options, platform_options
@@ -91,18 +89,13 @@
 
 def run(port, options, args, regular_output=sys.stderr, buildbot_output=sys.stdout):
     try:
-        warnings = _set_up_derived_options(port, options)
-
         printer = printing.Printer(port, options, regular_output, buildbot_output, logger=logging.getLogger())
 
-        for warning in warnings:
-            _log.warning(warning)
+        _set_up_derived_options(port, options)
 
         if options.lint_test_files:
             return lint(port, options)
 
-        # We wrap any parts of the run that are slow or likely to raise exceptions
-        # in a try/finally to ensure that we clean up the logging configuration.
         manager = Manager(port, options, printer)
         printer.print_config(port.results_directory())
 
@@ -114,9 +107,6 @@
 
 def _set_up_derived_options(port, options):
     """Sets the options values that depend on other options values."""
-    # We return a list of warnings to print after the printer is initialized.
-    warnings = []
-
     if not options.child_processes:
         options.child_processes = os.environ.get("WEBKIT_TEST_CHILD_PROCESSES",
                                                  str(port.default_child_processes()))
@@ -142,11 +132,11 @@
         options.additional_platform_directory = additional_platform_directories
 
     if not options.http and options.skipped in ('ignore', 'only'):
-        warnings.append("--force/--skipped=%s overrides --no-http." % (options.skipped))
+        _log.warning("--force/--skipped=%s overrides --no-http." % (options.skipped))
         options.http = True
 
     if options.ignore_metrics and (options.new_baseline or options.reset_results):
-        warnings.append("--ignore-metrics has no effect with --new-baselines or with --reset-results")
+        _log.warning("--ignore-metrics has no effect with --new-baselines or with --reset-results")
 
     if options.new_baseline:
         options.reset_results = True
@@ -162,7 +152,7 @@
             # to Port.
             filesystem = port.host.filesystem
             if not filesystem.isdir(filesystem.join(port.layout_tests_dir(), directory)):
-                warnings.append("'%s' was passed to --pixel-test-directories, which doesn't seem to be a directory" % str(directory))
+                _log.warning("'%s' was passed to --pixel-test-directories, which doesn't seem to be a directory" % str(directory))
             else:
                 varified_dirs.add(directory)
 
@@ -171,10 +161,8 @@
     if options.run_singly:
         options.verbose = True
 
-    return warnings
 
-
-def _compat_shim_callback(option, opt_str, value, parser):
+def _compat_shim_callback(option, opt_str, value, parser):  # ignore unused variable warning - pylint: disable-msg=W0613
     print "Ignoring unsupported option: %s" % opt_str
 
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to