[Lldb-commits] [PATCH] D20193: test infra: catch bad decorators and import-time errors

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Fri May 13 13:40:24 PDT 2016


Here's the patch I'm using so far to get to the point where dotest is
actually running and successfully returning results.  It just doesn't
indicate any error results, only a job_begin and a job_end.

All this patch does is add use_lldb_suite.py in 2 places, import it, and
change a "w" to a "wb".

The question of why no errors are getting returned is still open.

On Fri, May 13, 2016 at 1:33 PM Zachary Turner <zturner at google.com> wrote:

> zturner added a comment.
>
> In lldbsuite\test_event\formatter\__init__.py, if I open the file with "wb"
> instead of "w" I get further, but I still get other errors.  This might
> create a problem because you conditionally set the output file to stderr or
> stdout, which are opened for text already, so those will never work with
> cPickle.dump().  Do you have any good idea how to fix that?
>
> In any case, for now I've set it to "wb" and I'm getting further.  It's
> returning results back to the unit test, but the results only contain a
> begin and an end, but no error results.
>
>
> http://reviews.llvm.org/D20193
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160513/ec2b7d9b/attachment.html>
-------------- next part --------------
diff --git a/packages/Python/lldbsuite/test_event/formatter/__init__.py b/packages/Python/lldbsuite/test_event/formatter/__init__.py
index 556370e..00d8bfa 100644
--- a/packages/Python/lldbsuite/test_event/formatter/__init__.py
+++ b/packages/Python/lldbsuite/test_event/formatter/__init__.py
@@ -94,7 +94,7 @@ def create_results_formatter(config):
             results_file_object = sys.stderr
             cleanup_func = None
         else:
-            results_file_object = open(config.filename, "w")
+            results_file_object = open(config.filename, "wb")
             cleanup_func = results_file_object.close
         default_formatter_name = (
             "lldbsuite.test_event.formatter.xunit.XunitFormatter")
diff --git a/packages/Python/lldbsuite/test_event/test/src/event_collector.py b/packages/Python/lldbsuite/test_event/test/src/event_collector.py
index 35d1320..4671c2f 100644
--- a/packages/Python/lldbsuite/test_event/test/src/event_collector.py
+++ b/packages/Python/lldbsuite/test_event/test/src/event_collector.py
@@ -7,6 +7,7 @@ import sys
 import tempfile
 
 # noinspection PyUnresolvedReferences
+import use_lldb_suite
 from six.moves import cPickle
 
 
diff --git a/packages/Python/lldbsuite/test_event/test/src/use_lldb_suite.py b/packages/Python/lldbsuite/test_event/test/src/use_lldb_suite.py
new file mode 100644
index 0000000..f3e358a
--- /dev/null
+++ b/packages/Python/lldbsuite/test_event/test/src/use_lldb_suite.py
@@ -0,0 +1,25 @@
+import inspect
+import os
+import sys
+
+def find_lldb_root():
+    lldb_root = os.path.dirname(inspect.getfile(inspect.currentframe()))
+    while True:
+        lldb_root = os.path.dirname(lldb_root)
+        if lldb_root is None:
+            return None
+
+        test_path = os.path.join(lldb_root, "use_lldb_suite_root.py")
+        if os.path.isfile(test_path):
+            return lldb_root
+    return None
+
+lldb_root = find_lldb_root()
+if lldb_root is not None:
+    import imp
+    fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
+    try:
+        imp.load_module("use_lldb_suite_root", fp, pathname, desc)
+    finally:
+        if fp:
+            fp.close()
diff --git a/packages/Python/lldbsuite/test_event/use_lldb_suite.py b/packages/Python/lldbsuite/test_event/use_lldb_suite.py
new file mode 100644
index 0000000..f3e358a
--- /dev/null
+++ b/packages/Python/lldbsuite/test_event/use_lldb_suite.py
@@ -0,0 +1,25 @@
+import inspect
+import os
+import sys
+
+def find_lldb_root():
+    lldb_root = os.path.dirname(inspect.getfile(inspect.currentframe()))
+    while True:
+        lldb_root = os.path.dirname(lldb_root)
+        if lldb_root is None:
+            return None
+
+        test_path = os.path.join(lldb_root, "use_lldb_suite_root.py")
+        if os.path.isfile(test_path):
+            return lldb_root
+    return None
+
+lldb_root = find_lldb_root()
+if lldb_root is not None:
+    import imp
+    fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
+    try:
+        imp.load_module("use_lldb_suite_root", fp, pathname, desc)
+    finally:
+        if fp:
+            fp.close()


More information about the lldb-commits mailing list