コード例 #1
0
ファイル: call_tree_manager.py プロジェクト: rknuus/INCode
 def dump(self, file_name, entry_point, include_system_headers=False, extra_arguments=None):
     tu_access = ClangTUAccess(file_name=file_name, extra_arguments=extra_arguments)
     self.call_graph_access_ = ClangCallGraphAccess(include_system_headers=include_system_headers)
     for file_name, compiler_arguments in tu_access.files.items():
         self.call_graph_access_.parse_tu(tu_file_name=file_name, compiler_arguments=compiler_arguments)
     root = self.call_graph_access_.get_callable(entry_point)
     return self.dump_callable_(root, 0)
コード例 #2
0
def test__given_compilation_database_with_one_file__return_file_and_args():
    content = '[{ "command": "-I/usr/include", "file": "file.cpp" }]'
    with generate_file('compile_commands.json', content) as file_name:
        access = ClangTUAccess(file_name=file_name)
    expected = {'file.cpp': ['-I/usr/include']}
    actual = access.files
    assert actual == expected
コード例 #3
0
def test__given_file_with_extra_compiler_arguments__return_file_and_args():
    with generate_file('file.cpp', '') as file_name:
        access = ClangTUAccess(file_name=file_name,
                               extra_arguments='-std=c++11')
        expected = {file_name: ['-std=c++11']}
    actual = access.files
    assert actual == expected
コード例 #4
0
ファイル: call_tree_manager.py プロジェクト: rknuus/INCode
 def open(self, file_name):
     if self.state_ not in [CallTreeManagerState.INITIALIZED,
                            CallTreeManagerState.EXTRA_ARGUMENTS_INITIALIZED,
                            CallTreeManagerState.READY_TO_SELECT_TU]:
         warnings.warn('Unsupported state transition from {} to {}'.format(
             self.state_, CallTreeManagerState.READY_TO_SELECT_TU))
         return
     self.tu_access_ = ClangTUAccess(file_name=file_name,
                                     extra_arguments=self.extra_arguments_)
     set_global_common_path(find_common_path(list(self.tu_access_.files)))
     self.state_ = CallTreeManagerState.READY_TO_SELECT_TU
     return self.tu_access_.files.keys()
コード例 #5
0
def test__given_file_without_compiler_arguments__return_file():
    with generate_file('file.cpp', '') as file_name:
        access = ClangTUAccess(file_name=file_name)
        expected = {file_name: []}
    actual = access.files
    assert actual == expected
コード例 #6
0
def test__given_non_existing_file__parse_tu_throws():
    with pytest.raises(FileNotFoundError):
        ClangTUAccess(file_name='a-file-that-doesnt-exist')
コード例 #7
0
def test__given_empty_compilation_database__return_empty_dic():
    with generate_file('compile_commands.json', '[]') as file_name:
        access = ClangTUAccess(file_name=file_name)
    expected = {}
    actual = access.files
    assert actual == expected