summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaman Tenneti <rtenneti@google.com>2021-01-11 12:18:47 -0800
committerRaman Tenneti <rtenneti@google.com>2021-01-12 21:49:13 +0000
commit48b2d10d8f7565173ca53bed0d0be15323512de4 (patch)
treea6d4eee0c9fcaa8c420a4745bb03749510d85488
parent0588f3dc527509d9de2fb1467a6d8eeb96292bc0 (diff)
downloadgit-repo-48b2d10d8f7565173ca53bed0d0be15323512de4.tar.gz
manifest_xml: - Added doc and testing of unknown tags/elements.
Added this test to verify that older versions of repo can handle "<superproject" element. Tested by adding "<iankaz" unknown element. Tested the code with the following commands. $ ./run_tests tests/test_manifest_xml.py $ ./run_tests -v Bug: https://crbug.com/gerrit/13709 Tested-by: Raman Tenneti <rtenneti@google.com> Change-Id: I858d56f38cefcfcd14474efdd631a5a940c3ce47 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/293482 Reviewed-by: Mike Frysinger <vapier@google.com>
-rw-r--r--docs/manifest-format.md6
-rw-r--r--tests/test_manifest_xml.py21
2 files changed, 27 insertions, 0 deletions
diff --git a/docs/manifest-format.md b/docs/manifest-format.md
index 8e5e2874..6156333a 100644
--- a/docs/manifest-format.md
+++ b/docs/manifest-format.md
@@ -109,6 +109,12 @@ following DTD:
109]> 109]>
110``` 110```
111 111
112For compatibility purposes across repo releases, all unknown elements are
113silently ignored. However, repo reserves all possible names for itself for
114future use. If you want to use custom elements, the `x-*` namespace is
115reserved for that purpose, and repo guarantees to never allocate any
116corresponding names.
117
112A description of the elements and their attributes follows. 118A description of the elements and their attributes follows.
113 119
114 120
diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py
index e4adf3c9..e2c83af9 100644
--- a/tests/test_manifest_xml.py
+++ b/tests/test_manifest_xml.py
@@ -280,6 +280,27 @@ class XmlManifestTests(unittest.TestCase):
280 '<superproject name="superproject"/>' + 280 '<superproject name="superproject"/>' +
281 '</manifest>') 281 '</manifest>')
282 282
283 def test_unknown_tags(self):
284 """Check superproject settings."""
285 manifest = self.getXmlManifest("""
286<manifest>
287 <remote name="test-remote" fetch="http://localhost" />
288 <default remote="test-remote" revision="refs/heads/main" />
289 <superproject name="superproject"/>
290 <iankaz value="unknown (possible) future tags are ignored"/>
291 <x-custom-tag>X tags are always ignored</x-custom-tag>
292</manifest>
293""")
294 self.assertEqual(manifest.superproject['name'], 'superproject')
295 self.assertEqual(manifest.superproject['remote'].name, 'test-remote')
296 self.assertEqual(
297 manifest.ToXml().toxml(),
298 '<?xml version="1.0" ?><manifest>' +
299 '<remote name="test-remote" fetch="http://localhost"/>' +
300 '<default remote="test-remote" revision="refs/heads/main"/>' +
301 '<superproject name="superproject"/>' +
302 '</manifest>')
303
283 def test_project_group(self): 304 def test_project_group(self):
284 """Check project group settings.""" 305 """Check project group settings."""
285 manifest = self.getXmlManifest(""" 306 manifest = self.getXmlManifest("""