[Lldb-commits] [lldb] 199ec40 - [lldb][NFC] Refactor _get_bool_config_skip_if_decorator

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Wed Dec 9 11:02:52 PST 2020


Author: Raphael Isemann
Date: 2020-12-09T20:02:06+01:00
New Revision: 199ec40e7bcc8548282d803b1a43b1ae1d3b57ce

URL: https://github.com/llvm/llvm-project/commit/199ec40e7bcc8548282d803b1a43b1ae1d3b57ce
DIFF: https://github.com/llvm/llvm-project/commit/199ec40e7bcc8548282d803b1a43b1ae1d3b57ce.diff

LOG: [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).

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py
index 2013c5241007..bcf665f6cc4c 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -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):


        


More information about the lldb-commits mailing list