Title: [90184] trunk/Tools
Revision
90184
Author
[email protected]
Date
2011-06-30 16:40:32 -0700 (Thu, 30 Jun 2011)

Log Message

2011-06-30  Adam Barth  <[email protected]>

        Reviewed by Darin Adler.

        Clean up output from new-run-webkit-tests
        https://bugs.webkit.org/show_bug.cgi?id=63759

        Printing messages from the child process looks super ugly because of
        the way the pretty-printer works.  Printing a blank line first is a
        hack, but it makes things at least partially sane.

        Also, handle the case where calling sample throws an exception.

        * Scripts/webkitpy/layout_tests/port/server_process.py:
        * Scripts/webkitpy/layout_tests/port/server_process_unittest.py:

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (90183 => 90184)


--- trunk/Tools/ChangeLog	2011-06-30 23:39:34 UTC (rev 90183)
+++ trunk/Tools/ChangeLog	2011-06-30 23:40:32 UTC (rev 90184)
@@ -1,3 +1,19 @@
+2011-06-30  Adam Barth  <[email protected]>
+
+        Reviewed by Darin Adler.
+
+        Clean up output from new-run-webkit-tests
+        https://bugs.webkit.org/show_bug.cgi?id=63759
+
+        Printing messages from the child process looks super ugly because of
+        the way the pretty-printer works.  Printing a blank line first is a
+        hack, but it makes things at least partially sane.
+
+        Also, handle the case where calling sample throws an exception.
+
+        * Scripts/webkitpy/layout_tests/port/server_process.py:
+        * Scripts/webkitpy/layout_tests/port/server_process_unittest.py:
+
 2011-06-27  Diego Gonzalez  <[email protected]>
 
         Reviewed by Antonio Gomes.

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/server_process.py (90183 => 90184)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/server_process.py	2011-06-30 23:39:34 UTC (rev 90183)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/server_process.py	2011-06-30 23:40:32 UTC (rev 90184)
@@ -39,7 +39,7 @@
 if sys.platform != 'win32':
     import fcntl
 
-from webkitpy.common.system.executive import Executive
+from webkitpy.common.system.executive import Executive, ScriptError
 
 _log = logging.getLogger(__file__)
 
@@ -166,19 +166,28 @@
             self.crashed = True
             self.handle_interrupt()
 
+    def _log(self, message):
+        # This is a bit of a hack, but we first log a blank line to avoid
+        # messing up the master process's output.
+        _log.info('')
+        _log.info(message)
+
     def _sample(self):
         if sys.platform != "darwin":
             return
-        _log.warning('Sampling process... (use --no-sample-on-timeout to skip this step)')
-        hang_report = os.path.join(self._port.results_directory(), "%s-%s.sample.txt" % (self._name, self._proc.pid))
-        self._executive.run_command([
-            "/usr/bin/sample",
-            self._proc.pid,
-            10,
-            10,
-            "-file",
-            hang_report,
-        ])
+        try:
+            self._log('Sampling %s process... (use --no-sample-on-timeout to skip this step)' % self._name)
+            hang_report = os.path.join(self._port.results_directory(), "%s-%s.sample.txt" % (self._name, self._proc.pid))
+            self._executive.run_command([
+                "/usr/bin/sample",
+                self._proc.pid,
+                10,
+                10,
+                "-file",
+                hang_report,
+            ])
+        except ScriptError, e:
+            self._log('Unable to sample process.')
 
     def _read(self, timeout, size):
         """Internal routine that actually does the read."""
@@ -193,7 +202,7 @@
             now = time.time()
             if now > deadline:
                 if self._executive.running_pids(self._port.is_crash_reporter):
-                    _log.warning('Waiting for crash reporter...')
+                    self._log('Waiting for crash reporter...')
                     self._executive.wait_newest(self._port.is_crash_reporter)
                     if not self.crashed:
                         self._check_for_crash()

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/server_process_unittest.py (90183 => 90184)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/server_process_unittest.py	2011-06-30 23:39:34 UTC (rev 90183)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/server_process_unittest.py	2011-06-30 23:40:32 UTC (rev 90184)
@@ -30,6 +30,7 @@
 import unittest
 
 from webkitpy.layout_tests.port import server_process
+from webkitpy.common.system.executive import ScriptError
 from webkitpy.common.system.executive_mock import MockExecutive2
 from webkitpy.common.system.outputcapture import OutputCapture
 
@@ -38,6 +39,10 @@
     print args
 
 
+def _throwing_run_command(args):
+    raise ScriptError("MOCK script error")
+
+
 class TrivialMockPort(object):
     def results_directory(self):
         return "/mock/results"
@@ -92,3 +97,11 @@
         server_process._proc = MockProc(server_process)
         expected_stdout = "['/usr/bin/sample', 1, 10, 10, '-file', '/mock/results/test-1.sample.txt']\n"
         OutputCapture().assert_outputs(self, server_process._sample, expected_stdout=expected_stdout)
+
+    def test_sample_process_throws_exception(self):
+        # Currently, sample-on-timeout only works on Darwin.
+        if sys.platform != "darwin":
+            return
+        server_process = FakeServerProcess(port_obj=TrivialMockPort(), name="test", cmd=["test"], executive=MockExecutive2(run_command_fn=_throwing_run_command))
+        server_process._proc = MockProc(server_process)
+        OutputCapture().assert_outputs(self, server_process._sample)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to