summaryrefslogtreecommitdiffstats
path: root/tests/test_manifest_xml.py
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2021-09-26 23:20:32 -0700
committerXin Li <delphij@google.com>2021-09-27 06:36:05 +0000
commite0b16a22a01c54a00a9e4a0c53dddfce3b0d59d6 (patch)
tree7759c55cdbe045de3974be17bc3a5557d42619db /tests/test_manifest_xml.py
parentd669d2dee5bd7986593d5df1dd8a736778501bbf (diff)
downloadgit-repo-e0b16a22a01c54a00a9e4a0c53dddfce3b0d59d6.tar.gz
superproject: support a new revision attribute.
Tested: $ ./run_tests Verified that a manifest that specified superproject revision would use the specified revision, and superproject will use the default revision. Note that this is a slight behavior change from earlier repo versions, which would always use the branch name of the manifest itself. However, the new behavior would be more consisitent with regular "project" element and would allow superproject be used even if it is not enabled for the particular manifest branch, so we have decided to make the change as it would provide more flexibility and better matches what other elements would do. Bug: [google internal] b/187868160 Change-Id: I35255ee347aff6e65179f7879d52931f168b477e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/317643 Tested-by: Xin Li <delphij@google.com> Reviewed-by: Raman Tenneti <rtenneti@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'tests/test_manifest_xml.py')
-rw-r--r--tests/test_manifest_xml.py69
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py
index 20459d1d..ce422536 100644
--- a/tests/test_manifest_xml.py
+++ b/tests/test_manifest_xml.py
@@ -572,6 +572,7 @@ class SuperProjectElementTests(ManifestParseTestCase):
572 self.assertEqual(manifest.superproject['name'], 'superproject') 572 self.assertEqual(manifest.superproject['name'], 'superproject')
573 self.assertEqual(manifest.superproject['remote'].name, 'test-remote') 573 self.assertEqual(manifest.superproject['remote'].name, 'test-remote')
574 self.assertEqual(manifest.superproject['remote'].url, 'http://localhost/superproject') 574 self.assertEqual(manifest.superproject['remote'].url, 'http://localhost/superproject')
575 self.assertEqual(manifest.superproject['revision'], 'refs/heads/main')
575 self.assertEqual( 576 self.assertEqual(
576 sort_attributes(manifest.ToXml().toxml()), 577 sort_attributes(manifest.ToXml().toxml()),
577 '<?xml version="1.0" ?><manifest>' 578 '<?xml version="1.0" ?><manifest>'
@@ -580,6 +581,72 @@ class SuperProjectElementTests(ManifestParseTestCase):
580 '<superproject name="superproject"/>' 581 '<superproject name="superproject"/>'
581 '</manifest>') 582 '</manifest>')
582 583
584 def test_superproject_revision(self):
585 """Check superproject settings with a different revision attribute"""
586 self.maxDiff = None
587 manifest = self.getXmlManifest("""
588<manifest>
589 <remote name="test-remote" fetch="http://localhost" />
590 <default remote="test-remote" revision="refs/heads/main" />
591 <superproject name="superproject" revision="refs/heads/stable" />
592</manifest>
593""")
594 self.assertEqual(manifest.superproject['name'], 'superproject')
595 self.assertEqual(manifest.superproject['remote'].name, 'test-remote')
596 self.assertEqual(manifest.superproject['remote'].url, 'http://localhost/superproject')
597 self.assertEqual(manifest.superproject['revision'], 'refs/heads/stable')
598 self.assertEqual(
599 sort_attributes(manifest.ToXml().toxml()),
600 '<?xml version="1.0" ?><manifest>'
601 '<remote fetch="http://localhost" name="test-remote"/>'
602 '<default remote="test-remote" revision="refs/heads/main"/>'
603 '<superproject name="superproject" revision="refs/heads/stable"/>'
604 '</manifest>')
605
606 def test_superproject_revision_default_negative(self):
607 """Check superproject settings with a same revision attribute"""
608 self.maxDiff = None
609 manifest = self.getXmlManifest("""
610<manifest>
611 <remote name="test-remote" fetch="http://localhost" />
612 <default remote="test-remote" revision="refs/heads/stable" />
613 <superproject name="superproject" revision="refs/heads/stable" />
614</manifest>
615""")
616 self.assertEqual(manifest.superproject['name'], 'superproject')
617 self.assertEqual(manifest.superproject['remote'].name, 'test-remote')
618 self.assertEqual(manifest.superproject['remote'].url, 'http://localhost/superproject')
619 self.assertEqual(manifest.superproject['revision'], 'refs/heads/stable')
620 self.assertEqual(
621 sort_attributes(manifest.ToXml().toxml()),
622 '<?xml version="1.0" ?><manifest>'
623 '<remote fetch="http://localhost" name="test-remote"/>'
624 '<default remote="test-remote" revision="refs/heads/stable"/>'
625 '<superproject name="superproject"/>'
626 '</manifest>')
627
628 def test_superproject_revision_remote(self):
629 """Check superproject settings with a same revision attribute"""
630 self.maxDiff = None
631 manifest = self.getXmlManifest("""
632<manifest>
633 <remote name="test-remote" fetch="http://localhost" revision="refs/heads/main" />
634 <default remote="test-remote" />
635 <superproject name="superproject" revision="refs/heads/stable" />
636</manifest>
637""")
638 self.assertEqual(manifest.superproject['name'], 'superproject')
639 self.assertEqual(manifest.superproject['remote'].name, 'test-remote')
640 self.assertEqual(manifest.superproject['remote'].url, 'http://localhost/superproject')
641 self.assertEqual(manifest.superproject['revision'], 'refs/heads/stable')
642 self.assertEqual(
643 sort_attributes(manifest.ToXml().toxml()),
644 '<?xml version="1.0" ?><manifest>'
645 '<remote fetch="http://localhost" name="test-remote" revision="refs/heads/main"/>'
646 '<default remote="test-remote"/>'
647 '<superproject name="superproject" revision="refs/heads/stable"/>'
648 '</manifest>')
649
583 def test_remote(self): 650 def test_remote(self):
584 """Check superproject settings with a remote.""" 651 """Check superproject settings with a remote."""
585 manifest = self.getXmlManifest(""" 652 manifest = self.getXmlManifest("""
@@ -593,6 +660,7 @@ class SuperProjectElementTests(ManifestParseTestCase):
593 self.assertEqual(manifest.superproject['name'], 'platform/superproject') 660 self.assertEqual(manifest.superproject['name'], 'platform/superproject')
594 self.assertEqual(manifest.superproject['remote'].name, 'superproject-remote') 661 self.assertEqual(manifest.superproject['remote'].name, 'superproject-remote')
595 self.assertEqual(manifest.superproject['remote'].url, 'http://localhost/platform/superproject') 662 self.assertEqual(manifest.superproject['remote'].url, 'http://localhost/platform/superproject')
663 self.assertEqual(manifest.superproject['revision'], 'refs/heads/main')
596 self.assertEqual( 664 self.assertEqual(
597 sort_attributes(manifest.ToXml().toxml()), 665 sort_attributes(manifest.ToXml().toxml()),
598 '<?xml version="1.0" ?><manifest>' 666 '<?xml version="1.0" ?><manifest>'
@@ -613,6 +681,7 @@ class SuperProjectElementTests(ManifestParseTestCase):
613""") 681""")
614 self.assertEqual(manifest.superproject['name'], 'superproject') 682 self.assertEqual(manifest.superproject['name'], 'superproject')
615 self.assertEqual(manifest.superproject['remote'].name, 'default-remote') 683 self.assertEqual(manifest.superproject['remote'].name, 'default-remote')
684 self.assertEqual(manifest.superproject['revision'], 'refs/heads/main')
616 self.assertEqual( 685 self.assertEqual(
617 sort_attributes(manifest.ToXml().toxml()), 686 sort_attributes(manifest.ToXml().toxml()),
618 '<?xml version="1.0" ?><manifest>' 687 '<?xml version="1.0" ?><manifest>'