def setUp(self): import cxxd_mocks from services.clang_format_service import ClangFormat self.parser = CxxdConfigParser(self.cxxd_config.name) self.parser_with_empty_config_file = CxxdConfigParser( self.empty_cxxd_config.name) self.parser_with_inexisting_config_file = CxxdConfigParser( 'some_inexisting_cxxd_config_filename')
def test_if_cxxd_config_parser_returns_valid_configuration_when_there_are_multiple_configs_existing( self): self.cxxd_config = FileGenerator.gen_cxxd_config_filename_with_invalid_section( [ '\ { \n\ "configuration" : { \n\ "type" : "compilation-database", \n\ "compilation-database" : { \n\ "target" : { \n\ "rel" : "/tmp" \n\ } \n\ }, \n\ "compile-flags" : { \n\ "target" : { \n\ "rel" : "/tmp" \n\ } \n\ } \n\ } \n\ } \n\ ' ]) self.cxxd_config_parser = CxxdConfigParser(self.cxxd_config.name, self.project_root_directory) self.assertEqual(self.cxxd_config_parser.get_configuration_type(), 'compilation-database') self.assertEqual( self.cxxd_config_parser.get_configuration_for_target('rel'), self.json_compilation_database.name) FileGenerator.close_gen_file(self.cxxd_config)
def setUp(self): import cxxd_mocks from services.clang_tidy_service import ClangTidy self.service = ClangTidy(self.project_root_directory, CxxdConfigParser(self.cxxd_config.name), cxxd_mocks.ServicePluginMock()) self.unsupported_compilation_database = 'compiler_flags.yaml'
def setUp(self): import cxxd_mocks from services.project_builder_service import ProjectBuilder self.service = ProjectBuilder(self.project_root_directory, CxxdConfigParser(self.cxxd_config.name), cxxd_mocks.ServicePluginMock()) self.build_cmd = 'gcc -o {0}.o -c {1}'.format( self.file_to_be_built.name, self.file_to_be_built.name)
def setUp(self): import cxxd_mocks from services.clang_tidy_service import ClangTidy self.service = ClangTidy( self.project_root_directory, CxxdConfigParser('inexisting_config_file', self.project_root_directory), self.target, cxxd_mocks.ServicePluginMock())
def setUp(self): import cxxd_mocks from services.clang_tidy_service import ClangTidy self.service = ClangTidy( self.project_root_directory, CxxdConfigParser(self.cxxd_config_with_json_comp_db.name, self.project_root_directory), self.target, cxxd_mocks.ServicePluginMock())
def setUp(self): import cxxd_mocks from services.clang_format_service import ClangFormat self.service = ClangFormat( self.project_root_directory, CxxdConfigParser(self.cxxd_config.name, self.project_root_directory), cxxd_mocks.ServicePluginMock())
def __init__(self, handle, project_root_directory, target, source_code_model_plugin, project_builder_plugin, clang_format_plugin, clang_tidy_plugin): self.handle = handle self.cxxd_config_filename = '.cxxd_config.json' self.cxxd_config_parser = CxxdConfigParser( os.path.join(project_root_directory, self.cxxd_config_filename), project_root_directory) self.action = { ServerRequestId.START_ALL_SERVICES: self.__start_all_services, ServerRequestId.START_SERVICE: self.__start_service, ServerRequestId.SEND_SERVICE: self.__send_service_request, ServerRequestId.SHUTDOWN_ALL_SERVICES: self.__shutdown_all_services, ServerRequestId.SHUTDOWN_SERVICE: self.__shutdown_service, ServerRequestId.SHUTDOWN_AND_EXIT: self.__shutdown_and_exit # TODO add runtime debugging switch action } self.service = {} self.started_up = True self.configuration = self.cxxd_config_parser.get_configuration_for_target( target) if self.configuration: self.service = { ServiceId.SOURCE_CODE_MODEL: self.ServiceHandler( SourceCodeModel(project_root_directory, self.cxxd_config_parser, target, source_code_model_plugin)), ServiceId.PROJECT_BUILDER: self.ServiceHandler( ProjectBuilder(project_root_directory, self.cxxd_config_parser, project_builder_plugin)), ServiceId.CLANG_FORMAT: self.ServiceHandler( ClangFormat(project_root_directory, self.cxxd_config_parser, clang_format_plugin)), ServiceId.CLANG_TIDY: self.ServiceHandler( ClangTidy(project_root_directory, self.cxxd_config_parser, target, clang_tidy_plugin)), } logging.info("Registered services: {0}".format(self.service)) logging.info("Actions: {0}".format(self.action)) else: logging.fatal( 'Unable to find proper configuration for given target: {0}. Please check entries in your .cxxd_config.json.' .format(target)) logging.fatal('Bailing out ...') self.__shutdown_and_exit(0, [])
def test_if_cxxd_config_parser_returns_auto_discovery_try_harder_when_configuration_is_missing( self): self.cxxd_config = FileGenerator.gen_cxxd_config_filename_with_invalid_section( [ '\ { \n\ } \n\ ' ]) self.cxxd_config_parser = CxxdConfigParser(self.cxxd_config.name, self.project_root_directory) self.assertEqual(self.cxxd_config_parser.get_configuration_type(), 'auto-discovery-try-harder') FileGenerator.close_gen_file(self.cxxd_config)
def test_if_cxxd_config_parser_returns_auto_discovery_for_type(self): self.cxxd_config = FileGenerator.gen_cxxd_config_filename_with_invalid_section( [ '\ { \n\ "configuration" : { \n\ "type": "auto-discovery" \n\ } \n\ } \n\ ' ]) self.cxxd_config_parser = CxxdConfigParser(self.cxxd_config.name, self.project_root_directory) self.assertEqual(self.cxxd_config_parser.get_configuration_type(), 'auto-discovery') FileGenerator.close_gen_file(self.cxxd_config)
def test_if_cxxd_config_parser_returns_none_when_type_is_not_one_of_valid_values( self): self.cxxd_config = FileGenerator.gen_cxxd_config_filename_with_invalid_section( [ '\ { \n\ "configuration" : { \n\ "type": "something-unsupported" \n\ } \n\ } \n\ ' ]) self.cxxd_config_parser = CxxdConfigParser(self.cxxd_config.name, self.project_root_directory) self.assertEqual(self.cxxd_config_parser.get_configuration_type(), None) FileGenerator.close_gen_file(self.cxxd_config)
def test_if_cxxd_config_parser_returns_none_when_for_inexisting_target_section( self): self.cxxd_config = FileGenerator.gen_cxxd_config_filename_with_invalid_section( [ '\ { \n\ "configuration" : { \n\ "type": "compilation-database", \n\ "compilation-database" : { \n\ } \n\ } \n\ } \n\ ' ]) self.cxxd_config_parser = CxxdConfigParser(self.cxxd_config.name, self.project_root_directory) self.assertEqual( self.cxxd_config_parser.get_configuration_for_target('whatever'), None) FileGenerator.close_gen_file(self.cxxd_config)
def __init__(self, handle, project_root_directory, source_code_model_plugin, project_builder_plugin, clang_format_plugin, clang_tidy_plugin): self.handle = handle self.cxxd_config_filename = '.cxxd_config.json' self.cxxd_config_parser = CxxdConfigParser( os.path.join(project_root_directory, self.cxxd_config_filename)) self.service = { ServiceId.SOURCE_CODE_MODEL: self.ServiceHandler( SourceCodeModel(project_root_directory, self.cxxd_config_parser, source_code_model_plugin)), ServiceId.PROJECT_BUILDER: self.ServiceHandler( ProjectBuilder(project_root_directory, self.cxxd_config_parser, project_builder_plugin)), ServiceId.CLANG_FORMAT: self.ServiceHandler( ClangFormat(project_root_directory, self.cxxd_config_parser, clang_format_plugin)), ServiceId.CLANG_TIDY: self.ServiceHandler( ClangTidy(project_root_directory, self.cxxd_config_parser, clang_tidy_plugin)), } self.action = { ServerRequestId.START_ALL_SERVICES: self.__start_all_services, ServerRequestId.START_SERVICE: self.__start_service, ServerRequestId.SEND_SERVICE: self.__send_service_request, ServerRequestId.SHUTDOWN_ALL_SERVICES: self.__shutdown_all_services, ServerRequestId.SHUTDOWN_SERVICE: self.__shutdown_service, ServerRequestId.SHUTDOWN_AND_EXIT: self.__shutdown_and_exit # TODO add runtime debugging switch action } self.started_up = True logging.info("Registered services: {0}".format(self.service)) logging.info("Actions: {0}".format(self.action))
def test_if_cxxd_config_parser_returns_none_when_auto_discovery_does_not_contain_any_search_paths( self): self.cxxd_config = FileGenerator.gen_cxxd_config_filename_with_invalid_section( [ '\ { \n\ "configuration" : { \n\ "type": "auto-discovery", \n\ "auto-discovery" : { \n\ } \n\ } \n\ } \n\ ' ]) self.cxxd_config_parser = CxxdConfigParser(self.cxxd_config.name, self.project_root_directory) self.assertEqual(self.cxxd_config_parser.get_configuration_type(), 'auto-discovery') self.assertEqual( self.cxxd_config_parser.get_configuration_for_target('whatever'), None) FileGenerator.close_gen_file(self.cxxd_config)
def test_if_cxxd_config_parser_returns_config_found_in_auto_discovery_search_path( self): self.cxxd_config = FileGenerator.gen_cxxd_config_filename_with_invalid_section( [ '\ { \n\ "configuration" : { \n\ "type": "auto-discovery", \n\ "auto-discovery" : { \n\ "search-paths" : ["/tmp"] \n\ } \n\ } \n\ } \n\ ' ]) self.cxxd_config_parser = CxxdConfigParser(self.cxxd_config.name, self.project_root_directory) self.assertEqual(self.cxxd_config_parser.get_configuration_type(), 'auto-discovery') self.assertEqual( self.cxxd_config_parser.get_configuration_for_target('whatever'), self.json_compilation_database.name) FileGenerator.close_gen_file(self.cxxd_config)
def test_if_cxxd_config_parser_returns_none_configuration_when_config_for_selected_type_is_missing( self): self.cxxd_config = FileGenerator.gen_cxxd_config_filename_with_invalid_section( [ '\ { \n\ "configuration" : { \n\ "type" : "compilation-database", \n\ "compile-flags" : { \n\ "target" : { \n\ "rel" : "/rel" \n\ } \n\ } \n\ } \n\ } \n\ ' ]) self.cxxd_config_parser = CxxdConfigParser(self.cxxd_config.name, self.project_root_directory) self.assertEqual(self.cxxd_config_parser.get_configuration_type(), 'compilation-database') self.assertEqual( self.cxxd_config_parser.get_configuration_for_target('rel'), None) FileGenerator.close_gen_file(self.cxxd_config)
def setUp(self): self.parser = CxxdConfigParser(self.cxxd_config.name, self.project_root_directory)
def setUp(self): self.parser = CxxdConfigParser('inexisting_cxxd_config_filename', self.project_root_directory)
def setUp(self): self.parser_with_empty_config_file = CxxdConfigParser( self.empty_cxxd_config.name, self.project_root_directory)