def get_toolnames_by_types_by_language(cls): """ get imformation about the plugged-in testcase tool drivers. :return: a dict having the form: { language: { TestToolType: [ (toolname, is_installed?) ] } } """ modules_dict = ToolsModulesLoader.get_tools_modules( \ ToolsModulesLoader.TESTCASES_TOOLS) res = {} for language in modules_dict: res[language] = {} for toolname in modules_dict[language]: for tooltype in TestToolType: tooltype_name = tooltype.get_field_value() try: # the tooltype is returned by config.get_tool_type() TestcaseTool = getattr(\ modules_dict[language][toolname],\ tooltype_name) if TestcaseTool is not None: if tooltype_name not in res[language]: res[language][tooltype_name] = [] res[language][tooltype_name].append(\ (toolname, TestcaseTool.installed())) except AttributeError: ERROR_HANDLER.error_exit("{} {} {} {}".format( \ "(REPORT BUG) The test case tool of type", \ tooltype_name,\ "is not present for test tool", toolname), \ __file__) # Add custom dev test for language in res: tooltype = TestToolType.USE_ONLY_CODE res[language][tooltype.get_tool_type_classname()] = \ (CustomTestcases.CUSTOM_TEST_TOOLNAME, \ CustomTestcases.installed()) return res
def get_toolnames_by_types_by_criteria_by_language(cls): """ get imformation about the plugged-in criteria tool drivers. :return: a dict having the form: { language: { criterion: { CriteriaToolType: [ (toolname, is_installed?) ] } } } """ modules_dict = ToolsModulesLoader.get_tools_modules( \ ToolsModulesLoader.CRITERIA_TOOLS) res = {} for language in modules_dict: res[language] = {} for toolname in modules_dict[language]: for tooltype in CriteriaToolType: tooltype_name = tooltype.get_field_value() try: # the tooltype is returned by config.get_tool_type() CriteriaTool = getattr(\ modules_dict[language][toolname],\ tooltype_name) if CriteriaTool is None: continue for criterion in CriteriaTool.get_supported_criteria(): if criterion not in res[language]: res[language][criterion] = {} if tooltype_name not in res[language][criterion]: res[language][criterion][tooltype_name] = [] res[language][criterion][tooltype_name].append(\ (toolname, CriteriaTool.installed())) except AttributeError: ERROR_HANDLER.error_exit("{} {} {} {}".format( \ "(REPORT BUG) The criteria tool of type", \ tooltype_name,\ "is not present for criteria tool", toolname),\ __file__) return res
def __init__(self, language, tests_working_dir, code_builds_factory, test_tool_config_list, head_explorer, hash_outlog=True): """ Initialize a meta testcase tool object. :type language: :param language: :type tests_working_dir: :param tests_working_dir: :type code_builds_factory: :param code_builds_factory: :type test_tool_config_list: :param test_tool_config_list: :raises: :rtype: """ # Set Constants self.modules_dict = ToolsModulesLoader.get_tools_modules( \ ToolsModulesLoader.TESTCASES_TOOLS) # Set Direct Arguments Variables self.language = language.lower() self.tests_working_dir = tests_working_dir self.code_builds_factory = code_builds_factory self.test_tool_config_list = test_tool_config_list self.head_explorer = head_explorer self.hash_outlog = hash_outlog # Verify Direct Arguments Variables ERROR_HANDLER.assert_true(self.tests_working_dir is not None, \ "Must specify tests_working_dir", __file__) ERROR_HANDLER.assert_true(len(self.test_tool_config_list) == \ len(set([c.get_tool_config_alias() for c in \ self.test_tool_config_list])), \ "some tool configs appear multiple times", __file__) # Set Indirect Arguments Variables self.checkpoints_dir = os.path.join(self.tests_working_dir, \ "_checkpoints_") self.testcases_info_file = \ os.path.join(self.tests_working_dir, "testcasesInfos.json") self.duplicated_tests_info_file = os.path.join(self.tests_working_dir,\ "duplicatedTestcasesInfos.json") self.flakiness_workdir = \ os.path.join(self.tests_working_dir, "Flakiness") # Verify Indirect Arguments Variables # Initialize other Fields self.testcases_configured_tools = {} self.checkpointer = None # Make Initialization Computation () ## Create dirs if not os.path.isdir(self.tests_working_dir): self.clear_working_dir() ## Set the checkpointer self.checkpointer = common_fs.CheckpointState(\ *self._get_checkpoint_files()) self.custom_devtest_toolalias = None # Keep the duplicate test so that they are executed only once # TODO: load from file(above), if not compute and store (in different func). in runtests, check that tests are here # make sure that every test is is present, if not recompute. self.tests_duplicates_map = None self._update_tests_duplicates_map() # Create the diffent tools for idx in range(len(test_tool_config_list)): config = test_tool_config_list[idx] toolname = config.get_tool_name() toolalias = config.get_tool_config_alias() tool_working_dir = self._get_test_tool_out_folder(toolalias) tool_checkpointer = common_fs.CheckpointState(\ *self._get_test_tool_checkpoint_files(toolalias)) self.checkpointer.add_dep_checkpoint_state(tool_checkpointer) self.testcases_configured_tools[toolalias] = { self.TOOL_OBJ_KEY: self._create_testcase_tool(toolname, \ tool_working_dir, config, \ tool_checkpointer), self.TOOL_WORKDIR_KEY: tool_working_dir, self.TOOL_TYPE_KEY: config.get_tool_type() }
def __init__(self, language, tests_working_dir, code_builds_factory, test_tool_config_list, test_oracle_manager): """ Initialize a meta testcase tool object. :type language: :param language: :type tests_working_dir: :param tests_working_dir: :type code_builds_factory: :param code_builds_factory: :type test_tool_config_list: :param test_tool_config_list: :raises: :rtype: """ # Set Constants self.modules_dict = ToolsModulesLoader.get_tools_modules( \ ToolsModulesLoader.TESTCASES_TOOLS) # Set Direct Arguments Variables self.language = language.lower() self.tests_working_dir = tests_working_dir self.code_builds_factory = code_builds_factory self.test_tool_config_list = test_tool_config_list self.test_oracle_manager = test_oracle_manager # Verify Direct Arguments Variables ERROR_HANDLER.assert_true(self.tests_working_dir is not None, \ "Must specify tests_working_dir", __file__) ERROR_HANDLER.assert_true(len(self.test_tool_config_list) == \ len(set([c.get_tool_config_alias() for c in \ self.test_tool_config_list])), \ "some tool configs appear multiple times", __file__) # Set Indirect Arguments Variables self.checkpoints_dir = os.path.join(self.tests_working_dir, \ "_checkpoints_") self.testcases_info_file = \ os.path.join(self.tests_working_dir, "testcasesInfos.json") # Verify Indirect Arguments Variables # Initialize other Fields self.testcases_configured_tools = {} self.checkpointer = None # Make Initialization Computation () ## Create dirs if not os.path.isdir(self.tests_working_dir): self.clear_working_dir() ## Set the checkpointer self.checkpointer = common_fs.CheckpointState(\ *self._get_checkpoint_files()) # Create the diffent tools for idx in range(len(test_tool_config_list)): config = test_tool_config_list[idx] toolname = config.get_tool_name() toolalias = config.get_tool_config_alias() tool_working_dir = self._get_test_tool_out_folder(toolalias) tool_checkpointer = common_fs.CheckpointState(\ *self._get_test_tool_checkpoint_files(toolalias)) self.checkpointer.add_dep_checkpoint_state(tool_checkpointer) self.testcases_configured_tools[toolalias] = { self.TOOL_OBJ_KEY: self._create_testcase_tool(toolname, \ tool_working_dir, config, \ tool_checkpointer), self.TOOL_WORKDIR_KEY: tool_working_dir, self.TOOL_TYPE_KEY: config.get_tool_type() }
def __init__(self, language, meta_test_generation_obj, \ criteria_working_dir, \ code_builds_factory, \ tools_config_by_criterion_dict): # Set Constants self.modules_dict = ToolsModulesLoader.get_tools_modules(\ ToolsModulesLoader.CRITERIA_TOOLS) # Set Direct Arguments Variables self.language = language.lower() self.meta_test_generation_obj = meta_test_generation_obj self.criteria_working_dir = criteria_working_dir self.code_builds_factory = code_builds_factory self.tools_config_by_criterion_dict = tools_config_by_criterion_dict # Verify Direct Arguments Variables ERROR_HANDLER.assert_true(self.criteria_working_dir is not None, \ "Must specify criteria_working_dir", __file__) for criterion in self.tools_config_by_criterion_dict: ERROR_HANDLER.assert_true( \ len(self.tools_config_by_criterion_dict[criterion]) == \ len(set([c.get_tool_config_alias() for c in \ self.tools_config_by_criterion_dict[criterion]])), \ "some tool configs appear multiple times for {}".format( \ criterion), __file__) # Set Indirect Arguments Variables self.checkpoints_dir = os.path.join(self.criteria_working_dir, \ "_checkpoints_") self.criteria_info_file_by_criteria = {} for criterion in self.tools_config_by_criterion_dict: self.criteria_info_file_by_criteria[criterion] = os.path.join(\ self.criteria_working_dir, \ criterion.get_str()+"_info_file.json") # Verify indirect Arguments Variables # Initialize Other Fields self.criteria_configured_tools = {} self.checkpointer = None # Make Initialization Computation ## Create dirs if not os.path.isdir(self.criteria_working_dir): self.clear_working_dir() ## set checkpointer self.checkpointer = common_fs.CheckpointState(\ *self._get_checkpoint_files()) ## Create the different tools ### XXX Merge configs that are identical across criteria tmp_alias2conf = {} for criterion in self.tools_config_by_criterion_dict: for config in self.tools_config_by_criterion_dict[criterion]: toolname = config.get_tool_name() toolalias = config.get_tool_config_alias() if toolalias in tmp_alias2conf: # make sure that the config is the same ERROR_HANDLER.assert_true(config == \ tmp_alias2conf[toolalias], \ "{} {} {}".format( \ "same tool alias but different", \ "config for alias", toolalias), __file__) else: tmp_alias2conf[toolalias] = config tool_working_dir = self._get_criteria_tool_out_folder(\ toolalias) tool_checkpointer = common_fs.CheckpointState( \ *self._get_criteria_tool_checkpoint_files( \ toolalias)) self.checkpointer.add_dep_checkpoint_state( \ tool_checkpointer) self.criteria_configured_tools[toolalias] = { self.TOOL_OBJ_KEY: self._create_criteria_tool( \ toolname, \ tool_working_dir, config, \ tool_checkpointer), self.TOOL_WORKDIR_KEY: tool_working_dir, } # verify supported criteria for criterion in self.tools_config_by_criterion_dict: for toolconf in self.tools_config_by_criterion_dict[criterion]: toolalias = toolconf.get_tool_config_alias() if criterion not in self.criteria_configured_tools[toolalias]\ [self.TOOL_OBJ_KEY].get_supported_criteria(): ERROR_HANDLER.error_exit( \ "tool {} specified for unsupported criterion {}".\ format(toolalias, criterion), __file__)