| Environment Name | ",filename)
+ if env_name == None:
+ reportName = "Aggregate Coverage Report"
+ else:
+ reportName = "Aggregate Coverage Report {}".format(env_name)
+ reportType = 1
- elif "full_status" in filename:
- manageProject = filename.split("_aggregate",1)[0]
+ elif searchKeyword(">Full Status Section<", filename)[0] != -1:
reportName = "Full Status Report"
- elif "environment" in filename:
- manageProject = filename.split("_environment",1)[0]
- reportName = "Environment Report"
-
- elif "manage_incremental_rebuild_report" in filename:
- manageProject = filename.split("_manage_incremental_rebuild_report",1)[0]
+ elif searchKeyword("Manage Incremental Rebuild Report", filename)[0] != -1:
reportName = "Incremental Report Report"
- elif "metrics" in filename:
- manageProject = filename.split("_metrics",1)[0]
+ elif searchKeyword(">Metrics Report<", filename)[0] != -1:
reportName = "Metrics Report"
- elif "html_reports" in filename:
- ## html_reports/VectorCAST_MinGW_C++_UnitTesting_ENV_LINKED_LIST.html
- comp_ts_env = filename.replace("html_reports/","").replace(".html","")
- reportName = comp_ts_env
+ elif searchKeyword(">Test Case Summary Report<", filename)[0] != -1:
+ reportName = "System Test Status Report"
+
+ elif searchKeyword(">PC-Lint Plus Results<", filename)[0] != -1:
+ reportName = "PC-Lint Plus Results"
+
+ elif searchKeyword(">PC-Lint Plus Results<", filename)[0] != -1:
+ reportName = "PC-Lint Plus Results"
+
+ elif searchKeyword(">Full Report<", filename)[0] != -1:
+ reportName = "Full Report "
+ reportName += getEnvName(" |
|---|
| Environment Name | ",filename)
+
reportType = 1
- elif "management" in filename:
- comp_ts_env = filename.replace("management/","").replace(".html","")
- reportName = comp_ts_env
- reportType = 3
-
else:
reportType = 2
return reportName, reportType
usingGitLabCI = False
+baseOutputDir = ""
-def create_index_html(mpName, isGitLab = False):
- import pathlib
+def create_index_html(mpName, isGitLab = False, output_dir = ""):
from vector.apps.DataAPI.vcproject_api import VCProjectApi
from vector.apps.ReportBuilder.custom_report import CustomReport
global usingGitLabCI
usingGitLabCI = isGitLab
- api = VCProjectApi(mpName)
+ global baseOutputDir
+ baseOutputDir = output_dir
+
+ vcproj = VCProjectApi(mpName)
+
# Set custom report directory to the where this script was
# found. Must contain sections/index_section.py
- rep_path = pathlib.Path(__file__).parent.resolve()
+ rep_path = os.path.abspath(os.path.dirname(__file__))
- if usingGitLabCI:
- output_file="html_reports/index.html"
- else:
- output_file="index.html"
+ output_file=os.path.join(baseOutputDir,"index.html")
CustomReport.report_from_api(
- api=api,
+ api=vcproj,
title="HTML Reports",
report_type="INDEX_FILE",
formats=["HTML"],
output_file=output_file,
sections=['CUSTOM_HEADER', 'REPORT_TITLE', 'TABLE_OF_CONTENTS','INDEX_SECTION', 'CUSTOM_FOOTER'],
customization_dir=rep_path)
-
- api.close()
-
+ vcproj.close()
+
def create_index_html_body ():
- tempHtmlReportList = glob.glob("*.html")
- tempHtmlReportList += glob.glob("html_reports/*.html")
- tempHtmlReportList += glob.glob("management/*.html")
+ tempHtmlReportList = glob.glob(os.path.join(baseOutputDir,"*.html"))
+ tempHtmlReportList += glob.glob(os.path.join(baseOutputDir,"html_reports/*.html"))
+ tempHtmlReportList += glob.glob(os.path.join(baseOutputDir,"management/*.html"))
htmlReportList = []
try:
diff --git a/src/main/resources/scripts/fixup_reports.py b/src/main/resources/scripts/fixup_reports.py
index d0314802..dee40364 100644
--- a/src/main/resources/scripts/fixup_reports.py
+++ b/src/main/resources/scripts/fixup_reports.py
@@ -25,25 +25,22 @@
from __future__ import division
from __future__ import print_function
+import sys, os, locale
+
import sys, os
# adding path
-workspace = os.getenv("WORKSPACE")
-if workspace is None:
- workspace = os.getcwd()
-
-jenkinsScriptHome = os.path.join(workspace,"vc_scripts")
-python_path_updates = jenkinsScriptHome
-sys.path.append(python_path_updates)
-
-# needed because vc18 vpython does not have bs4 package
if sys.version_info[0] < 3:
- python_path_updates += os.sep + 'vpython-addons'
+ python_path_updates = os.path.join(os.path.dirname(os.path.abspath(__file__)),'vpython-addons')
sys.path.append(python_path_updates)
from bs4 import BeautifulSoup
-from safe_open import open
+try:
+ from safe_open import open
+except:
+ pass
import tee_print
+from vcast_utils import getVectorCASTEncoding
def fixup_2020_soup(main_soup):
@@ -76,6 +73,7 @@ def fixup_2020_soup(main_soup):
'col_subprogram': 'word-break:break-all;width:30%;',
'col_complexity': 'white-space:nowrap;',
'col_metric': 'white-space:nowrap;',
+ 'mcdc-all-pairs': 'white-space:nowrap;',
'i0' : 'padding-left:0.25em;min-width:11em',
'i1' : 'padding-left: 1.25em;min-width: 11em;',
'i2' : 'padding-left: 2.25em;',
@@ -107,18 +105,42 @@ def fixup_2020_soup(main_soup):
return main_soup
def fixup_2020_reports(report_name):
- with open(report_name,"r") as fd:
+
+ encFmt = getVectorCASTEncoding()
+
+ with open(report_name, "rb") as fd:
+ raw = fd.read().decode(encFmt, "replace")
+
+ try:
+ # First attempt: use lxml if available, else let BS pick
try:
- main_soup = BeautifulSoup(fd,features="lxml")
- except:
- main_soup = BeautifulSoup(fd)
+ import lxml # noqa
+ parser = "lxml"
+ except ImportError:
+ parser = "html.parser"
+
+ main_soup = BeautifulSoup(raw, features=parser)
+
+ except Exception:
+ try:
+ # Fallback to UTF-8
+ main_soup = BeautifulSoup(
+ raw.encode("utf-8", "replace"),
+ features=parser
+ )
+ except Exception:
+ main_soup = BeautifulSoup(
+ raw.encode(encFmt, "replace")
+ )
main_soup = fixup_2020_soup(main_soup)
- with open(report_name,"w") as fd:
- fd.write(main_soup.prettify(formatter="html"))
-
+ with open(report_name, "wb") as fd:
+ fd.write(main_soup.prettify(formatter="html").encode(encFmt, "replace"))
+
+
if __name__ == '__main__':
+
report_name = sys.argv[1]
fixup_2020_reports(report_name)
diff --git a/src/main/resources/scripts/full_report_no_toc.py b/src/main/resources/scripts/full_report_no_toc.py
index ff36124f..efd84a28 100644
--- a/src/main/resources/scripts/full_report_no_toc.py
+++ b/src/main/resources/scripts/full_report_no_toc.py
@@ -36,23 +36,6 @@ def generate_full_status(manageProject):
mpName = os.path.splitext(os.path.basename(manageProject))[0]
full_report_name = mpName + "_full_report.html"
metrics_report_name = mpName + "_metrics_report.html"
-
- # try:
- # from vector.apps.DataAPI.vcproject_api import VCProjectApi
- # api = VCProjectApi(manageProject)
-
- # api.report(report_type="MANAGE_STATUS_FULL_REPORT", formats=["HTML"], output_file=full_report_name , environments=api.Environment.all(), levels = [])
- # api.report(report_type="MANAGE_METRICS_REPORT" , formats=["HTML"], output_file=metrics_report_name, environments=api.Environment.all(), levels = [])
-
- # shutil.copy(full_report_name,full_report_name + "_tmp")
- # fixup_reports.fixup_2020_reports(full_report_name + "_tmp")
-
- # shutil.copy(metrics_report_name,metrics_report_name + "_tmp")
- # fixup_reports.fixup_2020_reports(metrics_report_name + "_tmp")
-
- # api.close()
-
- # except:
from managewait import ManageWait
diff --git a/src/main/resources/scripts/generate-results.py b/src/main/resources/scripts/generate-results.py
index dc6871f9..785429a2 100644
--- a/src/main/resources/scripts/generate-results.py
+++ b/src/main/resources/scripts/generate-results.py
@@ -1,7 +1,7 @@
#
# The MIT License
#
-# Copyright 2024 Vector Informatik, GmbH.
+# Copyright 2025 Vector Informatik, GmbH.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -27,6 +27,7 @@
import os
import sys
+
import argparse
import shutil
import re
@@ -38,23 +39,8 @@
import tee_print
from safe_open import open
+from vcast_utils import getVectorCASTEncoding
-# adding path
-workspace = os.getenv("WORKSPACE")
-if workspace is None:
- workspace = os.getcwd()
-
-jenkinsScriptHome = os.path.join(workspace,"vc_scripts")
-
-python_path_updates = jenkinsScriptHome
-sys.path.append(python_path_updates)
-
-if sys.version_info[0] < 3:
- python_path_updates += os.sep + 'vpython-addons'
- sys.path.append(python_path_updates)
- using_27_python = True
-else:
- using_27_python = False
import tcmr2csv
import vcastcsv2jenkins
@@ -81,7 +67,9 @@
from vector.apps.DataAPI.vcproject_api import VCProjectApi
except:
pass
-
+
+encFmt = getVectorCASTEncoding()
+
#global variables
global verbose
global print_exc
@@ -178,11 +166,14 @@ def readManageVersion(ManageFile):
version = 14
if os.path.isfile(ManageFile + ".vcm"):
ManageFile = ManageFile + '.vcm'
- with open(ManageFile, 'r') as projFile:
- for line in projFile:
+
+ with open(ManageFile, 'rb') as projFile:
+ for raw_line in projFile: # iterates lazily, line by line
+ line = raw_line.decode(encFmt, "replace") # decode each line
if 'version' in line and 'project' in line:
version = int(re.findall(r'\d+', line)[0])
break
+
if verbose:
print("Version of VectorCAST project file = %d" % version)
print("(Levels change in version 17 (*maybe) and above)")
@@ -308,8 +299,8 @@ def fixup_css(report_name):
if not need_fixup:
return
- with open(report_name,"r") as fd:
- data = fd.read()
+ with open(report_name,"rb") as fd:
+ data = fd.read().decode('utf-8','replace')
#fix up inline CSS because of Content Security Policy violation
newData = data[: data.index(" |
|---|