[Lldb-commits] [lldb] r175946 - This should get clang/gcc decorators working

Malea, Daniel daniel.malea at intel.com
Mon Feb 25 15:13:01 PST 2013


Hi Enrico,

Thanks for doing this, it will help get much better test (and buildbot) output.

However, this commit seems to duplicate some code -- any way around that? I have a patch that adds arguments to the uses of @expectedFailure[Linux|Clang|Gcc|i386] and friends in the test cases... if that would help you avoid the giant "if callable(..)" block in the decorator body, let me know and I'll post it to the list. I'd really like to avoid that logic if possible, because as-is the variable named 'bugnumber' can be a rdar tracking number integer, or a function....quite confusing!

We are planning to enable more test compilers than GCC or Clang.... if we had a function that takes the compiler name as a string, adding that feature would be a lot cleaner than duplicating all this decorator logic.

Also, I think it would be great if the decorator would be used with a full string that describes the bug (i.e. "llvm.org/pr15130") that way we can distinguish between rdar issues and llvm.org bugtracker issues.

Cheers,
Dan



-----Original Message-----
From: lldb-commits-bounces at cs.uiuc.edu [mailto:lldb-commits-bounces at cs.uiuc.edu] On Behalf Of Enrico Granata
Sent: Friday, February 22, 2013 8:35 PM
To: lldb-commits at cs.uiuc.edu
Subject: [Lldb-commits] [lldb] r175946 - This should get clang/gcc decorators working

Author: enrico
Date: Fri Feb 22 19:35:21 2013
New Revision: 175946

URL: http://llvm.org/viewvc/llvm-project?rev=175946&view=rev
Log:
This should get clang/gcc decorators working

Modified:
    lldb/trunk/test/lldbtest.py

Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=175946&r1=175945&r2=175946&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Fri Feb 22 19:35:21 2013
@@ -368,25 +368,25 @@ def dwarf_test(func):
     wrapper.__dwarf_test__ = True
     return wrapper
 
-def expectedFailureCompiler(func,compiler,bugnumber=None):
+def expectedFailureGcc(bugnumber=None):
      if callable(bugnumber):
         @wraps(bugnumber)
-        def expectedFailureCompiler_easy_wrapper(*args, **kwargs):
+        def expectedFailureGcc_easy_wrapper(*args, **kwargs):
             from unittest2 import case
             self = args[0]
             test_compiler = self.getCompiler()
             try:
                 bugnumber(*args, **kwargs)
             except Exception:
-                if compiler in test_compiler:
+                if "gcc" in test_compiler:
                     raise case._ExpectedFailure(sys.exc_info(),None)
                 else:
                     raise
-            if compiler in test_compiler:
+            if "gcc" in test_compiler:
                 raise case._UnexpectedSuccess(sys.exc_info(),None)
-        return expectedFailureCompiler_easy_wrapper
+        return expectedFailureGcc_easy_wrapper
      else:
-        def expectedFailureCompiler_impl(func):
+        def expectedFailureGcc_impl(func):
               @wraps(func)
               def wrapper(*args, **kwargs):
                 from unittest2 import case @@ -395,26 +395,51 @@ def expectedFailureCompiler(func,compile
                 try:
                     func(*args, **kwargs)
                 except Exception:
-                    if compiler in test_compiler:
+                    if "gcc" in test_compiler:
                         raise case._ExpectedFailure(sys.exc_info(),bugnumber)
                     else:
                         raise
-                if compiler in test_compiler:
+                if "gcc" in test_compiler:
                     raise case._UnexpectedSuccess(sys.exc_info(),bugnumber)
               return wrapper
-        return expectedFailureCompiler_impl
+        return expectedFailureGcc_impl
 
-def expectedFailureGcc(func):
-    """Decorate the item as a GCC only expectedFailure."""
-    if isinstance(func, type) and issubclass(func, unittest2.TestCase):
-        raise Exception("@expectedFailureClang can only be used to decorate a test method")
-    return expectedFailureCompiler(func, "gcc")
+def expectedFailureClang(bugnumber=None):
+     if callable(bugnumber):
+        @wraps(bugnumber)
+        def expectedFailureClang_easy_wrapper(*args, **kwargs):
+            from unittest2 import case
+            self = args[0]
+            test_compiler = self.getCompiler()
+            try:
+                bugnumber(*args, **kwargs)
+            except Exception:
+                if "clang" in test_compiler:
+                    raise case._ExpectedFailure(sys.exc_info(),None)
+                else:
+                    raise
+            if "clang" in test_compiler:
+                raise case._UnexpectedSuccess(sys.exc_info(),None)
+        return expectedFailureClang_easy_wrapper
+     else:
+        def expectedFailureClang_impl(func):
+              @wraps(func)
+              def wrapper(*args, **kwargs):
+                from unittest2 import case
+                self = args[0]
+                test_compiler = self.getCompiler()
+                try:
+                    func(*args, **kwargs)
+                except Exception:
+                    if "clang" in test_compiler:
+                        raise case._ExpectedFailure(sys.exc_info(),bugnumber)
+                    else:
+                        raise
+                if "clang" in test_compiler:
+                    raise case._UnexpectedSuccess(sys.exc_info(),bugnumber)
+              return wrapper
+        return expectedFailureClang_impl
 
-def expectedFailureClang(func):
-    """Decorate the item as a Clang only expectedFailure."""
-    if isinstance(func, type) and issubclass(func, unittest2.TestCase):
-        raise Exception("@expectedFailureClang can only be used to decorate a test method")
-    return expectedFailureCompiler(func, "clang")
 
 def expectedFailurei386(bugnumber=None):
      if callable(bugnumber):


_______________________________________________
lldb-commits mailing list
lldb-commits at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits




More information about the lldb-commits mailing list