Skip to content

Commit 8bed754

Browse files
authored
[lldb][test] Add pexpect category for tests that import pexpect (#84860)
Instead of directly annotating pexpect-based tests with `@skipIfWindows`, we can tag them with a new `pexpect` category. We still automatically skip windows behavior by adding `pexpect` to the skip category list if the platform is windows, but also allow non-Windows users to skip them by configuring cmake with `-DLLDB_TEST_USER_ARGS=--skip-category=pexpect` As a prerequisite, remove the restriction that `@add_test_categories` can only apply to test cases, and we make the test runner look for categories on both the class and the test method.
1 parent cd8843f commit 8bed754

File tree

12 files changed

+26
-32
lines changed

12 files changed

+26
-32
lines changed

lldb/packages/Python/lldbsuite/test/decorators.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,6 @@ def add_test_categories(cat):
409409
cat = test_categories.validate(cat, True)
410410

411411
def impl(func):
412-
if isinstance(func, type) and issubclass(func, unittest.TestCase):
413-
raise Exception(
414-
"@add_test_categories can only be used to decorate a test method"
415-
)
416412
try:
417413
if hasattr(func, "categories"):
418414
cat.extend(func.categories)

lldb/packages/Python/lldbsuite/test/dotest.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,18 @@ def checkForkVForkSupport():
914914
configuration.skip_categories.append("fork")
915915

916916

917+
def checkPexpectSupport():
918+
from lldbsuite.test import lldbplatformutil
919+
920+
platform = lldbplatformutil.getPlatform()
921+
922+
# llvm.org/pr22274: need a pexpect replacement for windows
923+
if platform in ["windows"]:
924+
if configuration.verbose:
925+
print("pexpect tests will be skipped because of unsupported platform")
926+
configuration.skip_categories.append("pexpect")
927+
928+
917929
def run_suite():
918930
# On MacOS X, check to make sure that domain for com.apple.DebugSymbols defaults
919931
# does not exist before proceeding to running the test suite.
@@ -1013,6 +1025,7 @@ def run_suite():
10131025
checkDebugServerSupport()
10141026
checkObjcSupport()
10151027
checkForkVForkSupport()
1028+
checkPexpectSupport()
10161029

10171030
skipped_categories_list = ", ".join(configuration.skip_categories)
10181031
print(

lldb/packages/Python/lldbsuite/test/lldbpexpect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
@skipIfRemote
13-
@skipIfWindows # llvm.org/pr22274: need a pexpect replacement for windows
13+
@add_test_categories(["pexpect"])
1414
class PExpectTest(TestBase):
1515
NO_DEBUG_INFO_TESTCASE = True
1616
PROMPT = "(lldb) "

lldb/packages/Python/lldbsuite/test/test_categories.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"lldb-server": "Tests related to lldb-server",
3434
"lldb-dap": "Tests for the Debug Adaptor Protocol with lldb-dap",
3535
"llgs": "Tests for the gdb-server functionality of lldb-server",
36+
"pexpect": "Tests requiring the pexpect library to be available",
3637
"objc": "Tests related to the Objective-C programming language support",
3738
"pyapi": "Tests related to the Python API",
3839
"std-module": "Tests related to importing the std module",

lldb/packages/Python/lldbsuite/test/test_result.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,11 @@ def getCategoriesForTest(self, test):
148148
Gets all the categories for the currently running test method in test case
149149
"""
150150
test_categories = []
151+
test_categories.extend(getattr(test, "categories", []))
152+
151153
test_method = getattr(test, test._testMethodName)
152-
if test_method is not None and hasattr(test_method, "categories"):
153-
test_categories.extend(test_method.categories)
154+
if test_method is not None:
155+
test_categories.extend(getattr(test_method, "categories", []))
154156

155157
test_categories.extend(self._getFileBasedCategories(test))
156158

lldb/test/API/benchmarks/expression/TestExpressionCmd.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ def setUp(self):
1717
self.count = 25
1818

1919
@benchmarks_test
20-
@expectedFailureAll(
21-
oslist=["windows"],
22-
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows",
23-
)
20+
@add_test_categories(["pexpect"])
2421
def test_expr_cmd(self):
2522
"""Test lldb's expression commands and collect statistics."""
2623
self.build()

lldb/test/API/benchmarks/expression/TestRepeatedExprs.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ def setUp(self):
1919
self.count = 100
2020

2121
@benchmarks_test
22-
@expectedFailureAll(
23-
oslist=["windows"],
24-
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows",
25-
)
22+
@add_test_categories(["pexpect"])
2623
def test_compare_lldb_to_gdb(self):
2724
"""Test repeated expressions with lldb vs. gdb."""
2825
self.build()

lldb/test/API/benchmarks/frame_variable/TestFrameVariableResponse.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ def setUp(self):
1717

1818
@benchmarks_test
1919
@no_debug_info_test
20-
@expectedFailureAll(
21-
oslist=["windows"],
22-
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows",
23-
)
20+
@add_test_categories(["pexpect"])
2421
def test_startup_delay(self):
2522
"""Test response time for the 'frame variable' command."""
2623
print()

lldb/test/API/benchmarks/startup/TestStartupDelays.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ def setUp(self):
2222

2323
@benchmarks_test
2424
@no_debug_info_test
25-
@expectedFailureAll(
26-
oslist=["windows"],
27-
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows",
28-
)
25+
@add_test_categories(["pexpect"])
2926
def test_startup_delay(self):
3027
"""Test start up delays creating a target, setting a breakpoint, and run to breakpoint stop."""
3128
print()

lldb/test/API/benchmarks/stepping/TestSteppingSpeed.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ def setUp(self):
2222

2323
@benchmarks_test
2424
@no_debug_info_test
25-
@expectedFailureAll(
26-
oslist=["windows"],
27-
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows",
28-
)
25+
@add_test_categories(["pexpect"])
2926
def test_run_lldb_steppings(self):
3027
"""Test lldb steppings on a large executable."""
3128
print()

lldb/test/API/benchmarks/turnaround/TestCompileRunToBreakpointTurnaround.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ def setUp(self):
2121

2222
@benchmarks_test
2323
@no_debug_info_test
24-
@expectedFailureAll(
25-
oslist=["windows"],
26-
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows",
27-
)
24+
@add_test_categories(["pexpect"])
2825
def test_run_lldb_then_gdb(self):
2926
"""Benchmark turnaround time with lldb vs. gdb."""
3027
print()

lldb/test/API/terminal/TestSTTYBeforeAndAfter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def classCleanup(cls):
1919
cls.RemoveTempFile("child_send2.txt")
2020
cls.RemoveTempFile("child_read2.txt")
2121

22-
@skipIfWindows # llvm.org/pr22274: need a pexpect replacement for windows
22+
@add_test_categories(["pexpect"])
2323
@no_debug_info_test
2424
def test_stty_dash_a_before_and_afetr_invoking_lldb_command(self):
2525
"""Test that 'stty -a' displays the same output before and after running the lldb command."""

0 commit comments

Comments
 (0)