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

Side by Side Diff: tools/bisect_test.py

Issue 11266025: Make tools/bisect_builds.py handle reversed bad/good revision ranges (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fewer parens Created 8 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
« no previous file with comments | « tools/bisect-builds.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 import unittest
2
3 bisect_builds = __import__('bisect-builds')
4
5
6 class BisectTest(unittest.TestCase):
7
8 patched = []
9 max_rev = 10000
10
11 def monkey_patch(self, obj, name, new):
12 self.patched.append((obj, name, getattr(obj, name)))
13 setattr(obj, name, new)
14
15 def clear_patching(self):
16 for obj, name, old in self.patched:
17 setattr(obj, name, old)
18 self.patched = []
19
20 def setUp(self):
21 self.monkey_patch(bisect_builds.DownloadJob, 'Start', lambda *args: None)
22 self.monkey_patch(bisect_builds.DownloadJob, 'Stop', lambda *args: None)
23 self.monkey_patch(bisect_builds.DownloadJob, 'WaitFor', lambda *args: None)
24 self.monkey_patch(bisect_builds, 'RunRevision', lambda *args: (0, "", ""))
25 self.monkey_patch(bisect_builds.PathContext, 'ParseDirectoryIndex',
26 lambda *args: range(self.max_rev))
27
28 def tearDown(self):
29 self.clear_patching()
30
31 def bisect(self, good_rev, bad_rev, evaluate):
32 return bisect_builds.Bisect(good_rev=good_rev,
33 bad_rev=bad_rev,
34 evaluate=evaluate,
35 num_runs=1,
36 official_builds=False,
37 platform='linux',
38 profile=None,
39 try_args=())
40
41 def testBisectConsistentAnswer(self):
42 self.assertEqual(self.bisect(1000, 100, lambda *args: 'g'), (100, 101))
43 self.assertEqual(self.bisect(100, 1000, lambda *args: 'b'), (100, 101))
44 self.assertEqual(self.bisect(2000, 200, lambda *args: 'b'), (1999, 2000))
45 self.assertEqual(self.bisect(200, 2000, lambda *args: 'g'), (1999, 2000))
46
47
48 if __name__ == '__main__':
49 unittest.main()
OLDNEW
« no previous file with comments | « tools/bisect-builds.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698