| 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 datetime | 5 import datetime |
| 6 | 6 |
| 7 from common.waterfall import failure_type | 7 from common.waterfall import failure_type |
| 8 from model import analysis_approach_type | 8 from model import analysis_approach_type |
| 9 from model import suspected_cl_status | 9 from model import suspected_cl_status |
| 10 from model.suspected_cl_confidence import ConfidenceInformation | 10 from model.suspected_cl_confidence import ConfidenceInformation |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 self.assertIsNone(suspected_cl_util.GetSuspectedCLConfidenceScore( | 397 self.assertIsNone(suspected_cl_util.GetSuspectedCLConfidenceScore( |
| 398 self.cl_confidences, build)) | 398 self.cl_confidences, build)) |
| 399 | 399 |
| 400 def testGetConfidenceScoreTestNone(self): | 400 def testGetConfidenceScoreTestNone(self): |
| 401 build = { | 401 build = { |
| 402 'failure_type': failure_type.TEST, | 402 'failure_type': failure_type.TEST, |
| 403 'approaches': [] | 403 'approaches': [] |
| 404 } | 404 } |
| 405 self.assertIsNone(suspected_cl_util.GetSuspectedCLConfidenceScore( | 405 self.assertIsNone(suspected_cl_util.GetSuspectedCLConfidenceScore( |
| 406 self.cl_confidences, build)) | 406 self.cl_confidences, build)) |
| 407 |
| 408 def testGetSuspectedCLConfidenceScoreAndApproachNone(self): |
| 409 confidence, approach = ( |
| 410 suspected_cl_util.GetSuspectedCLConfidenceScoreAndApproach( |
| 411 self.cl_confidences, None, None)) |
| 412 self.assertIsNone(confidence) |
| 413 self.assertIsNone(approach) |
| 414 |
| 415 def testGetSuspectedCLConfidenceScoreAndApproachUseFirstBuild(self): |
| 416 build = { |
| 417 'failure_type': failure_type.COMPILE, |
| 418 'failures': None, |
| 419 'status': suspected_cl_status.CORRECT, |
| 420 'approaches': [analysis_approach_type.TRY_JOB], |
| 421 'top_score': 5 |
| 422 } |
| 423 |
| 424 first_build = { |
| 425 'failure_type': failure_type.COMPILE, |
| 426 'failures': None, |
| 427 'status': suspected_cl_status.CORRECT, |
| 428 'approaches': [analysis_approach_type.TRY_JOB, |
| 429 analysis_approach_type.HEURISTIC], |
| 430 'top_score': 5 |
| 431 } |
| 432 |
| 433 confidence, approach = ( |
| 434 suspected_cl_util.GetSuspectedCLConfidenceScoreAndApproach( |
| 435 self.cl_confidences, build, first_build)) |
| 436 |
| 437 self.assertEqual( |
| 438 suspected_cl_util._RoundConfidentToInteger( |
| 439 self.cl_confidences.compile_heuristic_try_job.confidence), |
| 440 confidence) |
| 441 self.assertEqual( |
| 442 analysis_approach_type.TRY_JOB, approach) |
| 443 |
| 444 def testGetSuspectedCLConfidenceScoreAndApproachUseNewStep(self): |
| 445 build = { |
| 446 'failure_type': failure_type.TEST, |
| 447 'failures': {'a': [], 'b': []}, |
| 448 'status': suspected_cl_status.CORRECT, |
| 449 'approaches': [analysis_approach_type.HEURISTIC], |
| 450 'top_score': 5 |
| 451 } |
| 452 |
| 453 first_build = { |
| 454 'failure_type': failure_type.TEST, |
| 455 'failures': {'a': ['t1']}, |
| 456 'status': suspected_cl_status.CORRECT, |
| 457 'approaches': [analysis_approach_type.TRY_JOB, |
| 458 analysis_approach_type.HEURISTIC], |
| 459 'top_score': 5 |
| 460 } |
| 461 |
| 462 confidence, approach = ( |
| 463 suspected_cl_util.GetSuspectedCLConfidenceScoreAndApproach( |
| 464 self.cl_confidences, build, first_build)) |
| 465 |
| 466 self.assertEqual( |
| 467 suspected_cl_util._RoundConfidentToInteger( |
| 468 self.cl_confidences.test_heuristic[1].confidence), |
| 469 confidence) |
| 470 self.assertEqual( |
| 471 analysis_approach_type.HEURISTIC, approach) |
| 472 |
| 473 def testGetSuspectedCLConfidenceScoreAndApproachUseNewTest(self): |
| 474 build = { |
| 475 'failure_type': failure_type.TEST, |
| 476 'failures': {'a': ['t1', 't2']}, |
| 477 'status': suspected_cl_status.CORRECT, |
| 478 'approaches': [analysis_approach_type.HEURISTIC], |
| 479 'top_score': 5 |
| 480 } |
| 481 |
| 482 first_build = { |
| 483 'failure_type': failure_type.TEST, |
| 484 'failures': {'a': ['t1']}, |
| 485 'status': suspected_cl_status.CORRECT, |
| 486 'approaches': [analysis_approach_type.TRY_JOB, |
| 487 analysis_approach_type.HEURISTIC], |
| 488 'top_score': 5 |
| 489 } |
| 490 |
| 491 confidence, approach = ( |
| 492 suspected_cl_util.GetSuspectedCLConfidenceScoreAndApproach( |
| 493 self.cl_confidences, build, first_build)) |
| 494 |
| 495 self.assertEqual( |
| 496 suspected_cl_util._RoundConfidentToInteger( |
| 497 self.cl_confidences.test_heuristic[1].confidence), |
| 498 confidence) |
| 499 self.assertEqual( |
| 500 analysis_approach_type.HEURISTIC, approach) |
| 501 |
| 502 def testGetSuspectedCLConfidenceScoreAndApproachUseLessTest(self): |
| 503 build = { |
| 504 'failure_type': failure_type.TEST, |
| 505 'failures': {'a': ['t1']}, |
| 506 'status': suspected_cl_status.CORRECT, |
| 507 'approaches': [analysis_approach_type.HEURISTIC], |
| 508 'top_score': 5 |
| 509 } |
| 510 |
| 511 first_build = { |
| 512 'failure_type': failure_type.TEST, |
| 513 'failures': {'a': ['t1', 't2']}, |
| 514 'status': suspected_cl_status.CORRECT, |
| 515 'approaches': [analysis_approach_type.TRY_JOB, |
| 516 analysis_approach_type.HEURISTIC], |
| 517 'top_score': 5 |
| 518 } |
| 519 |
| 520 confidence, approach = ( |
| 521 suspected_cl_util.GetSuspectedCLConfidenceScoreAndApproach( |
| 522 self.cl_confidences, build, first_build)) |
| 523 |
| 524 self.assertEqual( |
| 525 suspected_cl_util._RoundConfidentToInteger( |
| 526 self.cl_confidences.test_heuristic_try_job.confidence), confidence) |
| 527 self.assertEqual( |
| 528 analysis_approach_type.TRY_JOB, approach) |
| OLD | NEW |