OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import os | 5 import os |
6 import re | 6 import re |
7 import unittest | 7 import unittest |
8 | 8 |
9 import bisect_perf_regression | 9 import bisect_perf_regression |
10 import source_control as source_control_module | 10 import source_control as source_control_module |
(...skipping 14 matching lines...) Expand all Loading... |
25 source_control = source_control_module.DetermineAndCreateSourceControl( | 25 source_control = source_control_module.DetermineAndCreateSourceControl( |
26 bisect_options) | 26 bisect_options) |
27 bisect_instance = bisect_perf_regression.BisectPerformanceMetrics( | 27 bisect_instance = bisect_perf_regression.BisectPerformanceMetrics( |
28 source_control, bisect_options) | 28 source_control, bisect_options) |
29 return bisect_instance | 29 return bisect_instance |
30 | 30 |
31 | 31 |
32 class BisectPerfRegressionTest(unittest.TestCase): | 32 class BisectPerfRegressionTest(unittest.TestCase): |
33 """Test case for other functions and classes in bisect-perf-regression.py.""" | 33 """Test case for other functions and classes in bisect-perf-regression.py.""" |
34 | 34 |
| 35 def setUp(self): |
| 36 self.cwd = os.getcwd() |
| 37 |
| 38 def tearDown(self): |
| 39 os.chdir(self.cwd) |
| 40 |
35 def _AssertConfidence(self, score, bad_values, good_values): | 41 def _AssertConfidence(self, score, bad_values, good_values): |
36 """Checks whether the given sets of values have a given confidence score. | 42 """Checks whether the given sets of values have a given confidence score. |
37 | 43 |
38 The score represents our confidence that the two sets of values wouldn't | 44 The score represents our confidence that the two sets of values wouldn't |
39 be as different as they are just by chance; that is, that some real change | 45 be as different as they are just by chance; that is, that some real change |
40 occurred between the two sets of values. | 46 occurred between the two sets of values. |
41 | 47 |
42 Args: | 48 Args: |
43 score: Expected confidence score. | 49 score: Expected confidence score. |
44 bad_values: First list of numbers. | 50 bad_values: First list of numbers. |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 bisect_instance = _GetBisectPerformanceMetricsInstance() | 281 bisect_instance = _GetBisectPerformanceMetricsInstance() |
276 wk_rev = 'a94d028e0f2c77f159b3dac95eb90c3b4cf48c61' | 282 wk_rev = 'a94d028e0f2c77f159b3dac95eb90c3b4cf48c61' |
277 depot_path = os.path.join(bisect_perf_regression.SRC_DIR, 'third_party', | 283 depot_path = os.path.join(bisect_perf_regression.SRC_DIR, 'third_party', |
278 'WebKit') | 284 'WebKit') |
279 self.assertEqual( | 285 self.assertEqual( |
280 181660, | 286 181660, |
281 bisect_instance.source_control.GetCommitPosition(wk_rev, depot_path)) | 287 bisect_instance.source_control.GetCommitPosition(wk_rev, depot_path)) |
282 | 288 |
283 def testUpdateDepsContent(self): | 289 def testUpdateDepsContent(self): |
284 bisect_instance = _GetBisectPerformanceMetricsInstance() | 290 bisect_instance = _GetBisectPerformanceMetricsInstance() |
285 deps_file = 'DEPS' | 291 deps_file = os.path.join(bisect_perf_regression.SRC_DIR, 'DEPS') |
286 # We are intentionally reading DEPS file contents instead of string literal | 292 # We are intentionally reading DEPS file contents instead of string literal |
287 # with few lines from DEPS because to check if the format we are expecting | 293 # with few lines from DEPS because to check if the format we are expecting |
288 # to search is not changed in DEPS content. | 294 # to search is not changed in DEPS content. |
289 # TODO (prasadv): Add a separate test to validate the DEPS contents with the | 295 # TODO (prasadv): Add a separate test to validate the DEPS contents with the |
290 # format that bisect script expects. | 296 # format that bisect script expects. |
291 deps_contents = bisect_perf_regression.ReadStringFromFile(deps_file) | 297 deps_contents = bisect_perf_regression.ReadStringFromFile(deps_file) |
292 deps_key = 'v8_revision' | 298 deps_key = 'v8_revision' |
293 depot = 'v8' | 299 depot = 'v8' |
294 git_revision = 'a12345789a23456789a123456789a123456789' | 300 git_revision = 'a12345789a23456789a123456789a123456789' |
295 updated_content = bisect_instance.UpdateDepsContents( | 301 updated_content = bisect_instance.UpdateDepsContents( |
296 deps_contents, depot, git_revision, deps_key) | 302 deps_contents, depot, git_revision, deps_key) |
297 self.assertIsNotNone(updated_content) | 303 self.assertIsNotNone(updated_content) |
298 ss = re.compile('["\']%s["\']: ["\']%s["\']' % (deps_key, git_revision)) | 304 ss = re.compile('["\']%s["\']: ["\']%s["\']' % (deps_key, git_revision)) |
299 self.assertIsNotNone(re.search(ss, updated_content)) | 305 self.assertIsNotNone(re.search(ss, updated_content)) |
300 | 306 |
301 | 307 |
302 if __name__ == '__main__': | 308 if __name__ == '__main__': |
303 unittest.main() | 309 unittest.main() |
OLD | NEW |