| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 datetime import datetime | 5 from datetime import datetime |
| 6 | 6 |
| 7 from common.blame import Blame | 7 from common.blame import Blame |
| 8 from common.blame import Region | 8 from common.blame import Region |
| 9 from common.change_log import FileChangeInfo | 9 from common.change_log import FileChangeInfo |
| 10 from common.diff import ChangeType | 10 from common.diff import ChangeType |
| 11 from common.git_repository import GitRepository | 11 from common.git_repository import GitRepository |
| 12 from common.waterfall import failure_type |
| 12 from waterfall import build_failure_analysis | 13 from waterfall import build_failure_analysis |
| 13 from waterfall.failure_signal import FailureSignal | 14 from waterfall.failure_signal import FailureSignal |
| 14 from waterfall.test import wf_testcase | 15 from waterfall.test import wf_testcase |
| 15 | 16 |
| 16 | 17 |
| 17 class BuildFailureAnalysisTest(wf_testcase.WaterfallTestCase): | 18 class BuildFailureAnalysisTest(wf_testcase.WaterfallTestCase): |
| 18 | 19 |
| 19 def _MockGetChangeLog(self, revision): | 20 def _MockGetChangeLog(self, revision): |
| 20 | 21 |
| 21 class MockChangeLog(object): | 22 class MockChangeLog(object): |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 'failed': True, | 549 'failed': True, |
| 549 'chromium_revision': None, | 550 'chromium_revision': None, |
| 550 } | 551 } |
| 551 result = build_failure_analysis.AnalyzeBuildFailure( | 552 result = build_failure_analysis.AnalyzeBuildFailure( |
| 552 failure_info, change_logs=None, deps_info=None, failure_signals=None) | 553 failure_info, change_logs=None, deps_info=None, failure_signals=None) |
| 553 self.assertEqual(0, len(result['failures'])) | 554 self.assertEqual(0, len(result['failures'])) |
| 554 | 555 |
| 555 def testAnalyzeBuildFailure(self): | 556 def testAnalyzeBuildFailure(self): |
| 556 failure_info = { | 557 failure_info = { |
| 557 'master_name': 'm', | 558 'master_name': 'm', |
| 559 'builder_name': 'b', |
| 560 'build_number': 99, |
| 561 'failure_type': failure_type.TEST, |
| 558 'failed': True, | 562 'failed': True, |
| 559 'chromium_revision': 'r99_2', | 563 'chromium_revision': 'r99_2', |
| 560 'failed_steps': { | 564 'failed_steps': { |
| 561 'a': { | 565 'a': { |
| 562 'current_failure': 99, | 566 'current_failure': 99, |
| 563 'first_failure': 98, | 567 'first_failure': 98, |
| 564 }, | 568 }, |
| 565 'b': { | 569 'b': { |
| 566 'current_failure': 99, | 570 'current_failure': 99, |
| 567 'first_failure': 98, | 571 'first_failure': 98, |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 | 702 |
| 699 analysis_result = build_failure_analysis.AnalyzeBuildFailure( | 703 analysis_result = build_failure_analysis.AnalyzeBuildFailure( |
| 700 failure_info, change_logs, deps_info, failure_signals_json) | 704 failure_info, change_logs, deps_info, failure_signals_json) |
| 701 self.assertEqual(expected_analysis_result, analysis_result) | 705 self.assertEqual(expected_analysis_result, analysis_result) |
| 702 | 706 |
| 703 def testAnalyzeBuildFailureTestLevel(self): | 707 def testAnalyzeBuildFailureTestLevel(self): |
| 704 failure_info = { | 708 failure_info = { |
| 705 'failed': True, | 709 'failed': True, |
| 706 'chromium_revision': 'r99_2', | 710 'chromium_revision': 'r99_2', |
| 707 'master_name': 'm', | 711 'master_name': 'm', |
| 712 'builder_name': 'b', |
| 713 'build_number': 99, |
| 714 'failure_type': failure_type.TEST, |
| 708 'failed_steps': { | 715 'failed_steps': { |
| 709 'a': { | 716 'a': { |
| 710 'current_failure': 99, | 717 'current_failure': 99, |
| 711 'first_failure': 98, | 718 'first_failure': 98, |
| 712 }, | 719 }, |
| 713 'b': { | 720 'b': { |
| 714 'current_failure': 99, | 721 'current_failure': 99, |
| 715 'first_failure': 98, | 722 'first_failure': 98, |
| 716 'last_pass': 96, | 723 'last_pass': 96, |
| 717 'list_isolated_data': [ | 724 'list_isolated_data': [ |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 } | 983 } |
| 977 | 984 |
| 978 analysis_result = build_failure_analysis.AnalyzeBuildFailure( | 985 analysis_result = build_failure_analysis.AnalyzeBuildFailure( |
| 979 failure_info, change_logs, deps_info, failure_signals_json) | 986 failure_info, change_logs, deps_info, failure_signals_json) |
| 980 | 987 |
| 981 self.assertEqual(expected_analysis_result, analysis_result) | 988 self.assertEqual(expected_analysis_result, analysis_result) |
| 982 | 989 |
| 983 def testAnalyzeBuildFailureForUnsupportedStep(self): | 990 def testAnalyzeBuildFailureForUnsupportedStep(self): |
| 984 failure_info = { | 991 failure_info = { |
| 985 'master_name': 'master1', | 992 'master_name': 'master1', |
| 993 'builder_name': 'b', |
| 994 'build_number': 99, |
| 995 'failure_type': failure_type.TEST, |
| 986 'failed': True, | 996 'failed': True, |
| 987 'chromium_revision': 'r99_2', | 997 'chromium_revision': 'r99_2', |
| 988 'failed_steps': { | 998 'failed_steps': { |
| 989 'unsupported_step1': { | 999 'unsupported_step1': { |
| 990 'current_failure': 99, | 1000 'current_failure': 99, |
| 991 'first_failure': 98, | 1001 'first_failure': 98, |
| 992 }, | 1002 }, |
| 993 }, | 1003 }, |
| 994 'builds': { | 1004 'builds': { |
| 995 '99': { | 1005 '99': { |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1141 touched_file, file_path_in_log, justification, file_name_occurrences, | 1151 touched_file, file_path_in_log, justification, file_name_occurrences, |
| 1142 line_numbers, repo_info, commit_revision) | 1152 line_numbers, repo_info, commit_revision) |
| 1143 | 1153 |
| 1144 expected_justification = { | 1154 expected_justification = { |
| 1145 'score': 4, | 1155 'score': 4, |
| 1146 'hints': { | 1156 'hints': { |
| 1147 'modified c.cc[1, 3] (and it was in log)': 4 | 1157 'modified c.cc[1, 3] (and it was in log)': 4 |
| 1148 } | 1158 } |
| 1149 } | 1159 } |
| 1150 self.assertEqual(expected_justification, justification.ToDict()) | 1160 self.assertEqual(expected_justification, justification.ToDict()) |
| OLD | NEW |