From 352c93b68084e97ec7a3c09f0bd3f2a161290211 Mon Sep 17 00:00:00 2001 From: Fredrik de Groot Date: Tue, 6 Oct 2020 12:55:14 +0200 Subject: manifest: add support for groups in include Attrib groups can now be added to manifest include, thus all projects in an included manifest file can easily be tagged with a group without modifying all projects in that manifest file. Include groups will add and recurse, meaning included manifest projects will carry all parent includes. Intentionally, no support added for group remove, to keep complexity down. Group handling for projects is untouched, meaning a group set on a project will still append to whatever was or was not inherited in parent manifest includes, resulting in union of groups inherited and set for the project itself. Test: manual multi-level manifest include structure, in serial and parallel, with different groups set on init Test: added unit tests to cover the inheritance Change-Id: Id2229aa6fd78d355ba598cc15c701b2ee71e5c6f Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/283587 Tested-by: Fredrik de Groot Reviewed-by: Mike Frysinger --- tests/test_manifest_xml.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'tests/test_manifest_xml.py') diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py index 40385cce..939717be 100644 --- a/tests/test_manifest_xml.py +++ b/tests/test_manifest_xml.py @@ -235,3 +235,46 @@ class XmlManifestTests(unittest.TestCase): self.assertCountEqual( result['extras'], ['g1', 'g2', 'g1', 'name:extras', 'all', 'path:path']) + + def test_include_levels(self): + root_m = os.path.join(self.manifest_dir, 'root.xml') + with open(root_m, 'w') as fp: + fp.write(""" + + + + + + + +""") + with open(os.path.join(self.manifest_dir, 'level1.xml'), 'w') as fp: + fp.write(""" + + + + +""") + with open(os.path.join(self.manifest_dir, 'level2.xml'), 'w') as fp: + fp.write(""" + + + +""") + include_m = manifest_xml.XmlManifest(self.repodir, root_m) + for proj in include_m.projects: + if proj.name == 'root-name1': + # Check include group not set on root level proj. + self.assertNotIn('level1-group', proj.groups) + if proj.name == 'root-name2': + # Check root proj group not removed. + self.assertIn('r2g1', proj.groups) + if proj.name == 'level1-name1': + # Check level1 proj has inherited group level 1. + self.assertIn('level1-group', proj.groups) + if proj.name == 'level2-name1': + # Check level2 proj has inherited group levels 1 and 2. + self.assertIn('level1-group', proj.groups) + self.assertIn('level2-group', proj.groups) + # Check level2 proj group not removed. + self.assertIn('l2g1', proj.groups) -- cgit v1.2.3-54-g00ecf