Skip to content

[lldb][test] Remove expectedFailureIfFn #81703

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 6 additions & 33 deletions lldb/packages/Python/lldbsuite/test/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,33 +128,6 @@ def expectedFailure_impl(func):
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):
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
)


Expand Down Expand Up @@ -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
)


Expand Down Expand Up @@ -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
)


Expand Down
4 changes: 2 additions & 2 deletions lldb/test/API/commands/platform/sdk/TestPlatformSDK.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def port_not_available(self):

@no_debug_info_test
@skipUnlessDarwin
@expectedFailureIfFn(no_debugserver)
@expectedFailureIfFn(port_not_available)
@skipTestIfFn(no_debugserver)
@skipTestIfFn(port_not_available)
@skipIfRemote
def test_macos_sdk(self):
self.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_breakpoint(self):
breakpoint = target.BreakpointCreateByLocation("main.c", 1)
self.assertTrue(breakpoint.IsHardware())

@expectedFailureIfFn(HardwareBreakpointTestBase.supports_hw_breakpoints)
@skipTestIfFn(HardwareBreakpointTestBase.supports_hw_breakpoints)
def test_step_range(self):
"""Test stepping when hardware breakpoints are required."""
self.build()
Expand All @@ -49,7 +49,7 @@ def test_step_range(self):
"Could not create hardware breakpoint for thread plan" in error.GetCString()
)

@expectedFailureIfFn(HardwareBreakpointTestBase.supports_hw_breakpoints)
@skipTestIfFn(HardwareBreakpointTestBase.supports_hw_breakpoints)
def test_step_out(self):
"""Test stepping out when hardware breakpoints are required."""
self.build()
Expand All @@ -71,7 +71,7 @@ def test_step_out(self):
"Could not create hardware breakpoint for thread plan" in error.GetCString()
)

@expectedFailureIfFn(HardwareBreakpointTestBase.supports_hw_breakpoints)
@skipTestIfFn(HardwareBreakpointTestBase.supports_hw_breakpoints)
def test_step_over(self):
"""Test stepping over when hardware breakpoints are required."""
self.build()
Expand All @@ -91,7 +91,7 @@ def test_step_over(self):

# Was reported to sometimes pass on certain hardware.
@skipIf(oslist=["linux"], archs=["arm"])
@expectedFailureIfFn(HardwareBreakpointTestBase.supports_hw_breakpoints)
@skipTestIfFn(HardwareBreakpointTestBase.supports_hw_breakpoints)
def test_step_until(self):
"""Test stepping until when hardware breakpoints are required."""
self.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ def test_stop_default_platform_async(self):

@skipUnlessDarwin
@skipIfRemote
@expectedFailureIfFn(no_debugserver)
@expectedFailureIfFn(port_not_available)
@skipTestIfFn(no_debugserver)
@skipTestIfFn(port_not_available)
def test_stop_remote_platform_sync(self):
self.do_test_stop_at_entry(True, True)

@skipUnlessDarwin
@skipIfRemote
@expectedFailureIfFn(no_debugserver)
@expectedFailureIfFn(port_not_available)
@skipTestIfFn(no_debugserver)
@skipTestIfFn(port_not_available)
def test_stop_remote_platform_async(self):
self.do_test_stop_at_entry(False, True)

Expand Down