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