def output_before_run_set(self, runSet, start_time=None): """ The method output_before_run_set() calculates the length of the first column for the output in terminal and stores information about the runSet in XML. @param runSet: current run set """ xml_file_name = self.get_filename(runSet.name, "xml") identifier_names = [run.identifier for run in runSet.runs] # common prefix of file names runSet.common_prefix = util.common_base_dir(identifier_names) if runSet.common_prefix: runSet.common_prefix += os.path.sep # length of the first column in terminal runSet.max_length_of_filename = (max( len(file) for file in identifier_names) if identifier_names else 20) runSet.max_length_of_filename = max( 20, runSet.max_length_of_filename - len(runSet.common_prefix)) # write run set name to terminal numberOfFiles = len(runSet.runs) numberOfFilesStr = (" (1 file)" if numberOfFiles == 1 else f" ({numberOfFiles} files)") util.printOut("\nexecuting run set" + (" '" + runSet.name + "'" if runSet.name else "") + numberOfFilesStr + TERMINAL_TITLE.format(runSet.full_name)) # write information about the run set into txt_file self.writeRunSetInfoToLog(runSet) # prepare information for text output for run in runSet.runs: run.resultline = self.format_sourcefile_name( run.identifier, runSet) if run.sourcefiles: adjusted_identifier = util.relative_path( run.identifier, xml_file_name) else: # If no source files exist the task doesn't point to any file that could be downloaded. # In this case, the name doesn't have to be adjusted because it's no path. adjusted_identifier = run.identifier # prepare XML structure for each run and runSet run.xml = ElementTree.Element("run", name=adjusted_identifier) if run.sourcefiles: adjusted_sourcefiles = (util.relative_path(s, xml_file_name) for s in run.sourcefiles) run.xml.set("files", "[" + ", ".join(adjusted_sourcefiles) + "]") if run.specific_options: run.xml.set("options", " ".join(run.specific_options)) if run.properties: all_properties = (prop.name for prop in run.properties) run.xml.set("properties", " ".join(sorted(all_properties))) if len(run.properties) == 1: prop = run.properties[0] run.xml.set("propertyFile", util.relative_path(prop.filename, xml_file_name)) expected_result = str( run.expected_results.get(prop.filename, "")) if expected_result: run.xml.set("expectedVerdict", expected_result) block_name = runSet.blocks[0].name if len(runSet.blocks) == 1 else None runSet.xml = self.runs_to_xml(runSet, runSet.runs, block_name) if start_time: runSet.xml.set("starttime", start_time.isoformat()) elif not self.benchmark.config.start_time: runSet.xml.set("starttime", util.read_local_time().isoformat()) # write (empty) results to XML runSet.xml_file_name = xml_file_name self._write_rough_result_xml_to_file(runSet.xml, runSet.xml_file_name) runSet.xml_file_last_modified_time = time.monotonic() self.all_created_files.add(runSet.xml_file_name) self.xml_file_names.append(runSet.xml_file_name)
def output_before_run_set(self, runSet): """ The method output_before_run_set() calculates the length of the first column for the output in terminal and stores information about the runSet in XML. @param runSet: current run set """ xml_file_name = self.get_filename(runSet.name, "xml") identifier_names = [run.identifier for run in runSet.runs] # common prefix of file names runSet.common_prefix = util.common_base_dir(identifier_names) if runSet.common_prefix: runSet.common_prefix += os.path.sep # length of the first column in terminal runSet.max_length_of_filename = max(len(file) for file in identifier_names) if identifier_names else 20 runSet.max_length_of_filename = max(20, runSet.max_length_of_filename - len(runSet.common_prefix)) # write run set name to terminal numberOfFiles = len(runSet.runs) numberOfFilesStr = (" (1 file)" if numberOfFiles == 1 else " ({0} files)".format(numberOfFiles)) util.printOut("\nexecuting run set" + (" '" + runSet.name + "'" if runSet.name else "") + numberOfFilesStr + TERMINAL_TITLE.format(runSet.full_name)) # write information about the run set into txt_file self.writeRunSetInfoToLog(runSet) # prepare information for text output for run in runSet.runs: run.resultline = self.format_sourcefile_name(run.identifier, runSet) if run.sourcefiles: adjusted_identifier = util.relative_path(run.identifier, xml_file_name) else: # If no source files exist the task doesn't point to any file that could be downloaded. # In this case, the name doesn't have to be adjusted because it's no path. adjusted_identifier = run.identifier # prepare XML structure for each run and runSet run_attributes = {'name': adjusted_identifier} if run.sourcefiles: adjusted_sourcefiles = [util.relative_path(s, xml_file_name) for s in run.sourcefiles] run_attributes['files'] = '[' + ', '.join(adjusted_sourcefiles) + ']' run.xml = ET.Element("run", run_attributes) if run.specific_options: run.xml.set("options", " ".join(run.specific_options)) if run.properties: all_properties = [prop_name for prop in run.properties for prop_name in prop.names] run.xml.set("properties", " ".join(sorted(all_properties))) run.xml.extend(self.xml_dummy_elements) block_name = runSet.blocks[0].name if len(runSet.blocks) == 1 else None runSet.xml = self.runs_to_xml(runSet, runSet.runs, block_name) # write (empty) results to txt_file and XML self.txt_file.append(self.run_set_to_text(runSet), False) runSet.xml_file_name = xml_file_name self._write_rough_result_xml_to_file(runSet.xml, runSet.xml_file_name) runSet.xml_file_last_modified_time = util.read_monotonic_time() self.all_created_files.add(runSet.xml_file_name) self.xml_file_names.append(runSet.xml_file_name)