Skip to content

Commit

Permalink
Fixes race condition from using execute_results.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
TimSVector committed Apr 9, 2020
1 parent 2881dd1 commit b6d7d5a
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/main/resources/scripts/generate_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from vector.apps.ReportBuilder.custom_report import fmt_percent
from operator import attrgetter
from vector.enums import COVERAGE_TYPE_TYPE_T
import hashlib

def dummy(*args, **kwargs):
return None
Expand Down Expand Up @@ -472,17 +473,19 @@ def write_testcase_jUnit(self, tc, unit_name, func_name):
exp_pass += summary.control_flow_total - summary.control_flow_fail
exp_total += summary.control_flow_total + summary.signals + summary.unexpected_exceptions

exec_rpt_name = hashlib.md5("execution_results." + classname + "." + unit_subp + "." + tc_name).hexdigest()

self.api.report(
testcases=[tc],
single_testcase=True,
report_type="Demo",
formats=["TEXT"],
output_file="execution_results.txt",
output_file=exec_rpt_name,
sections=[ "TESTCASE_SECTIONS"],
testcase_sections=["EXECUTION_RESULTS"])

result = open("execution_results.txt","r").read()
os.remove("execution_results.txt")
result = open(exec_rpt_name,"r").read()
os.remove(exec_rpt_name)

# Failure takes priority
if not tc.passed:
Expand Down Expand Up @@ -532,20 +535,23 @@ def write_testcase_xUnit(self, tc, unit_name, func_name):
if tc.passed:
msg = "PASS"
else:
exec_rpt_name = hashlib.md5("execution_results." + classname + "." + unit_subp + "." + tc_name).hexdigest()

self.api.report(
testcases=[tc],
single_testcase=True,
report_type="Demo",
formats=["TEXT"],
output_file="execution_results.txt",
output_file=exec_rpt_name,
sections=[ "TESTCASE_SECTIONS"],
testcase_sections=["EXECUTION_RESULTS"])

result = open("execution_results.txt","r").read()
result = open(exec_rpt_name,"r").read()
result = cgi.escape(result)
result = result.replace("\"","")
result = result.replace("\n","
")
msg = "FAIL {} / {} Execution Report:\n {}".format(exp_pass, exp_total, result)
os.remove(exec_rpt_name)

self.fh.write(' <message>%s</message>\n' % msg)
self.fh.write(' </test>\n')
Expand Down

0 comments on commit b6d7d5a

Please sign in to comment.