def writeCaseSummaryLine(self, test_case, file): diff_ok = nrtDiff.diff_ok_statuses(True) diff_warn = nrtDiff.diff_warn_statuses() diff_error = nrtDiff.diff_error_statuses(True) status_cell = "" if test_case.gives_satisfactory_results(): status_cell = "<td class='ok'>OK</td>" elif test_case.code_ == -150: status_cell = "<td class='tooLong'>TOO LONG</td>" else: status_cell = "<td class='nok'>NOK</td>" line = '<tr><td>' line += '<a href="#' + test_case.case_ + '">' + test_case.case_ + "</a><td>" + test_case.name_ line += "</td><td class='simuTime'>%s</td>" % timeToString( test_case.time_) + status_cell + "<td class='code'>" + str( test_case.code_) + "</td>" #reference data line += "<td class='" if (test_case.diff_ in diff_error): line += "comparisonNOk" elif (test_case.diff_ in diff_warn): line += "comparisonWarn" elif (test_case.diff_ in diff_ok): line += "comparisonOk" else: line += "noComparison" line += "'>" line += nrtDiff.toString(test_case.diff_, True) line += "</td></tr>" file.write(line)
def gives_satisfactory_results(self): if not self.ok_: return False if self.diff_ in nrtDiff.diff_error_statuses(True): return False return True
def writeStatistics(self, file): diff_error = nrtDiff.diff_error_statuses(True) nb_diff_failed = 0 nb_diff = 0 no_diff = nrtDiff.diff_neutral_statuses() for test_case in self.test_cases_: if (test_case.diff_ in diff_error): nb_diff_failed += 1 if (test_case.diff_ not in no_diff): nb_diff += 1 statistics = "<aside><h1>Statistics</h1><ul><li>Number of failed cases:</li><li>Number of too long cases:</li>" if (nb_diff > 0): statistics += "<li>Number of failed results comparisons:</li>" statistics += "<li>Complete simulation time(sum of time of each case):</li><li>Non Regression Tests time:</li><li>Number of processors used:</li></ul><ul>" addOnBeginFailed = "" addOnEndFailed = "" if (self.number_of_nok_cases_ > 0): addOnBeginFailed = "<a href = \"#Failed_cases\">" addOnEndFailed = "</a>" addOnBeginTooLong = "" addOnEndTooLong = "" if (self.number_of_tooLong_cases_ > 0): addOnBeginTooLong = "<a href = \"#TooLong_cases\">" addOnEndTooLong = "</a>" statistics += "<li>" + addOnBeginFailed + str(self.number_of_nok_cases_) + "/" + str(self.number_of_cases_) + addOnEndFailed+"</li>" \ + "<li>" + addOnBeginTooLong + str(self.number_of_tooLong_cases_) + "/" + str(self.number_of_cases_) + addOnEndTooLong+"</li>" \ if (nb_diff > 0): statistics += "<li>" + str(nb_diff_failed) + "/" + str( nb_diff) + "</li>" statistics += "<li>" + timeToString(self.total_time_) +"</li>" \ + "<li>" + timeToString(self.real_time_) + "</li>" \ + "<li>" + str(self.nb_processors_used_) + "</li>" \ + "</ul></aside>\n" file.write(statistics)
def writeDetailsCase(self, file, test_case): file.write('<h3 id="' + test_case.case_ + '">' + test_case.case_ + "</h3>") file.write("<table><tr><th>Properties</th><th>value</th></tr>") file.write("<tr><td>Name</td><td>" + test_case.name_ + "</td></tr>") file.write("<tr><td>Description</td><td>" + test_case.description_ + "</td></tr>") file.write("<tr><td>simulation time</td><td>" + timeToString(test_case.time_) + "</td></tr>") file.write("<tr><td>return code</td><td>" + str(test_case.code_) + "</td></tr>") line = "<tr><td>return status</td>" testcase_status = "OK" if (test_case.ok_): line += "<td class='ok'>OK</td></tr>" elif test_case.code_ == -150: line += "<td class='tooLong'>TOO LONG</td></tr>" testcase_status = "tooLong" else: line += "<td class='nok'>NOK<br />Dynawo simulation failed.</td></tr>" testcase_status = "KO" file.write(line) diff_status = "NoReference" if (test_case.diff_ not in nrtDiff.diff_neutral_statuses()): diff_ok = nrtDiff.diff_ok_statuses(True) diff_warn = nrtDiff.diff_warn_statuses() diff_error = nrtDiff.diff_error_statuses(True) line = "<tr><td>diff status</td><td class='" if (test_case.diff_ in diff_error): line += "comparisonNOk" diff_status = "KO" elif (test_case.diff_ in diff_warn): line += "comparisonWarn" diff_status = "Warn" elif (test_case.diff_ in diff_ok): line += "comparisonOk" diff_status = "OK" line += "'>" + nrtDiff.toString(test_case.diff_, True) if not (test_case.diff_ in diff_ok): if len(test_case.diff_messages_) > 0: line += "<br/><br/>" for message in test_case.diff_messages_: line += message + "<br/>" line += "</td></tr>" file.write(line) file.write("</table>") for job in test_case.jobs_: job_relative_dir = test_case.case_ + "/" + job.job_ job_output_dir = os.path.join(output_dir, job_relative_dir) file.write("<table><tr><th>Properties</th><th>value</th></tr>") file.write("<tr><td>Name</td><td>" + job.name_ + "</td></tr>") file.write("<tr><td>Description</td><td>" + job.description_ + "</td></tr>") file.write("<tr><td>Solver Used</td><td>" + job.solver_ + "</td></tr>") # copy all tree of outputs if os.path.isdir(job.output_dir_): shutil.copytree(job.output_dir_, job_output_dir) else: os.mkdir(job_output_dir) if job.timeline_ != None: basename = os.path.basename(job.timeline_) if os.path.isfile(job.timeline_): if os.path.getsize(job.timeline_) > 0: file.write('<tr><td>timeline</td><td><a href="' + job_relative_dir + "/timeLine/" + basename + '" target="_blank">' + basename + "</a></td></tr>") else: file.write( '<tr><td>timeline</td><td>no event</td></tr>') if job.constraints_ != None: basename = os.path.basename(job.constraints_) if os.path.isfile(job.constraints_): if os.path.getsize(job.constraints_) > 0: file.write('<tr><td>constraints</td><td><a href="' + job_relative_dir + "/constraints/" + basename + '" target="_blank">' + basename + "</a></td></tr>") else: file.write('<tr><td>constraints</td><td>' + basename + " (zero constraints)</a></td></tr>") for app in job.appenders_: basename = os.path.basename(app) if os.path.isfile(app): file.write('<tr><td>log file</td><td><a href="' + job_relative_dir + "/logs/" + basename + '" target="_blank">' + basename + "</a></td></tr>") if job.hasCurves_: curvesOutput = os.path.join(os.path.dirname(job.curves_), "curvesOutput") curvesOutputCopyDir = os.path.join(job_output_dir, "curvesOutput") if os.path.isdir(curvesOutput): file.write('<tr><td>curves output</td><td><a href="' + job_relative_dir + "/curves/curvesOutput/curves.html" + '" target="_blank">' + "curves.html" + '</a></td></tr>') file.write("</table>") # write job identification info into a text file info_file_path = os.path.join(job_output_dir, 'info.txt') if (os.path.isfile(info_file_path)): os.remove(info_file_path) info_file = open(info_file_path, "w") case_dir = os.path.relpath(os.path.dirname(job.file_), data_dir) path_list = case_dir.split(os.sep) if len(path_list) > 1: case_first_dir = case_dir.split(os.sep)[0] case_second_dir = case_dir.split(os.sep)[1] else: case_first_dir = "" case_second_dir = case_dir.split(os.sep)[0] # first line: job identification infos info_file.write(case_first_dir + '|' + case_second_dir + '|' + job.name_ + '|' + job.description_ + \ '|' + testcase_status + '|' + diff_status +'\n') # second line : path to jobs file info_file.write(job.file_) info_file.close() file.write('<ul></ul>') file.write("<aside><h1>case command:</h1><ul>" + test_case.command_ + "</ul></aside>\n") file.write('<ul><a href="#resume">Back to resume</a></ul>')