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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/bisect-builds.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/bisect_test.py
diff --git a/tools/bisect_test.py b/tools/bisect_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..f1b6614e60147fbe73b571d0dc6f66eda17a3c97
--- /dev/null
+++ b/tools/bisect_test.py
@@ -0,0 +1,49 @@
+import unittest
+
+bisect_builds = __import__('bisect-builds')
+
+
+class BisectTest(unittest.TestCase):
+
+ patched = []
+ max_rev = 10000
+
+ def monkey_patch(self, obj, name, new):
+ self.patched.append((obj, name, getattr(obj, name)))
+ setattr(obj, name, new)
+
+ def clear_patching(self):
+ for obj, name, old in self.patched:
+ setattr(obj, name, old)
+ self.patched = []
+
+ def setUp(self):
+ self.monkey_patch(bisect_builds.DownloadJob, 'Start', lambda *args: None)
+ self.monkey_patch(bisect_builds.DownloadJob, 'Stop', lambda *args: None)
+ self.monkey_patch(bisect_builds.DownloadJob, 'WaitFor', lambda *args: None)
+ self.monkey_patch(bisect_builds, 'RunRevision', lambda *args: (0, "", ""))
+ self.monkey_patch(bisect_builds.PathContext, 'ParseDirectoryIndex',
+ lambda *args: range(self.max_rev))
+
+ def tearDown(self):
+ self.clear_patching()
+
+ def bisect(self, good_rev, bad_rev, evaluate):
+ return bisect_builds.Bisect(good_rev=good_rev,
+ bad_rev=bad_rev,
+ evaluate=evaluate,
+ num_runs=1,
+ official_builds=False,
+ platform='linux',
+ profile=None,
+ try_args=())
+
+ def testBisectConsistentAnswer(self):
+ self.assertEqual(self.bisect(1000, 100, lambda *args: 'g'), (100, 101))
+ self.assertEqual(self.bisect(100, 1000, lambda *args: 'b'), (100, 101))
+ self.assertEqual(self.bisect(2000, 200, lambda *args: 'b'), (1999, 2000))
+ self.assertEqual(self.bisect(200, 2000, lambda *args: 'g'), (1999, 2000))
+
+
+if __name__ == '__main__':
+ unittest.main()
« 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