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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2015 the V8 project authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 from collections import namedtuple
7 from os import path
Michael Achenbach 2015/09/17 14:19:00 nit: order
Michael Hablich 2015/09/18 07:38:47 Acknowledged.
8 import mergeinfo
9 import shutil
10 from subprocess import Popen, PIPE, check_call
11 import unittest
12
13
14 TEST_CONFIG = {
15 "GIT_REPO": "/tmp/test-v8-search-related-commits",
16 }
17
18 class TestSearchRelatedCommits(unittest.TestCase):
19
20 base_dir = TEST_CONFIG["GIT_REPO"]
21
22 def _execute_git(self, git_args):
23
24 fullCommand = ["git", "-C", self.base_dir] + git_args
25 p = Popen(args=fullCommand, stdin=PIPE,
26 stdout=PIPE, stderr=PIPE)
27 output, err = p.communicate()
28 rc = p.returncode
29 if rc != 0:
30 raise Exception(err)
31 return output
32
33 def setUp(self):
34 if path.exists(self.base_dir):
35 shutil.rmtree(self.base_dir)
36
37 check_call(["git", "init", self.base_dir])
38
39 # Initial commit
40 message = """[turbofan] Sanitize language mode for javascript operators.
41
42 R=mstarzinger@chromium.org
43
44 Review URL: https://codereview.chromium.org/1084243005
45
46 Cr-Commit-Position: refs/heads/master@{#28059}"""
47 self._make_empty_commit(message)
48
49 message = """[crankshaft] Do some stuff
50
51 R=hablich@chromium.org
52
53 Review URL: https://codereview.chromium.org/1084243007
54
55 Cr-Commit-Position: refs/heads/master@{#28030}"""
56
57 self._make_empty_commit(message)
58
59 def tearDown(self):
60 if path.exists(self.base_dir):
61 shutil.rmtree(self.base_dir)
62
63 def _assert_correct_standard_result(
64 self, result, all_commits, hash_of_first_commit):
65 self.assertEqual(len(result), 1, "Master commit not found")
66 self.assertTrue(
67 result.get(hash_of_first_commit),
68 "Master commit is wrong")
69
70 self.assertEqual(
71 len(result[hash_of_first_commit]),
72 1,
73 "Child commit not found")
74 self.assertEqual(
75 all_commits[2],
76 result[hash_of_first_commit][0],
77 "Child commit wrong")
78
79 def _get_commits(self):
80 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.
81 ["log", "--format=%H", "--reverse"]).splitlines()
82 return commits
83
84 def _make_empty_commit(self, message):
85 self._execute_git(["commit", "--allow-empty", "-m", message])
86
87 def testLonelyCommit(self):
88 message = '''Initial commit'''
89 self._make_empty_commit(message)
90 commits = self._get_commits()
91 hash_of_first_commit = commits[0]
92
93 result = mergeinfo.describe_commit(
94 self.base_dir,
95 hash_of_first_commit,
96 False)
97
98 self.assertEqual(
99 result,
100 hash_of_first_commit)
101
102 def testSearchFollowUpCommits(self):
103 message = 'Initial commit'
104 self._make_empty_commit(message)
105 commits = self._get_commits()
106 hash_of_first_commit = commits[0]
107
108 message = 'Follow-up commit of ' + hash_of_first_commit
109 self._make_empty_commit(message)
110 self._make_empty_commit(message)
111 self._make_empty_commit(message)
112 message = 'Not related commit'
113 self._make_empty_commit(message)
114
115 commits = self._get_commits()
116
117 followups = mergeinfo.get_followup_commits(
118 self.base_dir,
119 hash_of_first_commit,
120 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
121
122
123 if __name__ == "__main__":
124 #import sys;sys.argv = ['', 'Test.testName']
125 unittest.main()
OLDNEW
« 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