From 63a44186137e2706afec0aef278cd5d123fc98dc Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Mon, 14 May 2018 14:48:22 +0200 Subject: Record which MenuNode has each property This allows accurate documentation to be generated for symbols and choices defined in multiple locations. There are now MenuNode.defaults, MenuNode.selects, etc., lists that mirror the corresponding Symbol/Choice lists. Symbol/Choice.__str__() now correctly show property locations as well, by simply concatenating the strings returned by MenuNode.__str__() for each node. _parse_properties() was modified to add all properties directly to the menu node instead of adding them to the contained symbol or choice. The properties are then copied up to symbols and choices in _finalize_tree(). Dependency propagation is handled at the same time. As a side effect, this cleans up the code a bit and de-bloats _parse_properties(). Update the menuconfig implementation to use the new functionality. It now lists the menu nodes for symbols and choices with the correct properties for each node (previously, all defaults, selects, implies, and ranges appeared on the first definition). --- testsuite.py | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) (limited to 'testsuite.py') diff --git a/testsuite.py b/testsuite.py index 3f29ae3..13793f1 100644 --- a/testsuite.py +++ b/testsuite.py @@ -528,12 +528,15 @@ config ADVANCED first help text config ADVANCED + tristate prompt "prompt 2" menuconfig ADVANCED + tristate prompt "prompt 3" config ADVANCED + tristate depends on (A || !B || (C && D) || !(E && F) || G = H || (I && !J && (K || L) && !(M || N) && O = P)) && DEP4 && DEP3 help second help text @@ -576,6 +579,61 @@ config OPTIONS option env="ENV" """) + verify_str(c.syms["CORRECT_PROP_LOCS_BOOL"], """ +config CORRECT_PROP_LOCS_BOOL + bool + prompt "prompt 1" if LOC_1 + default DEFAULT_1 if LOC_1 + default DEFAULT_2 if LOC_1 + select SELECT_1 if LOC_1 + select SELECT_2 if LOC_1 + imply IMPLY_1 if LOC_1 + imply IMPLY_2 if LOC_1 + depends on LOC_1 + help + help 1 + +menuconfig CORRECT_PROP_LOCS_BOOL + bool + prompt "prompt 2" if LOC_2 + default DEFAULT_3 if LOC_2 + default DEFAULT_4 if LOC_2 + select SELECT_3 if LOC_2 + select SELECT_4 if LOC_2 + imply IMPLY_3 if LOC_2 + imply IMPLY_4 if LOC_2 + depends on LOC_2 + help + help 2 + +config CORRECT_PROP_LOCS_BOOL + bool + prompt "prompt 3" if LOC_3 + default DEFAULT_5 if LOC_3 + default DEFAULT_6 if LOC_3 + select SELECT_5 if LOC_3 + select SELECT_6 if LOC_3 + imply IMPLY_5 if LOC_3 + imply IMPLY_6 if LOC_3 + depends on LOC_3 + help + help 2 +""") + + verify_str(c.syms["CORRECT_PROP_LOCS_INT"], """ +config CORRECT_PROP_LOCS_INT + int + range 1 2 if LOC_1 + range 3 4 if LOC_1 + depends on LOC_1 + +config CORRECT_PROP_LOCS_INT + int + range 5 6 if LOC_2 + range 7 8 if LOC_2 + depends on LOC_2 +""") + print("Testing Choice.__str__()") @@ -594,6 +652,45 @@ choice optional """) + verify_str(c.named_choices["CORRECT_PROP_LOCS_CHOICE"], """ +choice CORRECT_PROP_LOCS_CHOICE + bool + default CHOICE_3 if LOC_1 + depends on LOC_1 + +choice CORRECT_PROP_LOCS_CHOICE + bool + default CHOICE_4 if LOC_2 + depends on LOC_2 + +choice CORRECT_PROP_LOCS_CHOICE + bool + default CHOICE_5 if LOC_3 + depends on LOC_3 +""") + + + print("Testing MenuNode.__str__() for menus and comments") + + verify_str(c.syms["SIMPLE_MENU_HOOK"].nodes[0].next, """ +menu "simple menu" +""") + + verify_str(c.syms["ADVANCED_MENU_HOOK"].nodes[0].next, """ +menu "advanced menu" + depends on A + visible if B && (C || D) +""") + + verify_str(c.syms["SIMPLE_COMMENT_HOOK"].nodes[0].next, """ +comment "simple comment" +""") + + verify_str(c.syms["ADVANCED_COMMENT_HOOK"].nodes[0].next, """ +comment "advanced comment" + depends on A && B +""") + print("Testing Symbol.__repr__()") @@ -860,6 +957,18 @@ g fail("recursive 'source' did not raise exception") + print("Testing Symbol/Choice.direct_dep") + + c = Kconfig("Kconfiglib/tests/Kdirdep") + + verify_equal(expr_str(c.syms["NO_DEP_SYM"].direct_dep), '"y"') + verify_equal(expr_str(c.syms["DEP_SYM"].direct_dep), "A || (B && C) || !D") + + verify_equal(expr_str(c.named_choices["NO_DEP_CHOICE"].direct_dep), '"y"') + verify_equal(expr_str(c.named_choices["DEP_CHOICE"].direct_dep), + "A || B || C") + + print("Testing split_expr()") def verify_split(to_split, op, operand_strs): -- cgit v1.2.3