Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(721)

Unified Diff: tests/git_footers_test.py

Issue 521033002: Added git footers tool to parse conventional metadata from git commits (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Review comments Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « man/src/git-footers.demo.1.sh ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/git_footers_test.py
diff --git a/tests/git_footers_test.py b/tests/git_footers_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..5cf9ccc5552a1b104d2af292c021ccb56f67992d
--- /dev/null
+++ b/tests/git_footers_test.py
@@ -0,0 +1,70 @@
+#!/usr/bin/env python
+
+"""Tests for git_footers."""
+
+import os
+import sys
+import unittest
+
+sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
+import git_footers
+
+class GitFootersTest(unittest.TestCase):
+ _message = """
+This is my commit message. There are many like it, but this one is mine.
+
+My commit message is my best friend. It is my life. I must master it.
+
+"""
+
+ _position = 'refs/heads/master@{#292272}'
+
+ _position_footer = 'Cr-Commit-Position: %s\n' % _position
+
+ _git_svn_id = ('svn://svn.chromium.org/chrome/trunk/src@290386'
+ ' 0039d316-1c4b-4281-b951-d872f2087c98')
+
+ _git_svn_id_footer = 'git-svn-id: %s\n' % _git_svn_id
+
+ _git_svn_id_branch = (
+ 'svn://svn.chromium.org/chrome/branches/blabble/src@177288')
+
+ _git_svn_id_footer_branch = 'git-svn-id: %s\n' % _git_svn_id_branch
+
+
+ def testFootersBasic(self):
+ self.assertEqual(
+ git_footers.parse_footers(self._message), {})
+ self.assertEqual(
+ git_footers.parse_footers(self._message + self._position_footer),
+ { 'Cr-Commit-Position': [ self._position ] })
+ self.assertEqual(
+ git_footers.parse_footers(self._message + self._git_svn_id_footer),
+ { 'Git-Svn-Id': [ self._git_svn_id ] })
+ self.assertEqual(
+ git_footers.parse_footers(self._message + self._position_footer
+ + self._position_footer),
+ { 'Cr-Commit-Position': [ self._position, self._position ] })
+
+ def testTrunkHeuristic(self):
+ footers = git_footers.parse_footers(self._message + self._git_svn_id_footer)
+ self.assertEqual(
+ footers,
+ { 'Git-Svn-Id': [ self._git_svn_id ] })
+ self.assertEqual(
+ git_footers.get_position(footers),
+ ('refs/heads/master', '290386'))
+
+ def testBranchHeuristic(self):
+ footers = git_footers.parse_footers(self._message +
+ self._git_svn_id_footer_branch)
+ self.assertEqual(
+ footers,
+ { 'Git-Svn-Id': [ self._git_svn_id_branch ] })
+ self.assertEqual(
+ git_footers.get_position(footers),
+ ('refs/branch-heads/blabble', None))
+
+if __name__ == '__main__':
+ unittest.main()
« no previous file with comments | « man/src/git-footers.demo.1.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698