tests: add an include test case
authorAndrea Righi <andrea.righi@canonical.com>
Tue, 5 Dec 2023 13:53:15 +0000 (14:53 +0100)
committerAndrea Righi <andrea.righi@canonical.com>
Mon, 11 Dec 2023 10:00:49 +0000 (11:00 +0100)
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
tests/data/annotations.derivative.1 [new file with mode: 0644]
tests/data/annotations.derivative.1.result [new file with mode: 0644]
tests/test_derivative.py [new file with mode: 0644]

diff --git a/tests/data/annotations.derivative.1 b/tests/data/annotations.derivative.1
new file mode 100644 (file)
index 0000000..e72ac4c
--- /dev/null
@@ -0,0 +1,9 @@
+# Menu: HEADER
+# FORMAT: 4
+# ARCH: amd64 armhf
+# FLAVOUR: amd64-baz
+# FLAVOUR_DEP: {"amd64-baz": "amd64-foo"}
+
+include "annotations.load.1"
+
+CONFIG_B_2   policy<{'amd64': '5'}> note<override Config B_2>
diff --git a/tests/data/annotations.derivative.1.result b/tests/data/annotations.derivative.1.result
new file mode 100644 (file)
index 0000000..d2bfdea
--- /dev/null
@@ -0,0 +1,31 @@
+{
+    "arch": [
+        "amd64",
+        "armhf"
+    ],
+    "flavour": [
+        "amd64-baz"
+    ],
+    "flavour_dep": {
+        "amd64-baz": "amd64-foo"
+    },
+    "include": [
+        "annotations.load.1"
+    ],
+    "config": {
+        "CONFIG_A_1": {
+            "policy": {
+                "amd64": "1",
+                "armhf": "1"
+            },
+            "note": "'Config A_1'"
+        },
+        "CONFIG_B_2": {
+            "policy": {
+                "amd64": "5",
+                "armhf": "2"
+            },
+            "note": "'override Config B_2'"
+        }
+    }
+}
diff --git a/tests/test_derivative.py b/tests/test_derivative.py
new file mode 100644 (file)
index 0000000..47ca5c0
--- /dev/null
@@ -0,0 +1,14 @@
+import unittest
+
+from tests import utils
+
+from kconfig.annotations import Annotation
+
+
+class TestLoadAnnotations(unittest.TestCase):
+    def test_load(self):
+        for d in ("annotations.derivative.1",):
+            f = "tests/data/" + d
+            a = Annotation(f)
+            r = utils.load_json(f + ".result")
+            self.assertEqual(utils.to_dict(a), r)