Ejemplo n.º 1
0
 def test_line_match(self, mocked_command):
     mocked_command.return_value = '\n'.join([
         "diff --git a/test_api.py b/test_api.py",
         "index 73e79d1..884b953 100644",
         "--- a/test_api.py",
         "+++ b/test_api.py",
         "@@ -35,7 +35,9 @@ class TestApi(base.TestCase):",
         "     @mock.patch('git_stacktrace.git.pickaxe')",
         "     @mock.patch('git_stacktrace.git.files_touched')",
         "     @mock.patch('git_stacktrace.git.files')",
         "-    def test_lookup_stacktrace(self, mock_files, mock_files_touched, mock_pickaxe):",
         "+    @mock.patch('git_stacktrace.git.line_match')",
         "+    def test_lookup_stacktrace(self, mock_line_match, mock_files, mock_files_touched, mock_pickaxe):",
         "+        mock_files_touched.return_value = True",
         "         traceback = self.get_traceback()",
         "         self.setup_mocks(mock_files, mock_files_touched)",
     ])
     filename = "test_api.py"
     line = parse_trace.Line(filename, 38, None, None)
     line.git_filename = filename
     self.assertTrue(git.line_match("hash1", line))
     line.line_number = 5
     self.assertFalse(git.line_match("hash1", line))
Ejemplo n.º 2
0
 def test_line_match(self, mocked_command):
     mocked_command.return_value = '\n'.join([
         "diff --git a/test_api.py b/test_api.py",
         "index 73e79d1..884b953 100644",
         "--- a/test_api.py",
         "+++ b/test_api.py",
         "@@ -35,7 +35,9 @@ class TestApi(base.TestCase):",
         "     @mock.patch('git_stacktrace.git.pickaxe')",
         "     @mock.patch('git_stacktrace.git.files_touched')",
         "     @mock.patch('git_stacktrace.git.files')",
         "-    def test_lookup_stacktrace(self, mock_files, mock_files_touched, mock_pickaxe):",
         "+    @mock.patch('git_stacktrace.git.line_match')",
         "+    def test_lookup_stacktrace(self, mock_line_match, mock_files, mock_files_touched, mock_pickaxe):",
         "+        mock_files_touched.return_value = True",
         "         traceback = self.get_traceback()",
         "         self.setup_mocks(mock_files, mock_files_touched)",
     ])
     filename = "test_api.py"
     line = parse_trace.Line(filename, 38, None, None)
     line.git_filename = filename
     self.assertTrue(git.line_match("hash1", line))
     line.line_number = 5
     self.assertFalse(git.line_match("hash1", line))
Ejemplo n.º 3
0
def _lookup_files(commit_files, git_files, traceback, results):
    """Populate results and line.git_filename."""
    for line in traceback.lines:
        matches = traceback.file_match(line.trace_filename, git_files)
        if matches:
            git_file = _longest_filename(matches)
            for commit, file_list in commit_files.items():
                if git_file in file_list:
                    git_file = file_list[file_list.index(git_file)]
                    line.git_filename = git_file.filename
                    line_number = None
                    if git.line_match(commit, line):
                        line_number = line.line_number
                    results.get_result(commit).add_file(git_file, line_number)
            if line.git_filename is None:
                line.git_filename = _longest_filename(matches)
Ejemplo n.º 4
0
def _lookup_files(commit_files, git_files, traceback, results):
    """Populate results and line.git_filename."""
    for line in traceback.lines:
        matches = traceback.file_match(line.trace_filename, git_files)
        if matches:
            git_file = _longest_filename(matches)
            for commit, file_list in commit_files.items():
                if git_file in file_list:
                    git_file = file_list[file_list.index(git_file)]
                    line.git_filename = git_file.filename
                    line_number = None
                    if git.line_match(commit, line):
                        line_number = line.line_number
                    results.get_result(commit).add_file(git_file, line_number)
            if line.git_filename is None:
                line.git_filename = _longest_filename(matches)