Exemplo n.º 1
0
 def test_parse_real_crash(self):
     import libscanbuild.runner as sut2
     import re
     with fixtures.TempDir() as tmpdir:
         filename = os.path.join(tmpdir, 'test.c')
         with open(filename, 'w') as handle:
             handle.write('int main() { return 0')
         # produce failure report
         opts = {'directory': os.getcwd(),
                 'clang': 'clang',
                 'file': filename,
                 'report': ['-fsyntax-only', '-E', filename],
                 'language': 'c',
                 'output_dir': tmpdir,
                 'error_type': 'other_error',
                 'error_output': 'some output',
                 'exit_code': 13}
         sut2.report_failure(opts)
         # find the info file
         pp_file = None
         for root, _, files in os.walk(tmpdir):
             keys = [os.path.join(root, name) for name in files]
             for key in keys:
                 if re.match(r'^(.*/)+clang(.*)\.i$', key):
                     pp_file = key
         self.assertIsNot(pp_file, None)
         # read the failure report back
         result = sut.parse_crash(pp_file + '.info.txt')
         self.assertEqual(result['source'], filename)
         self.assertEqual(result['problem'], 'Other Error')
         self.assertEqual(result['file'], pp_file)
         self.assertEqual(result['info'], pp_file + '.info.txt')
         self.assertEqual(result['stderr'], pp_file + '.stderr.txt')
Exemplo n.º 2
0
 def test_parse_real_crash(self):
     import libscanbuild.analyze as sut2
     with libear.temporary_directory() as tmp_dir:
         filename = os.path.join(tmp_dir, 'test.c')
         with open(filename, 'w') as handle:
             handle.write('int main() { return 0')
         # produce failure report
         opts = {
             'clang': 'clang',
             'directory': os.getcwd(),
             'flags': [],
             'source': filename,
             'output_dir': tmp_dir,
             'language': 'c',
             'error_output': 'some output',
             'exit_code': 13
         }
         sut2.report_failure(opts)
         # find the info file
         pp_files = glob.glob(os.path.join(tmp_dir, 'failures', '*.i'))
         self.assertIsNot(pp_files, [])
         pp_file = pp_files[0]
         # read the failure report back
         result = sut.parse_crash(pp_file + '.info.txt')
         self.assertEqual(result['source'], filename)
         self.assertEqual(result['problem'], 'Other Error')
         self.assertEqual(result['file'], pp_file)
         self.assertEqual(result['info'], pp_file + '.info.txt')
         self.assertEqual(result['stderr'], pp_file + '.stderr.txt')
Exemplo n.º 3
0
def run_crash_parse(content, prefix):
    with libear.temporary_directory() as tmp_dir:
        file_name = os.path.join(tmp_dir, prefix + '.info.txt')
        with open(file_name, 'w') as handle:
            lines = (line + os.linesep for line in content)
            handle.writelines(lines)
        return sut.parse_crash(file_name)
Exemplo n.º 4
0
def run_crash_parse(content, preproc):
    with fixtures.TempDir() as tmpdir:
        file_name = os.path.join(tmpdir, preproc + '.info.txt')
        with open(file_name, 'w') as handle:
            handle.writelines(content)
        return sut.parse_crash(file_name)