summaryrefslogtreecommitdiff
path: root/testsuite.py
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2018-07-15 13:16:47 +0200
committerUlf Magnusson <ulfalizer@gmail.com>2018-07-15 16:15:43 +0200
commit7a428aa415606820a44291f475248b08e3952c4b (patch)
tree6971486eabcf992acec01ae416bb69633d7ee44f /testsuite.py
parentd8a7421d231e504e5b1409d9ed3137b147b3db8d (diff)
Switch to more sensible globbing statements (w/ backwards compatibility)
Instead of having 'source' and 'gsource', have 'source' always glob, but require the pattern to match at least one file, throwing KconfigError otherwise. Have separate 'osource' and 'orsource' statements (the o is for "optional") for cases where it's okay for the pattern to not match any files. This is analogous to 'include' and '-include' in Make. The biggest flaw with 'gsource' was that there was no way to do a globbing match while requiring something to match, possibly leading to subtle failures. Preserve backwards compatibility by having "gsource" and "grsource" be aliases for "osource" and "orsource", respectively. Also include some related changes: - Kconfig.srctree is now set to the empty string if $srctree is unset, rather than to None. This gives nice behavior with os.path.join() and os.path.relpath(), which treat the empty string as the current directory (without adding './', for os.path.join()). - When $srctree is set, Kconfig files in the current directory will no longer override Kconfig files in $srctree when the relative paths match. This was likely a bug all along in the C tools, and probably only makes sense for .config files. I've seen it cause breakage in Zephyr. - Clarify the behavior of $srctree in the Kconfig.__init__() docstring. - Make MenuNode.filename be relative to $srctree for the Kconfig file passed to Kconfig.__init__(). This makes it consistent. The major version will be bumped later due to the small Kconfig.srctree API change.
Diffstat (limited to 'testsuite.py')
-rw-r--r--testsuite.py33
1 files changed, 30 insertions, 3 deletions
diff --git a/testsuite.py b/testsuite.py
index 189a325..0f42d69 100644
--- a/testsuite.py
+++ b/testsuite.py
@@ -807,7 +807,7 @@ comment "advanced comment"
print("Testing Kconfig.__repr__()")
verify_repr(c, """
-<configuration with 14 symbols, main menu prompt "Main menu", srctree not set, config symbol prefix "CONFIG_", warnings disabled, printing of warnings to stderr enabled, undef. symbol assignment warnings disabled, redundant symbol assignment warnings enabled>
+<configuration with 14 symbols, main menu prompt "Main menu", srctree is current directory, config symbol prefix "CONFIG_", warnings disabled, printing of warnings to stderr enabled, undef. symbol assignment warnings disabled, redundant symbol assignment warnings enabled>
""")
os.environ["srctree"] = "srctree value"
@@ -902,7 +902,7 @@ g
os.environ["srctree"] = srctree
# Has symbol with empty help text, so disable warnings
- c = Kconfig("tests/Klocation", warn=False)
+ c = Kconfig("Kconfiglib/tests/Klocation", warn=False)
verify_locations(c.syms["SINGLE_DEF"].nodes, "tests/Klocation:4")
@@ -913,9 +913,13 @@ g
"tests/sub/Klocation_rsourced:2",
"tests/sub/Klocation_gsourced1:1",
"tests/sub/Klocation_gsourced2:1",
+ "tests/sub/Klocation_gsourced1:1",
+ "tests/sub/Klocation_gsourced2:1",
"tests/sub/Klocation_grsourced1:1",
"tests/sub/Klocation_grsourced2:1",
- "tests/Klocation:60")
+ "tests/sub/Klocation_grsourced1:1",
+ "tests/sub/Klocation_grsourced2:1",
+ "tests/Klocation:70")
verify_locations(c.named_choices["CHOICE"].nodes,
"tests/Klocation_sourced:5")
@@ -937,6 +941,27 @@ g
else:
fail("recursive 'source' did not raise exception")
+ # Verify that source and rsource throw exceptions for missing files
+ # TODO: Make an exception test helper
+
+ try:
+ Kconfig("Kconfiglib/tests/Kmissingsource")
+ except KconfigError:
+ pass
+ except:
+ fail("'source' with missing file raised wrong exception")
+ else:
+ fail("'source' with missing file did not raise exception")
+
+ try:
+ Kconfig("Kconfiglib/tests/Kmissingrsource")
+ except KconfigError:
+ pass
+ except:
+ fail("'rsource' with missing file raised wrong exception")
+ else:
+ fail("'rsource' with missing file did not raise exception")
+
os.environ.pop("srctree", None)
@@ -1453,6 +1478,8 @@ g
verify(c.defconfig_filename == "Kconfiglib/tests/sub/defconfig_in_sub",
"defconfig_filename gave wrong file with $srctree set")
+ os.environ.pop("srctree", None)
+
print("Testing mainmenu_text")