| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 json | 5 import json |
| 6 import os | 6 import os |
| 7 import pickle | 7 import pickle |
| 8 import subprocess | 8 import subprocess |
| 9 | 9 |
| 10 from crash_queries import crash_iterator | 10 from crash_queries import crash_iterator |
| 11 from crash_queries.delta_test import delta_util | 11 from crash_queries.delta_test import delta_util |
| 12 | 12 |
| 13 PREDATOR_RESULTS_DIRECTORY = os.path.join(os.path.dirname(__file__), | 13 PREDATOR_RESULTS_DIRECTORY = os.path.join(os.path.dirname(__file__), |
| 14 'predator_results') | 14 'predator_results') |
| 15 DELTA_TEST_DIRECTORY = os.path.dirname(__file__) | 15 DELTA_TEST_DIRECTORY = os.path.dirname(__file__) |
| 16 CRASH_FIELDS = ['crashed_version', 'stack_trace', 'signature', | 16 CRASH_FIELDS = ['crashed_version', 'stack_trace', 'signature', |
| 17 'platform', 'client_id', 'regression_range', | 17 'platform', 'client_id', 'regression_range', |
| 18 'customized_data', 'historical_metadata'] | 18 'customized_data', 'historical_metadata'] |
| 19 | 19 |
| 20 | 20 |
| 21 | |
| 22 # TODO(crbug.com/662540): Add unittests. | 21 # TODO(crbug.com/662540): Add unittests. |
| 23 class Delta(object): # pragma: no cover. | 22 class Delta(object): # pragma: no cover. |
| 24 """Stands for delta between two results. | 23 """Stands for delta between two results. |
| 25 | 24 |
| 26 Note, the 2 results should be the same kind and have the same structure. | 25 Note, the 2 results should be the same kind and have the same structure. |
| 27 """ | 26 """ |
| 28 | 27 |
| 29 def __init__(self, result1, result2): | 28 def __init__(self, result1, result2): |
| 30 self._result1 = result1 | 29 self._result1 = result1 |
| 31 self._result2 = result2 | 30 self._result2 = result2 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 print '========= Delta of this batch =========' | 232 print '========= Delta of this batch =========' |
| 234 delta_util.PrintDelta(batch_deltas, len(crashes), app_id) | 233 delta_util.PrintDelta(batch_deltas, len(crashes), app_id) |
| 235 deltas.update(batch_deltas) | 234 deltas.update(batch_deltas) |
| 236 | 235 |
| 237 return deltas, crash_count | 236 return deltas, crash_count |
| 238 finally: | 237 finally: |
| 239 with open(os.devnull, 'w') as null_handle: | 238 with open(os.devnull, 'w') as null_handle: |
| 240 subprocess.check_call(['git', 'checkout', head_branch_name], | 239 subprocess.check_call(['git', 'checkout', head_branch_name], |
| 241 stdout=null_handle, | 240 stdout=null_handle, |
| 242 stderr=null_handle) | 241 stderr=null_handle) |
| OLD | NEW |