Hi dawn, ki.stfu,

The decorators to skip if or unless certain platforms relied on calling 
skipTest, which only worked if they were decorating individual test cases. 
However for decorating entire classes it needs different behavior. This 
behavior is already encapsulated in unittest2.skipIf and unittest2.skipUnless 
so this patch modifies the platform decorators to use these unittest skip 
decorators.

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D8903

Files:
  test/dotest.py
  test/lldbtest.py

Index: test/dotest.py
===================================================================
--- test/dotest.py
+++ test/dotest.py
@@ -1320,16 +1320,6 @@
 if not skip_long_running_test:
     os.environ["LLDB_SKIP_LONG_RUNNING_TEST"] = "NO"
 
-#
-# Walk through the testdirs while collecting tests.
-#
-for testdir in testdirs:
-    os.path.walk(testdir, visit, 'Test')
-
-#
-# Now that we have loaded all the test cases, run the whole test suite.
-#
-
 # For the time being, let's bracket the test runner within the
 # lldb.SBDebugger.Initialize()/Terminate() pair.
 import lldb
@@ -1383,6 +1373,16 @@
 # Don't do lldb-server (llgs) tests on anything except Linux.
 dont_do_llgs_test = not ("linux" in target_platform)
 
+#
+# Walk through the testdirs while collecting tests.
+#
+for testdir in testdirs:
+    os.path.walk(testdir, visit, 'Test')
+
+#
+# Now that we have loaded all the test cases, run the whole test suite.
+#
+
 # Put the blacklist in the lldb namespace, to be used by lldb.TestBase.
 lldb.blacklist = blacklist
 
Index: test/lldbtest.py
===================================================================
--- test/lldbtest.py
+++ test/lldbtest.py
@@ -683,33 +683,21 @@
     """Decorate the item to skip tests that should be skipped on any non 
Darwin platform."""
     return skipUnlessPlatform(getDarwinOSTriples())(func)
 
+def getPlatform():
+    platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2]
+    if platform.startswith('freebsd'):
+        platform = 'freebsd'
+    return platform
+
 def skipIfPlatform(oslist):
     """Decorate the item to skip tests if running on one of the listed 
platforms."""
-    def decorator(func):
-        @wraps(func)
-        def wrapper(*args, **kwargs):
-            from unittest2 import case
-            self = args[0]
-            if self.getPlatform() in oslist:
-                self.skipTest("skip on %s" % (", ".join(oslist)))
-            else:
-                func(*args, **kwargs)
-        return wrapper
-    return decorator
+    return unittest2.skipIf(getPlatform() in oslist,
+                            "skip on %s" % (", ".join(oslist)))
 
 def skipUnlessPlatform(oslist):
     """Decorate the item to skip tests unless running on one of the listed 
platforms."""
-    def decorator(func):
-        @wraps(func)
-        def wrapper(*args, **kwargs):
-            from unittest2 import case
-            self = args[0]
-            if not (self.getPlatform() in oslist):
-                self.skipTest("requires one of %s" % (", ".join(oslist)))
-            else:
-                func(*args, **kwargs)
-        return wrapper
-    return decorator
+    return unittest2.skipUnless(getPlatform() in oslist,
+                                "requires on of %s" % (", ".join(oslist)))
 
 def skipIfLinuxClang(func):
     """Decorate the item to skip tests that should be skipped if building on 
@@ -1405,10 +1393,7 @@
 
     def getPlatform(self):
         """Returns the platform the test suite is running on."""
-        platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2]
-        if platform.startswith('freebsd'):
-            platform = 'freebsd'
-        return platform
+        return getPlatform()
 
     def isIntelCompiler(self):
         """ Returns true if using an Intel (ICC) compiler, false otherwise. """

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
Index: test/dotest.py
===================================================================
--- test/dotest.py
+++ test/dotest.py
@@ -1320,16 +1320,6 @@
 if not skip_long_running_test:
     os.environ["LLDB_SKIP_LONG_RUNNING_TEST"] = "NO"
 
-#
-# Walk through the testdirs while collecting tests.
-#
-for testdir in testdirs:
-    os.path.walk(testdir, visit, 'Test')
-
-#
-# Now that we have loaded all the test cases, run the whole test suite.
-#
-
 # For the time being, let's bracket the test runner within the
 # lldb.SBDebugger.Initialize()/Terminate() pair.
 import lldb
@@ -1383,6 +1373,16 @@
 # Don't do lldb-server (llgs) tests on anything except Linux.
 dont_do_llgs_test = not ("linux" in target_platform)
 
+#
+# Walk through the testdirs while collecting tests.
+#
+for testdir in testdirs:
+    os.path.walk(testdir, visit, 'Test')
+
+#
+# Now that we have loaded all the test cases, run the whole test suite.
+#
+
 # Put the blacklist in the lldb namespace, to be used by lldb.TestBase.
 lldb.blacklist = blacklist
 
Index: test/lldbtest.py
===================================================================
--- test/lldbtest.py
+++ test/lldbtest.py
@@ -683,33 +683,21 @@
     """Decorate the item to skip tests that should be skipped on any non Darwin platform."""
     return skipUnlessPlatform(getDarwinOSTriples())(func)
 
+def getPlatform():
+    platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2]
+    if platform.startswith('freebsd'):
+        platform = 'freebsd'
+    return platform
+
 def skipIfPlatform(oslist):
     """Decorate the item to skip tests if running on one of the listed platforms."""
-    def decorator(func):
-        @wraps(func)
-        def wrapper(*args, **kwargs):
-            from unittest2 import case
-            self = args[0]
-            if self.getPlatform() in oslist:
-                self.skipTest("skip on %s" % (", ".join(oslist)))
-            else:
-                func(*args, **kwargs)
-        return wrapper
-    return decorator
+    return unittest2.skipIf(getPlatform() in oslist,
+                            "skip on %s" % (", ".join(oslist)))
 
 def skipUnlessPlatform(oslist):
     """Decorate the item to skip tests unless running on one of the listed platforms."""
-    def decorator(func):
-        @wraps(func)
-        def wrapper(*args, **kwargs):
-            from unittest2 import case
-            self = args[0]
-            if not (self.getPlatform() in oslist):
-                self.skipTest("requires one of %s" % (", ".join(oslist)))
-            else:
-                func(*args, **kwargs)
-        return wrapper
-    return decorator
+    return unittest2.skipUnless(getPlatform() in oslist,
+                                "requires on of %s" % (", ".join(oslist)))
 
 def skipIfLinuxClang(func):
     """Decorate the item to skip tests that should be skipped if building on 
@@ -1405,10 +1393,7 @@
 
     def getPlatform(self):
         """Returns the platform the test suite is running on."""
-        platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2]
-        if platform.startswith('freebsd'):
-            platform = 'freebsd'
-        return platform
+        return getPlatform()
 
     def isIntelCompiler(self):
         """ Returns true if using an Intel (ICC) compiler, false otherwise. """
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

Reply via email to