| 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..4d95873e9038c040f0599d628dea4cdc9079d58d 100644
|
| --- a/tools/auto_bisect/bisect_perf_regression_test.py
|
| +++ b/tools/auto_bisect/bisect_perf_regression_test.py
|
| @@ -2,6 +2,7 @@
|
| # Use of this source code is governed by a BSD-style license that can be
|
| # found in the LICENSE file.
|
|
|
| +import argparse
|
| import os
|
| import re
|
| import shutil
|
| @@ -131,6 +132,23 @@ def _FakeTestResult(values, bisect_mode_is_return_code):
|
| return (result_dict, success_code)
|
|
|
|
|
| +def _GetMockCallArg(function_mock, call_index):
|
| + """Gets the first argument value for call at "call_index".
|
| +
|
| + Args:
|
| + function_mock: A Mock object.
|
| + call_index: The index at which the mocked function was called.
|
| +
|
| + Returns:
|
| + The first argument value.
|
| + """
|
| + 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 +178,7 @@ def _GenericDryRun(options, print_results=False):
|
| Returns:
|
| The results dictionary as returned by the bisect Run method.
|
| """
|
| - _AbortIfThereAreStagedChanges()
|
| + #_AbortIfThereAreStagedChanges()
|
| # Disable rmtree to avoid deleting local trees.
|
| old_rmtree = shutil.rmtree
|
| shutil.rmtree = lambda path, on_error: None
|
| @@ -319,6 +337,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."""
|
| + # Test result goes from 0 to 100 where lower is better
|
| + 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())
|
| +
|
| + 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
|
|
|