Skip to content

Commit e8b1e03

Browse files
committed
Updates from testing
1 parent 11bbf4e commit e8b1e03

File tree

3 files changed

+69
-21
lines changed

3 files changed

+69
-21
lines changed

src/main/resources/scripts/cobertura.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ def getFileXML(testXml, coverAPI, verbose = False, extended = False, source_root
8787
fname = coverAPI.display_name
8888
fpath = os.path.relpath(coverAPI.display_path,prj_dir).replace("\\","/")
8989

90-
new_path = os.path.join(source_root,fpath.rsplit('/',1)[0])
91-
fpath = new_path.replace("\\","/")
92-
9390
branch_totals = float(coverAPI.metrics.branches + coverAPI.metrics.mcdc_branches)
9491
branch_covered = float(coverAPI.metrics.max_covered_branches + coverAPI.metrics.max_covered_mcdc_branches)
9592

@@ -447,8 +444,8 @@ def runCoberturaResults(packages, api, verbose = False, extended = False, source
447444
if not has_any_coverage(file):
448445
continue
449446

450-
#fpath = file.display_path.rsplit('.',1)[0]
451-
fpath = file.display_name
447+
fname = file.display_name
448+
fpath = file.display_path.rsplit('.',1)[0]
452449
fpath = os.path.relpath(fpath,prj_dir).replace("\\","/")
453450

454451
# print("*", file.name, file.display_name, fpath)
@@ -459,7 +456,6 @@ def runCoberturaResults(packages, api, verbose = False, extended = False, source
459456
file = fileDict[path]
460457
new_path = path.rsplit('/',1)[0]
461458

462-
463459
# when we switch paths
464460
if new_path != path_name:
465461

@@ -500,7 +496,7 @@ def runCoberturaResults(packages, api, verbose = False, extended = False, source
500496
# remove trailing . if present
501497
package_name = path_name.replace("/",".")
502498
package_name = package_name.lstrip(".")
503-
499+
504500
if package_name.endswith("."):
505501
package_name = package_name[:-1]
506502

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.tooltip {
2+
position: relative;
3+
display: inline-block;
4+
border-bottom: 2px dotted orange;
5+
}
6+
7+
.tooltip .tooltiptext {
8+
visibility: hidden;
9+
width: max-content;
10+
background-color: black;
11+
color: #fff;
12+
text-align: left;
13+
border-radius: 6px;
14+
padding: 5px 0;
15+
16+
/* Position the tooltip */
17+
position: absolute;
18+
z-index: 1;
19+
bottom: 150%;
20+
left: 50%;
21+
margin-left: -60px;
22+
}
23+
24+
.tooltip:hover .tooltiptext {
25+
visibility: visible;
26+
}
27+
28+
pre {background-color:#fcfcfc;}

src/main/resources/scripts/generate_lcov.py

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from collections import defaultdict
3939
from pprint import pprint
4040
import subprocess
41+
import argparse
4142

4243
from vcast_utils import dump, checkVectorCASTVersion
4344

@@ -112,9 +113,9 @@ def runCoverageResultsMP(mpFile, verbose = False, testName = "", source_root = "
112113
vcproj = VCProjectApi(mpFile)
113114
api = vcproj.project.cover_api
114115

115-
return runGcovResults(api, verbose = False, testName = vcproj.project.name, source_root=source_root)
116+
return runGcovResults(api, verbose = verbose, testName = vcproj.project.name, source_root=source_root)
116117

117-
def runGcovResults(api, verbose = False, testName = "", source_root = ""):
118+
def runGcovResults(api, verbose = False, testName = "", source_root = "") :
118119

119120
fileDict = {}
120121
try:
@@ -167,11 +168,13 @@ def runGcovResults(api, verbose = False, testName = "", source_root = ""):
167168
FNDA.append("FNDA:1" + "," + fName)
168169
else:
169170
FNDA.append("FNDA:0" + "," + fName)
170-
171+
171172
block_count = 0
172173
branch_number = 0
173174
line_branch = []
174-
175+
176+
last_line = ""
177+
175178
for line in func.iterate_coverage():
176179
if has_any_coverage(line):
177180
LF += 1
@@ -182,6 +185,8 @@ def runGcovResults(api, verbose = False, testName = "", source_root = ""):
182185
lineCovered = "0"
183186
DA.append("DA:" + str(line.line_number) + "," + lineCovered)
184187

188+
last_line = line.text
189+
185190
newBranch = False
186191
if has_branch_coverage(line) > 0:
187192
BRF += 1
@@ -200,6 +205,13 @@ def runGcovResults(api, verbose = False, testName = "", source_root = ""):
200205
if newBranch:
201206
block_count += 1
202207
branch_number += 1
208+
209+
210+
if "return" not in last_line:
211+
if verbose: print("counting last line: ", func.name, line.line_number,last_line)
212+
DA.append("DA:" + str(line.line_number) + ",1")
213+
else:
214+
if verbose: print("not counting last line: ", func.name, line.line_number,last_line)
203215

204216
for idx in range(0,len(FN)):
205217
output += FN[idx] + "\n"
@@ -268,22 +280,34 @@ def generateCoverageResults(inFile, xml_data_dir = "xml_data", verbose = False,
268280
if not checkVectorCASTVersion(21):
269281
print("Cannot create LCOV metrics. Please upgrade VectorCAST")
270282
sys.exit()
271-
283+
284+
parser = argparse.ArgumentParser()
285+
parser.add_argument('vcProjectName', help='VectorCAST Project Name', action="store")
286+
parser.add_argument('-v', '--verbose', help='Enable versobe output', dest="verbose", action="store_true", default=False)
287+
args = parser.parse_args()
288+
272289
try:
273-
inFile = sys.argv[1]
290+
inFile = args.vcProjectName
274291
if not inFile.endswith(".vcm"):
275292
inFile += ".vcm"
276293
except:
277294
inFile = os.getenv('VCAST_MANAGE_PROJECT_DIRECTORY') + ".vcm"
295+
296+
if args.verbose: print ("Running in verbose mode")
278297

279-
passed = generateCoverageResults(inFile, xml_data_dir = "xml_data", verbose = False, source_root = "")
298+
passed = generateCoverageResults(inFile, xml_data_dir = "xml_data", verbose = args.verbose, source_root = "")
280299

281-
## if opened from VectorCAST GUI...
282-
if passed and not os.getenv('VCAST_MANAGE_PROJECT_DIRECTORY') is None:
283-
from vector.lib.core import VC_Report_Client
300+
try:
301+
## if opened from VectorCAST GUI...
302+
if passed and not os.getenv('VCAST_MANAGE_PROJECT_DIRECTORY') is None:
303+
from vector.lib.core import VC_Report_Client
304+
305+
# Open report in VectorCAST GUI
306+
report_client = VC_Report_Client.ReportClient()
307+
if report_client.is_connected():
308+
report_client.open_report("out/index.html", "lcov Results")
309+
except:
310+
pass
311+
284312

285-
# Open report in VectorCAST GUI
286-
report_client = VC_Report_Client.ReportClient()
287-
if report_client.is_connected():
288-
report_client.open_report("out/index.html", "lcov Results")
289313

0 commit comments

Comments
 (0)