[Lldb-commits] [lldb] r221402 - Allow inline test case to register actually useful teardown hooks by allowing a hook to be passed back the test instance, were it not to be already bound to self. Use this ability to make the reversal of escape-non-printables a teardown hook for added reliability of the testing logic

Enrico Granata egranata at apple.com
Wed Nov 5 13:31:57 PST 2014


Author: enrico
Date: Wed Nov  5 15:31:57 2014
New Revision: 221402

URL: http://llvm.org/viewvc/llvm-project?rev=221402&view=rev
Log:
Allow inline test case to register actually useful teardown hooks by allowing a hook to be passed back the test instance, were it not to be already bound to self. Use this ability to make the reversal of escape-non-printables a teardown hook for added reliability of the testing logic

Modified:
    lldb/trunk/test/functionalities/data-formatter/stringprinter/main.cpp
    lldb/trunk/test/lldbinline.py
    lldb/trunk/test/lldbtest.py

Modified: lldb/trunk/test/functionalities/data-formatter/stringprinter/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/stringprinter/main.cpp?rev=221402&r1=221401&r2=221402&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/stringprinter/main.cpp (original)
+++ lldb/trunk/test/functionalities/data-formatter/stringprinter/main.cpp Wed Nov  5 15:31:57 2014
@@ -11,13 +11,11 @@
 
 int main (int argc, char const *argv[])
 {
-    std::string stdstring("Hello\t\tWorld\nI am here\t\tto say hello\n");
+    std::string stdstring("Hello\t\tWorld\nI am here\t\tto say hello\n"); //%self.addTearDownHook(lambda x: x.runCmd("setting set escape-non-printables true"))
     const char* constcharstar = stdstring.c_str();
     return 0; //% self.assertTrue(self.frame().FindVariable('stdstring').GetSummary() == '"Hello\\t\\tWorld\\nI am here\\t\\tto say hello\\n"')
      //% self.assertTrue(self.frame().FindVariable('constcharstar').GetSummary() == '"Hello\\t\\tWorld\\nI am here\\t\\tto say hello\\n"')
      //% self.runCmd("setting set escape-non-printables false")
-     //% print self.frame().FindVariable('stdstring').GetSummary()
      //% self.assertTrue(self.frame().FindVariable('stdstring').GetSummary() == '"Hello\t\tWorld\nI am here\t\tto say hello\n"')
      //% self.assertTrue(self.frame().FindVariable('constcharstar').GetSummary() == '"Hello\t\tWorld\nI am here\t\tto say hello\n"')
-     //% self.runCmd("setting set escape-non-printables true")
 }

Modified: lldb/trunk/test/lldbinline.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbinline.py?rev=221402&r1=221401&r2=221402&view=diff
==============================================================================
--- lldb/trunk/test/lldbinline.py (original)
+++ lldb/trunk/test/lldbinline.py Wed Nov  5 15:31:57 2014
@@ -187,5 +187,6 @@ def MakeInlineTest(__file, __globals, de
 
     # Add the test case to the globals, and hide InlineTest
     __globals.update({test_name : test})
-
+    
+    return test
 

Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=221402&r1=221401&r2=221402&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Wed Nov  5 15:31:57 2014
@@ -999,6 +999,8 @@ class Base(unittest2.TestCase):
             with recording(self, traceAlways) as sbuf:
                 print >> sbuf, "Adding tearDown hook:", getsource_if_available(hook)
             self.hooks.append(hook)
+        
+        return self
 
     def deletePexpectChild(self):
         # This is for the case of directly spawning 'lldb' and interacting with it
@@ -1033,7 +1035,14 @@ class Base(unittest2.TestCase):
         for hook in reversed(self.hooks):
             with recording(self, traceAlways) as sbuf:
                 print >> sbuf, "Executing tearDown hook:", getsource_if_available(hook)
-            hook()
+            import inspect
+            hook_argc = len(inspect.getargspec(hook).args)
+            if hook_argc == 0:
+                hook()
+            elif hook_argc == 1:
+                hook(self)
+            else:
+                hook() # try the plain call and hope it works
 
         del self.hooks
 





More information about the lldb-commits mailing list