Exemple #1
0
  def testCheckFileSameLineChanged(self):
    def MockGetChangedLines(*_):
      return [1, 3]
    self.mock(build_failure_analysis, '_GetChangedLinesForChromiumRepo',
              MockGetChangedLines)
    touched_file = {
        'change_type': ChangeType.MODIFY,
        'old_path': 'a/b/c.cc',
        'new_path': 'a/b/c.cc'
    }
    file_path_in_log = 'a/b/c.cc'
    justification = build_failure_analysis._Justification()
    file_name_occurrences = {'c.cc': 1}
    line_numbers = [1, 3]
    repo_info = {
        'repo_url': 'https://chromium.googlesource.com/chromium/src.git',
        'revision': 'dummy_abcd1234'
    }
    commit_revision = 'dummy_1'
    build_failure_analysis._CheckFile(
        touched_file, file_path_in_log, justification, file_name_occurrences,
        line_numbers, repo_info, commit_revision)

    expected_justification = {
        'score': 4,
        'hints': {
            'modified c.cc[1, 3] (and it was in log)': 4
        }
    }
    self.assertEqual(expected_justification, justification.ToDict())
Exemple #2
0
 def _testCheckFileInDependencyRoll(
     self, file_path_in_log, rolls, expected_score, line_numbers,
     expected_hints=None):
   self.mock(GitRepository, 'GetChangeLog', self._MockGetChangeLog)
   self.mock(GitRepository, 'GetBlame', self._MockGetBlame)
   justification = build_failure_analysis._Justification()
   build_failure_analysis._CheckFileInDependencyRolls(
       file_path_in_log, rolls, justification, line_numbers)
   self.assertEqual(expected_score, justification.score)
   if expected_hints:
     self.assertEqual(expected_hints, justification._hints)