Title: [122759] trunk/Tools
- Revision
- 122759
- Author
- [email protected]
- Date
- 2012-07-16 14:06:28 -0700 (Mon, 16 Jul 2012)
Log Message
test-webkitpy: handle failures properly when running in parallel
https://bugs.webkit.org/show_bug.cgi?id=91416
Reviewed by Tony Chang.
It turns out that unittest.TestResults contain a handle to the
test method itself, which isn't picklable; it's sufficient to just
store the test name instead of the actual method. By doing so
we can move the test_name() method from the printer to the
runner where it belongs (so the printer is less dependent on the
unittest framework's data structures).
This change should really have a test but I don't know how to
write one that properly captures the behavior and won't cause
test-webkitpy itself to fail. I've verified the fix by hand, at
least, in the meantime.
* Scripts/webkitpy/test/printer.py:
(Printer.__init__):
(Printer.print_result):
* Scripts/webkitpy/test/runner.py:
(_test_name):
(Runner.all_test_names):
(_Worker.handle):
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (122758 => 122759)
--- trunk/Tools/ChangeLog 2012-07-16 20:48:40 UTC (rev 122758)
+++ trunk/Tools/ChangeLog 2012-07-16 21:06:28 UTC (rev 122759)
@@ -1,5 +1,32 @@
2012-07-16 Dirk Pranke <[email protected]>
+ test-webkitpy: handle failures properly when running in parallel
+ https://bugs.webkit.org/show_bug.cgi?id=91416
+
+ Reviewed by Tony Chang.
+
+ It turns out that unittest.TestResults contain a handle to the
+ test method itself, which isn't picklable; it's sufficient to just
+ store the test name instead of the actual method. By doing so
+ we can move the test_name() method from the printer to the
+ runner where it belongs (so the printer is less dependent on the
+ unittest framework's data structures).
+
+ This change should really have a test but I don't know how to
+ write one that properly captures the behavior and won't cause
+ test-webkitpy itself to fail. I've verified the fix by hand, at
+ least, in the meantime.
+
+ * Scripts/webkitpy/test/printer.py:
+ (Printer.__init__):
+ (Printer.print_result):
+ * Scripts/webkitpy/test/runner.py:
+ (_test_name):
+ (Runner.all_test_names):
+ (_Worker.handle):
+
+2012-07-16 Dirk Pranke <[email protected]>
+
test-webkitpy: run tests in parallel
https://bugs.webkit.org/show_bug.cgi?id=91294
Modified: trunk/Tools/Scripts/webkitpy/test/printer.py (122758 => 122759)
--- trunk/Tools/Scripts/webkitpy/test/printer.py 2012-07-16 20:48:40 UTC (rev 122758)
+++ trunk/Tools/Scripts/webkitpy/test/printer.py 2012-07-16 21:06:28 UTC (rev 122759)
@@ -22,7 +22,6 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import logging
-import re
import StringIO
from webkitpy.common.system import outputcapture
@@ -34,12 +33,7 @@
def __init__(self, stream, options=None):
self.stream = stream
self.options = options
- self.test_description = re.compile("(\w+) \(([\w.]+)\)")
- def test_name(self, test):
- m = self.test_description.match(str(test))
- return "%s.%s" % (m.group(2), m.group(1))
-
def configure(self, options):
self.options = options
@@ -126,17 +120,17 @@
def print_result(self, result, run_time):
self.stream.write('\n')
- for (test, err) in result.errors:
+ for (test_name, err) in result.errors:
self.stream.write("=" * 80 + '\n')
- self.stream.write("ERROR: " + self.test_name(test) + '\n')
+ self.stream.write("ERROR: " + test_name + '\n')
self.stream.write("-" * 80 + '\n')
for line in err.splitlines():
self.stream.write(line + '\n')
self.stream.write('\n')
- for (test, failure) in result.failures:
+ for (test_name, failure) in result.failures:
self.stream.write("=" * 80 + '\n')
- self.stream.write("FAILURE: " + self.test_name(test) + '\n')
+ self.stream.write("FAILURE: " + test_name + '\n')
self.stream.write("-" * 80 + '\n')
for line in failure.splitlines():
self.stream.write(line + '\n')
Modified: trunk/Tools/Scripts/webkitpy/test/runner.py (122758 => 122759)
--- trunk/Tools/Scripts/webkitpy/test/runner.py 2012-07-16 20:48:40 UTC (rev 122758)
+++ trunk/Tools/Scripts/webkitpy/test/runner.py 2012-07-16 21:06:28 UTC (rev 122759)
@@ -23,6 +23,7 @@
"""code to actually run a list of python tests."""
import logging
+import re
import time
import unittest
@@ -31,6 +32,14 @@
_log = logging.getLogger(__name__)
+_test_description = re.compile("(\w+) \(([\w.]+)\)")
+
+
+def _test_name(test):
+ m = _test_description.match(str(test))
+ return "%s.%s" % (m.group(2), m.group(1))
+
+
class Runner(object):
def __init__(self, printer, options, loader):
self.options = options
@@ -45,7 +54,7 @@
for t in suite._tests:
names.extend(self.all_test_names(t))
else:
- names.append(self.printer.test_name(suite))
+ names.append(_test_name(suite))
return names
def run(self, suite):
@@ -80,4 +89,12 @@
start = time.time()
self._caller.post('started_test', test_name)
self._loader.loadTestsFromName(test_name, None).run(result)
+
+ # The tests in the TestResult contain file objects and other unpicklable things; we only
+ # care about the test name, so we rewrite the result to replace the test with the test name.
+ # FIXME: We need an automated test for this, but I don't know how to write an automated
+ # test that will fail in this case that doesn't get picked up by test-webkitpy normally :(.
+ result.failures = [(_test_name(failure[0]), failure[1]) for failure in result.failures]
+ result.errors = [(_test_name(error[0]), error[1]) for error in result.errors]
+
self._caller.post('finished_test', test_name, time.time() - start, result)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes