summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kconfiglib.py2
-rw-r--r--tests/Krecursive12
-rw-r--r--tests/Krecursive22
-rw-r--r--testsuite.py106
4 files changed, 102 insertions, 10 deletions
diff --git a/kconfiglib.py b/kconfiglib.py
index 3b4e8d7..a16a215 100644
--- a/kconfiglib.py
+++ b/kconfiglib.py
@@ -1551,7 +1551,7 @@ class Kconfig(object):
"\n{}:{}: Recursive 'source' of '{}' detected. Check that "
"environment variables are set correctly.\n"
"Backtrace:\n{}"
- .format(self._filename, self._linenr, filename,
+ .format(self._filename, self._linenr, rel_filename,
"\n".join("{}:{}".format(name, linenr)
for name, linenr, _
in reversed(self._filestack))))
diff --git a/tests/Krecursive1 b/tests/Krecursive1
index c4008c2..35b521a 100644
--- a/tests/Krecursive1
+++ b/tests/Krecursive1
@@ -1 +1 @@
-source "Kconfiglib/tests/Krecursive2"
+source "tests/Krecursive2"
diff --git a/tests/Krecursive2 b/tests/Krecursive2
index 5032b29..9f9f00e 100644
--- a/tests/Krecursive2
+++ b/tests/Krecursive2
@@ -1 +1 @@
-source "Kconfiglib/tests/Krecursive1"
+source "tests/Krecursive1"
diff --git a/testsuite.py b/testsuite.py
index 5c90f33..0cc472e 100644
--- a/testsuite.py
+++ b/testsuite.py
@@ -1038,20 +1038,27 @@ g
try:
Kconfig("tests/Krecursive1")
- except KconfigError:
- pass
+ except KconfigError as e:
+ verify_equal(str(e), """
+tests/Krecursive2:1: Recursive 'source' of 'tests/Krecursive1' detected. Check that environment variables are set correctly.
+Backtrace:
+tests/Krecursive2:1
+tests/Krecursive1:1
+"""[:-1])
except:
fail("recursive 'source' raised wrong exception")
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("tests/Kmissingsource")
- except KconfigError:
- pass
+ except KconfigError as e:
+ if "does not exist" not in str(e):
+ fail("'source' with missing file raised wrong KconfigError")
except:
fail("'source' with missing file raised wrong exception")
else:
@@ -1059,8 +1066,9 @@ g
try:
Kconfig("tests/Kmissingrsource")
- except KconfigError:
- pass
+ except KconfigError as e:
+ if "does not exist" not in str(e):
+ fail("'rsource' with missing file raised wrong KconfigError")
except:
fail("'rsource' with missing file raised wrong exception")
else:
@@ -2186,10 +2194,94 @@ CONFIG_G=-1
try:
Kconfig(filename)
except KconfigError as e:
- pass
+ if "Dependency loop" not in str(e):
+ fail("dependency loop in {} raised wrong KconfigError"
+ .format(filename))
+ except:
+ fail("dependency loop in {} raised wrong exception"
+ .format(filename))
else:
fail("dependency loop in {} not detected".format(filename))
+ # Check the most complicated message completely
+ try:
+ Kconfig("Kconfiglib/tests/Kdeploop10")
+ except KconfigError as e:
+ verify_equal(str(e), """
+Dependency loop
+===============
+
+A (defined at Kconfiglib/tests/Kdeploop10:1), with definition...
+
+config A
+ bool
+ depends on B
+
+...depends on B (defined at Kconfiglib/tests/Kdeploop10:5), with definition...
+
+config B
+ bool
+ depends on C = 7
+
+...depends on C (defined at Kconfiglib/tests/Kdeploop10:9), with definition...
+
+config C
+ int
+ range D 8
+
+...depends on D (defined at Kconfiglib/tests/Kdeploop10:13), with definition...
+
+config D
+ int
+ default 3 if E
+ default 8
+
+...depends on E (defined at Kconfiglib/tests/Kdeploop10:18), with definition...
+
+config E
+ bool
+
+(select-related dependencies: F && G)
+
+...depends on G (defined at Kconfiglib/tests/Kdeploop10:25), with definition...
+
+config G
+ bool
+ depends on H
+
+...depends on the choice symbol H (defined at Kconfiglib/tests/Kdeploop10:32), with definition...
+
+config H
+ bool
+ prompt "H" if I && <choice>
+ depends on I && <choice>
+
+...depends on the choice symbol I (defined at Kconfiglib/tests/Kdeploop10:41), with definition...
+
+config I
+ bool
+ prompt "I" if <choice>
+ depends on <choice>
+
+...depends on <choice> (defined at Kconfiglib/tests/Kdeploop10:38), with definition...
+
+choice
+ bool
+ prompt "choice" if J
+
+...depends on J (defined at Kconfiglib/tests/Kdeploop10:46), with definition...
+
+config J
+ bool
+ depends on A
+
+...depends again on A (defined at Kconfiglib/tests/Kdeploop10:1)
+"""[:-1])
+ except:
+ fail("Loop detection message check raised wrong exception")
+ else:
+ fail("Loop detection message check did not raise exception")
+
print("Testing preprocessor")