Skip to content

Commit 199ec40

Browse files
committed
[lldb][NFC] Refactor _get_bool_config_skip_if_decorator
NFC preparation for another patch. Also add some documentation for why the error value is true (and not false).
1 parent cab9f69 commit 199ec40

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -830,11 +830,20 @@ def skipIfAsan(func):
830830
"""Skip this test if the environment is set up to run LLDB *itself* under ASAN."""
831831
return skipTestIfFn(is_running_under_asan)(func)
832832

833-
def _get_bool_config_skip_if_decorator(key):
833+
def _get_bool_config(key, fail_value = True):
834+
"""
835+
Returns the current LLDB's build config value.
836+
:param key The key to lookup in LLDB's build configuration.
837+
:param fail_value The error value to return when the key can't be found.
838+
Defaults to true so that if an unknown key is lookup up we rather
839+
enable more tests (that then fail) than silently skipping them.
840+
"""
834841
config = lldb.SBDebugger.GetBuildConfiguration()
835842
value_node = config.GetValueForKey(key)
836-
fail_value = True # More likely to notice if something goes wrong
837-
have = value_node.GetValueForKey("value").GetBooleanValue(fail_value)
843+
return value_node.GetValueForKey("value").GetBooleanValue(fail_value)
844+
845+
def _get_bool_config_skip_if_decorator(key):
846+
have = _get_bool_config(key)
838847
return unittest2.skipIf(not have, "requires " + key)
839848

840849
def skipIfCursesSupportMissing(func):

0 commit comments

Comments
 (0)