OSDN Git Service

[lldb][NFC] Refactor _get_bool_config_skip_if_decorator
authorRaphael Isemann <teemperor@gmail.com>
Wed, 9 Dec 2020 19:02:00 +0000 (20:02 +0100)
committerRaphael Isemann <teemperor@gmail.com>
Wed, 9 Dec 2020 19:02:06 +0000 (20:02 +0100)
NFC preparation for another patch. Also add some documentation for why the
error value is true (and not false).

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

index 2013c52..bcf665f 100644 (file)
@@ -830,11 +830,20 @@ def skipIfAsan(func):
     """Skip this test if the environment is set up to run LLDB *itself* under ASAN."""
     return skipTestIfFn(is_running_under_asan)(func)
 
-def _get_bool_config_skip_if_decorator(key):
+def _get_bool_config(key, fail_value = True):
+    """
+    Returns the current LLDB's build config value.
+    :param key The key to lookup in LLDB's build configuration.
+    :param fail_value The error value to return when the key can't be found.
+           Defaults to true so that if an unknown key is lookup up we rather
+           enable more tests (that then fail) than silently skipping them.
+    """
     config = lldb.SBDebugger.GetBuildConfiguration()
     value_node = config.GetValueForKey(key)
-    fail_value = True # More likely to notice if something goes wrong
-    have = value_node.GetValueForKey("value").GetBooleanValue(fail_value)
+    return value_node.GetValueForKey("value").GetBooleanValue(fail_value)
+
+def _get_bool_config_skip_if_decorator(key):
+    have = _get_bool_config(key)
     return unittest2.skipIf(not have, "requires " + key)
 
 def skipIfCursesSupportMissing(func):