diff options
| -rw-r--r-- | kconfiglib.py | 8 | ||||
| -rw-r--r-- | tests/Kchoice | 24 | ||||
| -rw-r--r-- | testsuite.py | 27 |
3 files changed, 53 insertions, 6 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index 30b1493..b408900 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -1055,7 +1055,7 @@ class Config(object): # Symbol or Choice # See comment for 'menu_dep' - stmt.menu_dep = depends_on_expr + stmt.menu_dep = _make_and(deps, depends_on_expr) # Propagate dependencies to prompts @@ -2369,9 +2369,9 @@ class Symbol(Item): # dependencies inherited from enclosing menus and ifs self.all_referenced_syms = set() - # This records only dependencies specified with 'depends on'. Needed - # when determining actual choice items (hrrrr...). See also - # Choice._determine_actual_symbols(). + # This records only dependencies from enclosing ifs and menus together + # with local 'depends on' dependencies. Needed when determining actual + # choice items (hrrrr...). See Choice._determine_actual_symbols(). self.menu_dep = None # See Symbol.get_ref/def_locations(). diff --git a/tests/Kchoice b/tests/Kchoice index 481e438..1e841ca 100644 --- a/tests/Kchoice +++ b/tests/Kchoice @@ -111,3 +111,27 @@ config MMT_4 config MMT_5 bool endchoice + +# Choice with symbols that shouldn't be considered choice symbols because they +# depend on the preceding symbol. This might be a kconfig bug, but some things +# use it, so we need to emulate it. + +choice WEIRD_SYMS + bool "weird symbols that aren't considered part of the choice" + +# Only WS1 is part of the choice +config WS1 +config WS2 + depends on WS1 +config WS3 + depends on WS2 +config WS4 + depends on WS1 + +# 'if' has the same effect, so only WS5 is part of the choice +config WS5 +if WS5 +config WS6 +endif + +endchoice diff --git a/testsuite.py b/testsuite.py index f1bbe9e..c8f504c 100644 --- a/testsuite.py +++ b/testsuite.py @@ -1672,8 +1672,8 @@ def run_selftests(): choice_bool, choice_bool_opt, choice_tristate, choice_tristate_opt, \ choice_bool_m, choice_tristate_m, choice_defaults, \ choice_no_type_bool, choice_no_type_tristate, \ - choice_missing_member_type_1, choice_missing_member_type_2 \ - = c.get_choices() + choice_missing_member_type_1, choice_missing_member_type_2, \ + choice_weird_syms = c.get_choices() for choice in (choice_bool, choice_bool_opt, choice_bool_m, choice_defaults): @@ -1805,6 +1805,29 @@ def run_selftests(): (kconfiglib.BOOL, kconfiglib.BOOL), "Wrong types for second choice with missing member types") + # Verify that symbols in choices that depend on the preceding symbol aren't + # considered choice symbols + + def verify_is_normal_choice_symbol(sym): + verify(sym.is_choice_symbol() and + sym in choice_weird_syms.get_symbols() and + sym.get_parent() is choice_weird_syms, + "{} should be a normal choice symbol".format(sym.get_name())) + + def verify_is_weird_choice_symbol(sym): + verify(not sym.is_choice_symbol() and + sym not in choice_weird_syms.get_symbols() and + sym in choice_weird_syms.get_items() and + sym.get_parent() is choice_weird_syms, + "{} should be a weird (non-)choice symbol") + + verify_is_normal_choice_symbol(c["WS1"]) + verify_is_weird_choice_symbol(c["WS2"]) + verify_is_weird_choice_symbol(c["WS3"]) + verify_is_weird_choice_symbol(c["WS4"]) + verify_is_normal_choice_symbol(c["WS5"]) + verify_is_weird_choice_symbol(c["WS6"]) + # # Object dependencies # |
