aboutsummaryrefslogtreecommitdiff
path: root/lldb/packages
diff options
context:
space:
mode:
authorJordan Rupprecht <rupprecht@google.com>2024-02-14 13:53:19 -0800
committerGitHub <noreply@github.com>2024-02-14 15:53:19 -0600
commit0fc578664809d9f808d24a91e50a68d6bfa22118 (patch)
tree5687d2e3d4b52c1fe64b9dcb001a606f0fd52d9f /lldb/packages
parent8d326542926d4fba89cfb0ec01a0c1a1bd0789d6 (diff)
downloadllvm-0fc578664809d9f808d24a91e50a68d6bfa22118.zip
llvm-0fc578664809d9f808d24a91e50a68d6bfa22118.tar.gz
llvm-0fc578664809d9f808d24a91e50a68d6bfa22118.tar.bz2
[lldb][test] Remove expectedFailureIfFn (#81703)
Switching to modern `unittest` in 5b386158aacac4b41126983a5379d36ed413d0ea needs xfail annotations to be known prior to test running. In contrast, skipping can happen at any time, even during test execution. Thus, `expectedFailureIfFn` inherently doesn't work. Either we eagerly evaluate the function and use `expectedFailureIf` instead, or we use a skip annotation to lazily evaluate the function and potentially skip the test right before it starts. - For `expectedFailureAndroid`, the intent seems to be that certain tests _should_ work on android, but don't. Thus, xfail is appropriate, to ensure the test is re-enabled once those bugs are ever fixed. - For the other uses in individual tests, those generally seem to be cases where the test environment doesn't support the setup required by the test, and so it isn't meaningful to run the test at all. For those, a drop-in replacement to `skipTestIfFn` works.
Diffstat (limited to 'lldb/packages')
-rw-r--r--lldb/packages/Python/lldbsuite/test/decorators.py39
1 files changed, 6 insertions, 33 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py
index a5e1fa5..86594c2 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -128,33 +128,6 @@ def expectedFailureIf(condition, bugnumber=None):
return expectedFailure_impl
-def expectedFailureIfFn(expected_fn, bugnumber=None):
- def expectedFailure_impl(func):
- if isinstance(func, type) and issubclass(func, unittest.TestCase):
- raise Exception("Decorator can only be used to decorate a test method")
-
- @wraps(func)
- def wrapper(*args, **kwargs):
- xfail_reason = expected_fn(*args, **kwargs)
- if xfail_reason is not None:
- xfail_func = unittest.expectedFailure(func)
- xfail_func(*args, **kwargs)
- else:
- func(*args, **kwargs)
-
- return wrapper
-
- # Some decorators can be called both with no arguments (e.g. @expectedFailureWindows)
- # or with arguments (e.g. @expectedFailureWindows(compilers=['gcc'])). When called
- # the first way, the first argument will be the actual function because decorators are
- # weird like that. So this is basically a check that says "which syntax was the original
- # function decorated with?"
- if callable(bugnumber):
- return expectedFailure_impl(bugnumber)
- else:
- return expectedFailure_impl
-
-
def skipTestIfFn(expected_fn, bugnumber=None):
def skipTestIfFn_impl(func):
if isinstance(func, type) and issubclass(func, unittest.TestCase):
@@ -417,8 +390,8 @@ def skipIf(
)
-def _skip_for_android(reason, api_levels, archs):
- def impl(obj):
+def _skip_fn_for_android(reason, api_levels, archs):
+ def impl():
result = lldbplatformutil.match_android_device(
lldbplatformutil.getArchitecture(),
valid_archs=archs,
@@ -549,8 +522,8 @@ def expectedFailureAndroid(bugnumber=None, api_levels=None, archs=None):
arch - A sequence of architecture names specifying the architectures
for which a test is expected to fail. None means all architectures.
"""
- return expectedFailureIfFn(
- _skip_for_android("xfailing on android", api_levels, archs), bugnumber
+ return expectedFailureIf(
+ _skip_fn_for_android("xfailing on android", api_levels, archs)(), bugnumber
)
@@ -612,7 +585,7 @@ def expectedFlakeyNetBSD(bugnumber=None, compilers=None):
def expectedFlakeyAndroid(bugnumber=None, api_levels=None, archs=None):
return expectedFlakey(
- _skip_for_android("flakey on android", api_levels, archs), bugnumber
+ _skip_fn_for_android("flakey on android", api_levels, archs), bugnumber
)
@@ -846,7 +819,7 @@ def skipIfTargetAndroid(bugnumber=None, api_levels=None, archs=None):
for which a test is skipped. None means all architectures.
"""
return skipTestIfFn(
- _skip_for_android("skipping for android", api_levels, archs), bugnumber
+ _skip_fn_for_android("skipping for android", api_levels, archs), bugnumber
)