Skip to content

Commit

Permalink
[dotest] Add @skipIfCursesSupportMissing and annotate the new gui test
Browse files Browse the repository at this point in the history
Summary:
The gui command requires curses support, which can be disabled at
compile time. This patch adds the ability to detect this situation in
the test suite and skip the test accordingly.

Reviewers: teemperor, jankratochvil

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D67073

llvm-svn: 370658
  • Loading branch information
labath committed Sep 2, 2019
1 parent 491fc23 commit eafede2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
Expand Up @@ -11,6 +11,7 @@ class BasicGuiCommandTest(PExpectTest):

mydir = TestBase.compute_mydir(__file__)

@skipIfCursesSupportMissing
def test_gui(self):
self.build()

Expand Down
Expand Up @@ -6,10 +6,8 @@ class GuiTestCase(TestBase):

mydir = TestBase.compute_mydir(__file__)

def setUp(self):
TestBase.setUp(self)

@no_debug_info_test
@skipIfCursesSupportMissing
def test_reproducer_generate_invalid_invocation(self):
self.expect("gui blub", error=True,
substrs=["the gui command takes no arguments."])
15 changes: 10 additions & 5 deletions lldb/packages/Python/lldbsuite/test/decorators.py
Expand Up @@ -783,13 +783,18 @@ def is_compiler_with_address_sanitizer(self):
return None
return skipTestIfFn(is_compiler_with_address_sanitizer)(func)

def skipIfXmlSupportMissing(func):
def _get_bool_config_skip_if_decorator(key):
config = lldb.SBDebugger.GetBuildConfiguration()
xml = config.GetValueForKey("xml")

value_node = config.GetValueForKey(key)
fail_value = True # More likely to notice if something goes wrong
have_xml = xml.GetValueForKey("value").GetBooleanValue(fail_value)
return unittest2.skipIf(not have_xml, "requires xml support")(func)
have = value_node.GetValueForKey("value").GetBooleanValue(fail_value)
return unittest2.skipIf(not have, "requires " + key)

def skipIfCursesSupportMissing(func):
return _get_bool_config_skip_if_decorator("curses")(func)

def skipIfXmlSupportMissing(func):
return _get_bool_config_skip_if_decorator("xml")(func)

def skipIfLLVMTargetMissing(target):
config = lldb.SBDebugger.GetBuildConfiguration()
Expand Down
7 changes: 7 additions & 0 deletions lldb/source/API/SBDebugger.cpp
Expand Up @@ -624,6 +624,13 @@ SBStructuredData SBDebugger::GetBuildConfiguration() {
AddBoolConfigEntry(
*config_up, "xml", XMLDocument::XMLEnabled(),
"A boolean value that indicates if XML support is enabled in LLDB");
bool have_curses = true;
#ifdef LLDB_DISABLE_CURSES
have_curses = false;
#endif
AddBoolConfigEntry(
*config_up, "curses", have_curses,
"A boolean value that indicates if curses support is enabled in LLDB");
AddLLVMTargets(*config_up);

SBStructuredData data;
Expand Down

0 comments on commit eafede2

Please sign in to comment.