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

Unified Diff: tools/release/test_mergeinfo.py

Issue 1341303002: [Release] Distinguish between merges and follow-up CLs (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: First UnitTest Created 5 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
« tools/release/mergeinfo.py ('K') | « tools/release/search_related_commits.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/release/test_mergeinfo.py
diff --git a/tools/release/test_mergeinfo.py b/tools/release/test_mergeinfo.py
new file mode 100755
index 0000000000000000000000000000000000000000..04c32fc754b4e493abc891e8c748b1dd506f1256
--- /dev/null
+++ b/tools/release/test_mergeinfo.py
@@ -0,0 +1,125 @@
+#!/usr/bin/env python
+# Copyright 2015 the V8 project authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from collections import namedtuple
+from os import path
Michael Achenbach 2015/09/17 14:19:00 nit: order
Michael Hablich 2015/09/18 07:38:47 Acknowledged.
+import mergeinfo
+import shutil
+from subprocess import Popen, PIPE, check_call
+import unittest
+
+
+TEST_CONFIG = {
+ "GIT_REPO": "/tmp/test-v8-search-related-commits",
+}
+
+class TestSearchRelatedCommits(unittest.TestCase):
+
+ base_dir = TEST_CONFIG["GIT_REPO"]
+
+ def _execute_git(self, git_args):
+
+ fullCommand = ["git", "-C", self.base_dir] + git_args
+ p = Popen(args=fullCommand, stdin=PIPE,
+ stdout=PIPE, stderr=PIPE)
+ output, err = p.communicate()
+ rc = p.returncode
+ if rc != 0:
+ raise Exception(err)
+ return output
+
+ def setUp(self):
+ if path.exists(self.base_dir):
+ shutil.rmtree(self.base_dir)
+
+ check_call(["git", "init", self.base_dir])
+
+ # Initial commit
+ message = """[turbofan] Sanitize language mode for javascript operators.
+
+ R=mstarzinger@chromium.org
+
+ Review URL: https://codereview.chromium.org/1084243005
+
+ Cr-Commit-Position: refs/heads/master@{#28059}"""
+ self._make_empty_commit(message)
+
+ message = """[crankshaft] Do some stuff
+
+ R=hablich@chromium.org
+
+ Review URL: https://codereview.chromium.org/1084243007
+
+ Cr-Commit-Position: refs/heads/master@{#28030}"""
+
+ self._make_empty_commit(message)
+
+ def tearDown(self):
+ if path.exists(self.base_dir):
+ shutil.rmtree(self.base_dir)
+
+ def _assert_correct_standard_result(
+ self, result, all_commits, hash_of_first_commit):
+ self.assertEqual(len(result), 1, "Master commit not found")
+ self.assertTrue(
+ result.get(hash_of_first_commit),
+ "Master commit is wrong")
+
+ self.assertEqual(
+ len(result[hash_of_first_commit]),
+ 1,
+ "Child commit not found")
+ self.assertEqual(
+ all_commits[2],
+ result[hash_of_first_commit][0],
+ "Child commit wrong")
+
+ def _get_commits(self):
+ commits = self._execute_git(
Michael Achenbach 2015/09/17 14:19:00 nit: remove local var?
Michael Hablich 2015/09/18 07:38:47 I think it is easier to debug that way.
+ ["log", "--format=%H", "--reverse"]).splitlines()
+ return commits
+
+ def _make_empty_commit(self, message):
+ self._execute_git(["commit", "--allow-empty", "-m", message])
+
+ def testLonelyCommit(self):
+ message = '''Initial commit'''
+ self._make_empty_commit(message)
+ commits = self._get_commits()
+ hash_of_first_commit = commits[0]
+
+ result = mergeinfo.describe_commit(
+ self.base_dir,
+ hash_of_first_commit,
+ False)
+
+ self.assertEqual(
+ result,
+ hash_of_first_commit)
+
+ def testSearchFollowUpCommits(self):
+ message = 'Initial commit'
+ self._make_empty_commit(message)
+ commits = self._get_commits()
+ hash_of_first_commit = commits[0]
+
+ message = 'Follow-up commit of ' + hash_of_first_commit
+ self._make_empty_commit(message)
+ self._make_empty_commit(message)
+ self._make_empty_commit(message)
+ message = 'Not related commit'
+ self._make_empty_commit(message)
+
+ commits = self._get_commits()
+
+ followups = mergeinfo.get_followup_commits(
+ self.base_dir,
+ hash_of_first_commit,
+ False)
Michael Achenbach 2015/09/17 14:19:00 Shoudn't this assert something?"
Michael Hablich 2015/09/18 07:38:47 Right. Currently I am in the process of writing th
+
+
+if __name__ == "__main__":
+ #import sys;sys.argv = ['', 'Test.testName']
+ unittest.main()
« tools/release/mergeinfo.py ('K') | « tools/release/search_related_commits.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698