Skip to content

Commit 010720d

Browse files
committed
Correcting location for report generation
1 parent 11e1cd9 commit 010720d

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

create_index_html.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,24 +58,28 @@ def getReportName(filename):
5858
return reportName, reportType
5959

6060
usingGitLabCI = False
61+
baseOutputDir = ""
6162

62-
def create_index_html(mpName, isGitLab = False):
63+
def create_index_html(mpName, isGitLab = False, output_dir = ""):
6364
import pathlib
6465
from vector.apps.DataAPI.vcproject_api import VCProjectApi
6566
from vector.apps.ReportBuilder.custom_report import CustomReport
6667

6768
global usingGitLabCI
6869
usingGitLabCI = isGitLab
6970

71+
global baseOutputDir
72+
baseOutputDir = output_dir
73+
7074
api = VCProjectApi(mpName)
7175
# Set custom report directory to the where this script was
7276
# found. Must contain sections/index_section.py
7377
rep_path = pathlib.Path(__file__).parent.resolve()
7478

7579
if usingGitLabCI:
76-
output_file="index.html"
80+
output_file=os.path.join(baseOutputDir,"index.html")
7781
else:
78-
output_file="index.html"
82+
output_file=os.path.join(baseOutputDir,"index.html")
7983

8084
CustomReport.report_from_api(
8185
api=api,
@@ -90,9 +94,9 @@ def create_index_html(mpName, isGitLab = False):
9094

9195
def create_index_html_body ():
9296

93-
tempHtmlReportList = glob.glob("*.html")
94-
tempHtmlReportList += glob.glob("html_reports/*.html")
95-
tempHtmlReportList += glob.glob("management/*.html")
97+
tempHtmlReportList = glob.glob(os.path.join(baseOutputDir,"*.html"))
98+
tempHtmlReportList += glob.glob(os.path.join(baseOutputDir,"html_reports/*.html"))
99+
tempHtmlReportList += glob.glob(os.path.join(baseOutputDir,"management/*.html"))
96100

97101
htmlReportList = []
98102
try:

vcast_exec.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,12 @@ def __init__(self, args):
124124
self.failed_count = 0
125125

126126
if args.output_dir:
127+
self.output_dir = args.output_dir
127128
self.xml_data_dir = os.path.join(args.output_dir, 'xml_data')
128129
if not os.path.exists(self.xml_data_dir):
129130
os.makedirs(self.xml_data_dir)
130131
else:
132+
self.output_dir = ""
131133
self.xml_data_dir = "xml_data"
132134

133135
if args.build and not args.build_execute:
@@ -230,7 +232,8 @@ def generateIndexHtml(self):
230232
prj_dir = os.getcwd().replace("\\","/") + "/"
231233

232234
tempHtmlReportList = glob.glob("*.html")
233-
tempHtmlReportList += glob.glob(os.path.join(args.html_base_dir, "*.html"))
235+
tempHtmlReportList += glob.glob(os.path.join(self.xml_data_dir, "*.html"))
236+
tempHtmlReportList += glob.glob(os.path.join(self.html_base_dir, "*.html"))
234237
htmlReportList = []
235238

236239
for report in tempHtmlReportList:
@@ -240,7 +243,7 @@ def generateIndexHtml(self):
240243
htmlReportList.append(report)
241244

242245
from create_index_html import create_index_html
243-
create_index_html(self.FullMP, self.ciTool == CITool.GITLAB)
246+
create_index_html(self.FullMP, self.ciTool == CITool.GITLAB, output_dir=self.output_dir)
244247

245248
def runJunitMetrics(self):
246249
print("Creating JUnit Metrics")
@@ -329,23 +332,32 @@ def runPcLintPlusMetrics(self):
329332

330333
def runReports(self):
331334
if self.aggregate:
335+
agg_rpt_name = os.path.join(self.output_dir, self.mpName + "_aggregate_report.html")
332336
print("Creating Aggregate Coverage Report")
333-
self.manageWait.exec_manage_command ("--create-report=aggregate --output=" + self.mpName + "_aggregate_report.html")
337+
if os.path.exists(agg_rpt_name):
338+
os.remove(agg_rpt_name)
339+
self.manageWait.exec_manage_command ("--create-report=aggregate --output=" + agg_rpt_name)
334340
self.needIndexHtml = True
335341
if self.metrics:
342+
met_rpt_name = os.path.join(self.output_dir, self.mpName + "_metrics_report.html")
336343
print("Creating Metrics Report")
337-
self.manageWait.exec_manage_command ("--create-report=metrics --output=" + self.mpName + "_metrics_report.html")
344+
if os.path.exists(met_rpt_name):
345+
os.remove(met_rpt_name)
346+
self.manageWait.exec_manage_command ("--create-report=metrics --output=" + met_rpt_name)
338347
self.needIndexHtml = True
339348
if self.fullstatus:
349+
fs_rpt_name = os.path.join(self.output_dir, self.mpName + "_full_status_report.html")
350+
if os.path.exists(fs_rpt_name):
351+
os.remove(fs_rpt_name)
340352
print("Creating Full Status Report")
341-
self.manageWait.exec_manage_command ("--full-status=" + self.mpName + "_full_status_report.html")
353+
self.manageWait.exec_manage_command ("--full-status=" + fs_rpt_name)
342354
self.needIndexHtml = True
343355

344356
def generateTestCaseMgtRpt(self):
345-
if not os.path.exists("management"):
346-
os.makedirs("management")
357+
if not os.path.exists(os.path.join(self.output_dir, "management")):
358+
os.makedirs(os.path.join(self.output_dir, "management"))
347359
else:
348-
for file in glob.glob("management/*_management_report.html"):
360+
for file in glob.glob(os.path.join(self.output_dir, "management","*_management_report.html")):
349361
os.remove(file)
350362

351363
if checkVectorCASTVersion(21):
@@ -360,7 +372,7 @@ def generateTestCaseMgtRpt(self):
360372
self.needIndexHtml = True
361373

362374
report_name = env.compiler.name + "_" + env.testsuite.name + "_" + env.name + "_management_report.html"
363-
report_name = os.path.join("management",report_name)
375+
report_name = os.path.join(self.output_dir, "management",report_name)
364376
print(f"Creating Test Case Management HTML report for {env.name} in {report_name}")
365377
env.api.report(report_type="MANAGEMENT_REPORT", formats=["HTML"], output_file=report_name)
366378
else:

0 commit comments

Comments
 (0)