コード例 #1
0
 def test5(self):
     normalizer = IncludeDirectiveNormalizer(
         DefaultProjectFile(path_rel_to_root_unix="a/b.cpp",
                            local_repository_root="/test",
                            path_module=posixpath),
         include_canonicalizer_factory=self.
         __create_include_path_canonicalizer_factory())
     test_str = r'#include "..\y.h"\n'
     self.assertEquals('#include <../y.h>\n',
                       normalizer.normalize(test_str))
コード例 #2
0
 def testOneSymbol(self, UsedSymbolsListerMock, HeaderListerMock):
     used_symbols_lister = cpp.incl_deps.repair_includes_if.UsedSymbolsLister()
     used_symbols_lister.get_symbol_candidates.return_value = dict({'test_id': 'test'}) 
     header_lister = cpp.incl_deps.repair_includes_if.HeaderLister()
     header_lister.map_symbol_ids_to_headers.return_value = set(('test.h', ))
     is_implementation_file_func = lambda x: True
     resource_resolver = None
     testee = TwoPhaseRequiredIncludeFilesCalculator(used_symbols_lister, header_lister, is_implementation_file_func, resource_resolver)
     local_root = os.path.dirname(os.tempnam())
     test_file = DefaultProjectFile(path_rel_to_root_unix="a.cpp", local_repository_root=local_root, resource=None)
     self.assertEquals(set(('test.h', )), set(testee.calculate_required_include_files(test_file)))
     self.assertTrue(used_symbols_lister.get_symbol_candidates.called)
     self.assertEquals([((['test_id'], test_file),)], header_lister.map_symbol_ids_to_headers.call_args_list)
コード例 #3
0
 def _process_normalizing(self, repair_path, intermediate_result, input_file, output_file):
     normalizer = IncludeDirectiveNormalizer(DefaultProjectFile(path_rel_to_root_unix=repair_path, 
             local_repository_root=self._local_source_resource_resolver.get_base_paths()[0]), 
                                             self._include_canonicalizer_factory,
                                             filemap_factory_func=self._filemap_factory.get_filemap)
     comment_filter = CommentFilter()
     if self.__skip_comments:
         filtered_input_file = comment_filter.filter(input_file)
     else:
         filtered_input_file = input_file
     for line in filtered_input_file:
         include_spec = normalizer.get_include_specification(line)
         if include_spec:
             (_include_spec_type, included_resource) = include_spec
             # TODO output rel_to_root if under root
             print >>self.__output_file, "%s,%s" % (repair_path, included_resource.name())
     return (normalizer.get_included_files(), normalizer.get_statistics_dict())
コード例 #4
0
 def _process_normalizing(self, repair_path, intermediate_result, input_file, output_file):
     normalizer = IncludeDirectiveNormalizer(DefaultProjectFile(path_rel_to_root_unix=repair_path, 
             local_repository_root=self._local_source_resource_resolver.get_base_paths()[0]), 
                                             self._include_canonicalizer_factory,
                                             filemap_factory_func=self._filemap_factory.get_filemap)
     # TODO or only create the iterator here? But this would not allow to return the statistics...
     if self.__skip_comments:
         comment_filter = CommentFilter()
         filtered_input_file = comment_filter.filter(input_file)
     else:
         filtered_input_file = input_file
     self.__include_map[repair_path] = tuple(ifilter(None, imap(normalizer.get_include_specification, filtered_input_file)))
     
     statistics_dict = normalizer.get_statistics_dict()
     if self.__skip_comments:
         DictTools.merge_dict(statistics_dict, comment_filter.get_statistics_dict(), value_merge_func=None)
     self.__logger.debug("%s includes files %s" % (repair_path, tuple(normalizer.get_included_files())))
     return (normalizer.get_included_files(), statistics_dict)