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

Side by Side Diff: tests/git_number_test.py

Issue 26109002: Add git-number script to calculate generation numbers for commits. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Now with tests! Created 7 years, 1 month 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 | Annotate | Revision Log
« tests/git_common_test.py ('K') | « tests/git_common_test.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
M-A Ruel 2013/11/07 20:59:11 # Copyright 2013 The Chromium Authors. All rights
iannucci 2013/11/07 21:44:57 Oops. Done.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """Unit tests for git_number.py"""
7
8 import binascii
9 import os
10 import sys
11
12 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
13
14 from testing_support import git_test_utils
15
16 class Basic(git_test_utils.GitRepoReadWriteTestBase):
17 REPO = """
18 A B C D E
19 B F E
20 X Y E
21 """
22
23 @classmethod
24 def setUpClass(cls):
25 super(Basic, cls).setUpClass()
26 import git_number
27 cls.gn = git_number
28 cls.gn.POOL_KIND = 'threads'
M-A Ruel 2013/11/07 20:59:11 Why not do it in setUp()?
iannucci 2013/11/07 21:44:57 Doesn't need to be done for every test
29
30 @classmethod
31 def tearDownClass(cls):
32 super(Basic, cls).tearDownClass()
M-A Ruel 2013/11/07 20:59:11 You wan to call the super class after the function
iannucci 2013/11/07 21:44:57 Good point. Fixed everywhere.
33 cls.gn.POOL_KIND = 'procs'
34
35 def tearDown(self):
36 super(Basic, self).tearDown()
M-A Ruel 2013/11/07 20:59:11 same
iannucci 2013/11/07 21:44:57 Done.
37 self.gn.clear_caches()
38
39 def _git_number(self, refs, reset=False, cache=False):
40 return self.repo.run(
41 self.gn.git_number,
42 reset, cache, refs
43 )
44
45 def testBasic(self):
46 self.assertEqual(self._git_number([self.repo['A']]), [0])
47 self.assertEqual(self._git_number([self.repo['F']]), [2])
48 self.assertEqual(self._git_number([self.repo['X']]), [0])
49 self.assertEqual(self._git_number([self.repo['E']]), [4])
50
51 def testInProcessCache(self):
52 self.assertEqual(
53 self.repo.run(self.gn.get_num, binascii.unhexlify(self.repo['A'])), None
54 )
55 self.assertEqual(self._git_number([self.repo['E']]), [4])
56 self.assertEqual(
57 self.repo.run(self.gn.get_num, binascii.unhexlify(self.repo['A'])), 0
58 )
59
60 def testOnDiskCache(self):
61 self.assertEqual(
62 self.repo.run(self.gn.get_num, binascii.unhexlify(self.repo['A'])), None
63 )
64 self.assertEqual(self._git_number([self.repo['E']], cache=True), [4])
65 self.assertEqual(self._git_number([self.repo['E']], cache=True), [4])
66 self.gn.clear_caches()
67 self.assertEqual(
68 self.repo.run(self.gn.get_num, binascii.unhexlify(self.repo['A'])), 0
69 )
70 self.gn.clear_caches()
71 self._git_number([], reset=True)
72 self.assertEqual(
73 self.repo.run(self.gn.get_num, binascii.unhexlify(self.repo['A'])), None
74 )
75
76
77 if __name__ == '__main__':
78 sys.exit(git_test_utils.covered_main(
79 os.path.join(os.path.abspath(os.path.dirname(os.path.dirname(__file__))),
80 'git_number.py')
81 ))
OLDNEW
« tests/git_common_test.py ('K') | « tests/git_common_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698