summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test_event/event_builder.py
diff options
context:
space:
mode:
authorTodd Fiala <todd.fiala@gmail.com>2016-05-13 21:36:26 +0000
committerTodd Fiala <todd.fiala@gmail.com>2016-05-13 21:36:26 +0000
commit7c5f7caa200da38a106c268d09c6a0657a66829e (patch)
tree25cf73696b388c0ba216ea091075dd8e2c0700b7 /lldb/packages/Python/lldbsuite/test_event/event_builder.py
parentead771cb7ac8d8aacc71b2e6d62d465b1090ebd3 (diff)
downloadbcm5719-llvm-7c5f7caa200da38a106c268d09c6a0657a66829e.tar.gz
bcm5719-llvm-7c5f7caa200da38a106c268d09c6a0657a66829e.zip
test infra: catch bad decorators and import-time errors
Summary: This change enhances the LLDB test infrastructure to convert load-time exceptions in a given Python test module into errors. Before this change, specifying a non-existent test decorator, or otherwise having some load-time error in a python test module, would not get flagged as an error. With this change, typos and other load-time errors in a python test file get converted to errors and reported by the test runner. This change also includes test infrastructure tests that include covering the new work here. I'm going to wait until we have these infrastructure tests runnable on the main platforms before I try to work that into all the normal testing workflows. The test infrastructure tests can be run by using the standard python module testing practice of doing the following: cd packages/Python/lldbsuite/test_event python -m unittest discover -s test/src -p 'Test*.py' Those tests run the dotest inferior with a known broken test and verify that the errors are caught. These tests did not pass until I modified dotest.py to capture them properly. @zturner, if you have the chance, if you could try those steps above (the python -m unittest ... line) on Windows, that would be great if we can address any python2/3/Windows bits there. I don't think there's anything fancy, but I didn't want to hook it into test flow until I know it works there. I'll be slowly adding more tests that cover some of the other breakage I've occasionally seen that didn't get collected as part of the summarization. This is the biggest one I'm aware of. Reviewers: zturner, labath Subscribers: zturner, lldb-commits Differential Revision: http://reviews.llvm.org/D20193 llvm-svn: 269489
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test_event/event_builder.py')
-rw-r--r--lldb/packages/Python/lldbsuite/test_event/event_builder.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test_event/event_builder.py b/lldb/packages/Python/lldbsuite/test_event/event_builder.py
index 3c43f00577a..d97ea7a0e9e 100644
--- a/lldb/packages/Python/lldbsuite/test_event/event_builder.py
+++ b/lldb/packages/Python/lldbsuite/test_event/event_builder.py
@@ -321,6 +321,19 @@ class EventBuilder(object):
return event
@staticmethod
+ def event_for_job_test_add_error(test_filename, exception, backtrace):
+ event = EventBuilder.bare_event(EventBuilder.TYPE_JOB_RESULT)
+ event["status"] = EventBuilder.STATUS_ERROR
+ if test_filename is not None:
+ event["test_filename"] = EventBuilder._assert_is_python_sourcefile(test_filename)
+ if exception is not None and "__class__" in dir(exception):
+ event["issue_class"] = exception.__class__
+ event["issue_message"] = exception
+ if backtrace is not None:
+ event["issue_backtrace"] = backtrace
+ return event
+
+ @staticmethod
def event_for_job_exceptional_exit(
pid, worker_index, exception_code, exception_description,
test_filename, command_line):
OpenPOWER on IntegriCloud