| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 os | 5 import os |
| 6 import re | 6 import re |
| 7 | 7 |
| 8 from google.appengine.ext import testbed | 8 from google.appengine.ext import testbed |
| 9 | 9 |
| 10 import webapp2 | 10 import webapp2 |
| 11 import webtest | 11 import webtest |
| 12 | 12 |
| 13 from handlers import build_failure | 13 from handlers import build_failure |
| 14 from handlers import handlers_util | 14 from handlers import handlers_util |
| 15 from handlers import result_status | 15 from handlers import result_status |
| 16 from model.wf_analysis import WfAnalysis | 16 from model.wf_analysis import WfAnalysis |
| 17 from model.wf_try_job import WfTryJob |
| 17 from model import analysis_status | 18 from model import analysis_status |
| 18 from model.wf_analysis import WfAnalysis | 19 from model.wf_analysis import WfAnalysis |
| 19 from waterfall import buildbot | 20 from waterfall import buildbot |
| 20 from waterfall.test import wf_testcase | 21 from waterfall.test import wf_testcase |
| 21 | 22 |
| 22 # Root directory appengine/findit. | 23 # Root directory appengine/findit. |
| 23 ROOT_DIR = os.path.join(os.path.dirname(__file__), | 24 ROOT_DIR = os.path.join(os.path.dirname(__file__), |
| 24 os.path.pardir, os.path.pardir) | 25 os.path.pardir, os.path.pardir) |
| 25 | 26 |
| 26 SAMPLE_TRY_JOB_INFO = { | 27 SAMPLE_TRY_JOB_INFO = { |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 'tests': [], | 610 'tests': [], |
| 610 'first_failure': 120, | 611 'first_failure': 120, |
| 611 'last_pass': 119, | 612 'last_pass': 119, |
| 612 'supported': True | 613 'supported': True |
| 613 } | 614 } |
| 614 ] | 615 ] |
| 615 } | 616 } |
| 616 } | 617 } |
| 617 } | 618 } |
| 618 self.assertEqual(expected_result, result) | 619 self.assertEqual(expected_result, result) |
| 620 |
| 621 def testPrepareTryJobDataForCompileFailure(self): |
| 622 analysis = WfAnalysis.Create('m', 'b', 123) |
| 623 analysis.result = { |
| 624 'failures': [ |
| 625 { |
| 626 'step_name': 'compile', |
| 627 'first_failure': 122, |
| 628 'last_pass': 121, |
| 629 'suspected_cls': [], |
| 630 }, |
| 631 { |
| 632 'step_name': 'steps', |
| 633 }, |
| 634 ] |
| 635 } |
| 636 analysis.failure_result_map = { |
| 637 'compile': 'm/b/122', |
| 638 } |
| 639 |
| 640 try_job = WfTryJob.Create('m', 'b', 122) |
| 641 try_job.status = analysis_status.COMPLETED |
| 642 try_job.compile_results = [ |
| 643 { |
| 644 'url': 'build/url', |
| 645 'culprit': { |
| 646 'compile': { |
| 647 'revision': 'rev', |
| 648 } |
| 649 } |
| 650 } |
| 651 ] |
| 652 try_job.put() |
| 653 |
| 654 expected_try_job_data = { |
| 655 'status': 'completed', |
| 656 'url': 'build/url', |
| 657 'completed': True, |
| 658 'failed': False, |
| 659 'culprit': { |
| 660 'revision': 'rev', |
| 661 } |
| 662 } |
| 663 |
| 664 try_job_data = ( |
| 665 build_failure.BuildFailure._PrepareTryJobDataForCompileFailure( |
| 666 analysis)) |
| 667 |
| 668 self.assertEqual(expected_try_job_data, try_job_data) |
| 669 |
| 670 def testPopulateHeuristicDataForCompileFailure(self): |
| 671 analysis = WfAnalysis.Create('m', 'b', 123) |
| 672 analysis.result = { |
| 673 'failures': [ |
| 674 { |
| 675 'step_name': 'compile', |
| 676 'first_failure': 122, |
| 677 'last_pass': 121, |
| 678 'suspected_cls': [], |
| 679 }, |
| 680 { |
| 681 'step_name': 'steps', |
| 682 }, |
| 683 ] |
| 684 } |
| 685 expected_data = { |
| 686 'first_failure': 122, |
| 687 'last_pass': 121, |
| 688 'suspected_cls_by_heuristic': [], |
| 689 } |
| 690 |
| 691 data = {} |
| 692 build_failure.BuildFailure._PopulateHeuristicDataForCompileFailure( |
| 693 analysis, data) |
| 694 self.assertEqual(expected_data, data) |
| OLD | NEW |