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 33f733a7332641521a58b226afa48b69f74f382c..454f27b7cb8927e49352adceba66b3bf0ea52ae1 100644 |
--- a/tools/auto_bisect/bisect_perf_regression_test.py |
+++ b/tools/auto_bisect/bisect_perf_regression_test.py |
@@ -131,6 +131,23 @@ def _FakeTestResult(values, bisect_mode_is_return_code): |
return (result_dict, success_code) |
+def _GetMockCallArg(function_mock, call_index): |
+ """Gets the list of called arguements for call at "call_index". |
qyearsley
2016/01/26 18:08:01
arguements -> arguments
"call_index" -> |call_ind
chrisphan
2016/02/10 02:23:38
Done.
|
+ |
+ Args: |
+ function_mock: A Mock object. |
+ call_index: The index at which the mocked function was called. |
qyearsley
2016/01/26 18:08:00
Is this the index in the sequence of calls? e.g. 0
chrisphan
2016/02/10 02:23:38
That's correct.
|
+ |
+ Returns: |
+ The called argument list. |
+ """ |
+ call_args_list = function_mock.call_args_list |
+ if not call_args_list or len(call_args_list) <= call_index: |
+ return None |
+ args, _ = call_args_list[call_index] |
+ return args |
+ |
+ |
def _GetBisectPerformanceMetricsInstance(options_dict): |
"""Returns an instance of the BisectPerformanceMetrics class.""" |
opts = bisect_perf_regression.BisectOptions.FromDict(options_dict) |
@@ -160,7 +177,7 @@ def _GenericDryRun(options, print_results=False): |
Returns: |
The results dictionary as returned by the bisect Run method. |
""" |
- _AbortIfThereAreStagedChanges() |
+ #_AbortIfThereAreStagedChanges() |
qyearsley
2016/01/26 18:08:00
Uncomment
chrisphan
2016/02/10 02:23:38
Done.
|
# Disable rmtree to avoid deleting local trees. |
old_rmtree = shutil.rmtree |
shutil.rmtree = lambda path, on_error: None |
@@ -319,6 +336,23 @@ class BisectPerfRegressionTest(unittest.TestCase): |
results = _GenericDryRun(_GetExtendedOptions(1, -100)) |
self.assertIsNone(results.error) |
+ @mock.patch('urllib2.urlopen') |
+ def testBisectResultsPosted(self, mock_urlopen): |
+ """Bisects with improvement direction matching regression range.""" |
qyearsley
2016/01/26 18:08:00
Docstring should be deleted or updated.
chrisphan
2016/02/10 02:23:38
Done.
|
+ # Test result goes from 0 to 100 where lower is better |
qyearsley
2016/01/26 18:08:01
This comment appears to be unrelated.
chrisphan
2016/02/10 02:23:38
Done.
|
+ options_dict = dict(DEFAULT_OPTIONS) |
+ options_dict.update({ |
+ 'bisect_mode': bisect_utils.BISECT_MODE_MEAN, |
+ 'try_job_id': 1234, |
+ }) |
+ opts = bisect_perf_regression.BisectOptions.FromDict(options_dict) |
+ results = _GenericDryRun(options_dict, True) |
+ bisect_perf_regression._PostBisectResults(results, opts, os.getcwd()) |
qyearsley
2016/01/26 18:08:00
Optional: Because the purpose of this test method
chrisphan
2016/02/10 02:23:38
Done.
|
+ |
+ call_args = _GetMockCallArg(mock_urlopen, 0) |
+ self.assertIsNotNone(call_args) |
+ self.assertIn('"try_job_id": 1234', call_args[1]) |
+ |
def _CheckAbortsEarly(self, results, **extra_opts): |
"""Returns True if the bisect job would abort early.""" |
global _MockResultsGenerator |