| 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 from testing_utils import testing | 5 from testing_utils import testing |
| 6 from crash.test.stacktrace_test_suite import StacktraceTestSuite | 6 from crash.test.stacktrace_test_suite import StacktraceTestSuite |
| 7 | 7 |
| 8 | 8 |
| 9 class CrashTestSuite(StacktraceTestSuite): # pragma: no cover. | 9 class CrashTestSuite(StacktraceTestSuite): # pragma: no cover. |
| 10 | 10 |
| 11 def _VerifyTwoStackInfosEqual(self, infos1, infos2): | 11 def _VerifyTwoStackInfosEqual(self, infos1, infos2): |
| 12 self.assertEqual(len(infos1), len(infos2)) | 12 self.assertEqual(len(infos1), len(infos2)) |
| 13 | 13 |
| 14 for (frame1, priority1), (frame2, priority2) in zip(infos1, infos2): | 14 for (frame1, priority1), (frame2, priority2) in zip(infos1, infos2): |
| 15 self.assertEqual(priority1, priority2) | 15 self.assertEqual(priority1, priority2) |
| 16 self._VerifyTwoStackFramesEqual(frame1, frame2) | 16 self._VerifyTwoStackFramesEqual(frame1, frame2) |
| 17 | 17 |
| 18 def _VerifyTwoBlamesEqual(self, blame1, blame2): | 18 def _VerifyTwoBlamesEqual(self, blame1, blame2): |
| 19 self.assertEqual(blame1.revision, blame2.revision) | 19 self.assertEqual(blame1.revision, blame2.revision) |
| 20 self.assertEqual(blame1.path, blame2.path) | 20 self.assertEqual(blame1.path, blame2.path) |
| 21 map(self.assertEqual, blame1.ToDict()['regions'], | 21 map(self.assertEqual, blame1.ToDict()['regions'], |
| 22 blame2.ToDict()['regions']) | 22 blame2.ToDict()['regions']) |
| 23 | 23 |
| 24 def _VerifyTwoChangeLogsEqual(self, changelog1, changelog2): | 24 def _VerifyTwoChangeLogsEqual(self, changelog1, changelog2): |
| 25 self.assertEqual(changelog1.ToDict(), changelog2.ToDict()) | 25 self.assertEqual(changelog1.ToDict(), changelog2.ToDict()) |
| 26 | 26 |
| 27 def _VerifyTwoResultEqual(self, result1, result2): | 27 def _VerifyTwoSuspectEqual(self, suspect1, suspect2): |
| 28 self._VerifyTwoChangeLogsEqual(result1.changelog, result2.changelog) | 28 """Assert that two ``Suspect`` objects are equal.""" |
| 29 self.assertEqual(result1.dep_path, result2.dep_path) | 29 self._VerifyTwoChangeLogsEqual(suspect1.changelog, suspect2.changelog) |
| 30 self.assertEqual(result1.confidence, result2.confidence) | 30 self.assertEqual(suspect1.dep_path, suspect2.dep_path) |
| 31 self.assertEqual(result1.reasons, result2.reasons) | 31 self.assertEqual(suspect1.confidence, suspect2.confidence) |
| 32 self.assertEqual(suspect1.reasons, suspect2.reasons) |
| 32 | 33 |
| 33 self.assertEqual(result1.file_to_stack_infos.keys(), | 34 self.assertEqual(suspect1.file_to_analysis_info, |
| 34 result2.file_to_stack_infos.keys()) | 35 suspect2.file_to_analysis_info) |
| 35 for file_path in result1.file_to_stack_infos.keys(): | |
| 36 self._VerifyTwoStackInfosEqual(result1.file_to_stack_infos[file_path], | |
| 37 result2.file_to_stack_infos[file_path]) | |
| 38 | 36 |
| 39 self.assertEqual(result1.file_to_analysis_info, | 37 self.assertEqual(suspect1.file_to_stack_infos.keys(), |
| 40 result2.file_to_analysis_info) | 38 suspect2.file_to_stack_infos.keys()) |
| 39 for file_path in suspect1.file_to_stack_infos.keys(): |
| 40 self._VerifyTwoStackInfosEqual(suspect1.file_to_stack_infos[file_path], |
| 41 suspect2.file_to_stack_infos[file_path]) |
| 41 | 42 |
| 42 def _VerifyTwoMatchResultEqual(self, match_result1, match_result2): | 43 self.assertEqual(suspect1.file_to_analysis_info, |
| 43 self.assertEqual(match_result1.file_to_analysis_info, | 44 suspect2.file_to_analysis_info) |
| 44 match_result2.file_to_analysis_info) | |
| 45 self._VerifyTwoResultEqual(match_result1, match_result2) | |
| 46 | 45 |
| 47 def _VerifyTwoMatchResultsEqual(self, match_results1, match_results2): | 46 def _VerifyTwoSuspectsEqual(self, suspects1, suspects2): |
| 48 self.assertEqual(match_results1._ignore_cls, match_results2._ignore_cls) | 47 """Assert that two ``Suspects`` objects are equal.""" |
| 48 self.assertEqual(suspects1._ignore_cls, suspects2._ignore_cls) |
| 49 | 49 |
| 50 self.assertEqual(len(match_results1), len(match_results2)) | 50 self.assertEqual(len(suspects1), len(suspects2)) |
| 51 for revision1, match_result1 in match_results1.iteritems(): | 51 for revision1, suspect1 in suspects1.iteritems(): |
| 52 self.assertTrue(revision1 in match_results2) | 52 self.assertTrue(revision1 in suspects2) |
| 53 self._VerifyTwoMatchResultEqual(match_result1, match_results2[revision1]) | 53 self._VerifyTwoSuspectEqual(suspect1, suspects2[revision1]) |
| OLD | NEW |