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

Unified Diff: tools/auto_bisect/bisect_perf_regression_test.py

Issue 554283003: Refactored bisect results dicts into a separate class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adressed comments Created 6 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
« no previous file with comments | « tools/auto_bisect/bisect_perf_regression.py ('k') | tools/auto_bisect/bisect_results.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/auto_bisect/bisect_perf_regression_test.py
diff --git a/tools/auto_bisect/bisect_perf_regression_test.py b/tools/auto_bisect/bisect_perf_regression_test.py
index a033d8baaaa336d0a18d6378f8037fb0920ec8ea..b8f32266c92a66ae086d838718c2a61f2e0c51ff 100644
--- a/tools/auto_bisect/bisect_perf_regression_test.py
+++ b/tools/auto_bisect/bisect_perf_regression_test.py
@@ -8,6 +8,7 @@ import shutil
import unittest
import bisect_perf_regression
+import bisect_results
import source_control as source_control_module
def _GetBisectPerformanceMetricsInstance():
@@ -26,14 +27,20 @@ def _GetBisectPerformanceMetricsInstance():
bisect_options)
bisect_instance = bisect_perf_regression.BisectPerformanceMetrics(
source_control, bisect_options)
- bisect_instance.src_cwd = os.path.abspath(
- os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir))
return bisect_instance
class BisectPerfRegressionTest(unittest.TestCase):
"""Test case for other functions and classes in bisect-perf-regression.py."""
+ def setUp(self):
+ self.cwd = os.getcwd()
+ os.chdir(os.path.abspath(os.path.join(os.path.dirname(__file__),
+ os.path.pardir, os.path.pardir)))
+
+ def tearDown(self):
+ os.chdir(self.cwd)
+
def _AssertConfidence(self, score, bad_values, good_values):
"""Checks whether the given sets of values have a given confidence score.
@@ -48,7 +55,7 @@ class BisectPerfRegressionTest(unittest.TestCase):
"""
# ConfidenceScore takes a list of lists but these lists are flattened
# inside the function.
- confidence = bisect_perf_regression.ConfidenceScore(
+ confidence = bisect_results.ConfidenceScore(
[[v] for v in bad_values],
[[v] for v in good_values])
self.assertEqual(score, confidence)
@@ -306,5 +313,40 @@ class BisectPerfRegressionTest(unittest.TestCase):
self.assertIsNotNone(re.search(ss, updated_content))
+class DepotDirectoryRegistryTest(unittest.TestCase):
+
+ def setUp(self):
+ self.old_chdir = os.chdir
+ os.chdir = self.mockChdir
+ self.old_depot_names = bisect_perf_regression.DEPOT_NAMES
+ bisect_perf_regression.DEPOT_NAMES = ['mock_depot']
+ self.old_depot_deps_name = bisect_perf_regression.DEPOT_DEPS_NAME
+ bisect_perf_regression.DEPOT_DEPS_NAME = {'mock_depot': {'src': 'src/foo'}}
+
+ self.registry = bisect_perf_regression.DepotDirectoryRegistry('/mock/src')
+ self.cur_dir = None
+
+ def tearDown(self):
+ os.chdir = self.old_chdir
+ bisect_perf_regression.DEPOT_NAMES = self.old_depot_names
+ bisect_perf_regression.DEPOT_DEPS_NAME = self.old_depot_deps_name
+
+ def mockChdir(self, new_dir):
+ self.cur_dir = new_dir
+
+ def testReturnsCorrectResultForChrome(self):
+ self.assertEqual(self.registry.GetDepotDir('chromium'), '/mock/src')
+
+ def testReturnsCorrectResultForChromeOS(self):
+ self.assertEqual(self.registry.GetDepotDir('cros'), '/mock/src/tools/cros')
+
+ def testUsesDepotSpecToInitializeRegistry(self):
+ self.assertEqual(self.registry.GetDepotDir('mock_depot'), '/mock/src/foo')
+
+ def testChangedTheDirectory(self):
+ self.registry.ChangeToDepotDir('mock_depot')
+ self.assertEqual(self.cur_dir, '/mock/src/foo')
+
+
if __name__ == '__main__':
unittest.main()
« no previous file with comments | « tools/auto_bisect/bisect_perf_regression.py ('k') | tools/auto_bisect/bisect_results.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698