Skip to content

Commit a4780a1

Browse files
committed
Updates
1 parent b93b893 commit a4780a1

2 files changed

Lines changed: 21 additions & 32 deletions

File tree

src/main/resources/scripts/generate_qa_results_xml.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
except ImportError:
66
# html not standard module in Python 2.
77
from cgi import escape
8-
import sys, subprocess, os
8+
import sys, subprocess, os
9+
from vcast_utils import dump, getVectorCASTEncoding
10+
911
global saved_compiler, saved_testsuite, saved_envname
1012

1113
saved_compiler = ""
@@ -18,32 +20,30 @@ def get_timestamp():
1820
if hour > 12:
1921
hour -= 12
2022
return dt.strftime('%d %b %Y @HR@:%M:%S %p').upper().replace('@HR@', str(hour))
21-
23+
2224
def writeJunitHeader(currentEnv, junitfile, failed, total, unit_report_name, encoding = 'UTF-8'):
23-
24-
junitfile.write("<?xml version=\"1.0\" encoding=\"" + encoding.upper() + "\"?>\n")
25+
26+
data = "<?xml version=\"1.0\" encoding=\"{}\"?>\n".format(encoding)
27+
data += "<testsuites>\n <!-- {} -->\n".format(unit_report_name)
28+
data += " <testsuite errors=\"{}\" tests=\"{}\" failures=\"{}\" name=\"{}\" id=\"1\">\n".format(0, total, failed, currentEnv)
2529

26-
junitfile.write("<testsuites>\n <!--" + unit_report_name + "-->\n")
27-
28-
junitfile.write(" <testsuite errors=\"%d\" tests=\"%d\" failures=\"%d\" name=\"%s\" id=\"1\">\n" %
29-
(0, total, failed, currentEnv))
30+
junitfile.write(data.encode(encoding, "replace"))
3031

31-
def writeJunitData(junitfile,all_tc_data):
32-
junitfile.write(all_tc_data)
32+
def writeJunitData(junitfile,all_tc_data, encoding):
33+
junitfile.write(all_tc_data.encode(encoding, "replace"))
3334

34-
def writeJunitFooter(junitfile):
35-
junitfile.write(" </testsuite>\n")
36-
junitfile.write("</testsuites>\n")
35+
def writeJunitFooter(junitfile, encoding):
36+
junitfile.write(" </testsuite>\n".encode(encoding, "replace"))
37+
junitfile.write("</testsuites>\n".encode(encoding, "replace"))
3738

3839
def write_tc_data(currentEnv, unit_report_name, jobNameDotted, passed, failed, error, testcase_data, encoding = 'utf-8', xml_data_dir = "xml_data"):
3940

40-
fh = open(os.path.join(xml_data_dir,unit_report_name), "w")
41-
42-
writeJunitHeader(currentEnv, fh, failed, failed+passed, unit_report_name, encoding)
43-
writeJunitData(fh, testcase_data)
44-
writeJunitFooter(fh)
45-
fh.close()
46-
41+
with open(os.path.join(xml_data_dir,unit_report_name), "wb") as fh:
42+
encoding = getVectorCASTEncoding()
43+
writeJunitHeader(currentEnv, fh, failed, failed+passed, unit_report_name, encoding)
44+
writeJunitData(fh, testcase_data, encoding)
45+
writeJunitFooter(fh, encoding)
46+
4747
def generateJunitTestCase(jobname, tc_name, passFail):
4848
testCasePassString =" <testcase name=\"%s\" classname=\"%s\" time=\"0\"/>\n"
4949
testCaseFailString =""" <testcase name="%s" classname="%s" time="0">

src/main/resources/scripts/generate_xml.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -479,12 +479,7 @@ def _generate_cover(self, cov_type):
479479
functions_added = False
480480
funcs_with_cover_data = []
481481
for func in srcFile.functions:
482-
try:
483-
hasAnyCov = func.has_coverage_data
484-
except:
485-
hasAnyCov = func.instrumented_functions[0].has_coverage_data
486-
487-
if hasAnyCov:
482+
if self.hasAnyCov(func):
488483
functions_added = True
489484
funcs_with_cover_data.append(func)
490485

@@ -499,8 +494,6 @@ def _generate_cover(self, cov_type):
499494
sorted_funcs.sort(key=lambda x: (x.name))
500495

501496
for func in sorted_funcs:
502-
503-
504497
try:
505498
cover_function = func.cover_data.metrics
506499
except:
@@ -525,16 +518,12 @@ def _generate_cover(self, cov_type):
525518

526519
self.grand_total_max_covered_branches += metrics.max_covered_branches + metrics.max_covered_mcdc_branches
527520
self.grand_total_branches += metrics.branches + metrics.mcdc_branches
528-
529521
self.grand_total_max_covered_statements += metrics.max_covered_statements
530522
self.grand_total_statements += metrics.statements
531-
532523
self.grand_total_max_mcdc_covered_branches += metrics.max_covered_mcdc_branches
533524
self.grand_total_mcdc_branches += metrics.mcdc_branches
534-
535525
self.grand_total_max_covered_mcdc_pairs += metrics.max_covered_mcdc_pairs
536526
self.grand_total_mcdc_pairs += metrics.mcdc_pairs
537-
538527
self.grand_total_max_covered_function_calls += metrics.max_covered_function_calls
539528
self.grand_total_function_calls += metrics.function_calls
540529

0 commit comments

Comments
 (0)