Skip to content

Commit e979fb6

Browse files
committed
Reverting calls to not use imported results on lcov and cobertuyra
1 parent 4b10ff6 commit e979fb6

File tree

2 files changed

+21
-56
lines changed

2 files changed

+21
-56
lines changed

src/main/resources/scripts/cobertura.py

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
fileList = []
4646

47-
from vcast_utils import dump, checkVectorCASTVersion, getVectorCASTEncoding, checkProjectResults
47+
from vcast_utils import dump, checkVectorCASTVersion, getVectorCASTEncoding
4848

4949
encFmt = getVectorCASTEncoding()
5050

@@ -347,13 +347,11 @@ def procesCoverage(coverXML, coverApi, extended = False, source_root = ""):
347347

348348
if extended:
349349
for func in coverApi.functions:
350-
351-
if isinstance(func.instrumented_functions[0].parameterized_name, bool):
352-
continue
353-
350+
354351
method = etree.SubElement(methods, "method")
352+
355353
method.attrib['name'] = func.name
356-
method.attrib['signature'] = func.instrumented_functions[0].parameterized_name.replace(func.name,"",1)
354+
method.attrib['signature'] = func.instrumented_functions[0].parameterized_name.replace(func.name,"",1)
357355
method.attrib['line-rate'] = str(func.metrics.max_covered_statements_pct/100.0)
358356

359357
statementPercentStr = "{:.2f}".format(func.metrics.max_covered_statements_pct) + "% (" + str(func.metrics.max_covered_statements) + "/" + str(func.metrics.statements) + ")"
@@ -389,23 +387,9 @@ def procesCoverage(coverXML, coverApi, extended = False, source_root = ""):
389387
return processStatementBranchMCDC(coverApi, lines, extended)
390388

391389
def runCoverageResultsMP(packages, mpFile, verbose = False, extended=False, source_root = ""):
392-
393-
with VCProjectApi(mpFile) as vcproj:
394-
395-
anyLocalResults, anyImportedResults = checkProjectResults(vcproj)
396-
397-
if anyImportedResults:
398-
importedResultsError = " ** Cobertura results does not processing imported results at this time\n\n"
399-
print(importedResultsError)
400-
return [-1] * 19
401-
402-
if not anyLocalResults:
403-
localResultsError = " ** No local results in project to process\n\n"
404-
print(localResultsError)
405-
return [-1] * 19
406390

391+
with VCProjectApi(mpFile) as vcproj:
407392
api = vcproj.project.cover_api
408-
409393
results = runCoberturaResults(packages, api, verbose = False, extended = extended, source_root = source_root)
410394

411395
return results
@@ -466,7 +450,8 @@ def runCoberturaResults(packages, api, verbose = False, extended = False, source
466450
except:
467451
prj_dir = os.getcwd().replace("\\","/") + "/"
468452

469-
# get a sorted listed of all the files with the proj directory stripped off
453+
# get a sorted listed of all the files with the proj directory stripped off
454+
470455
for file in api.SourceFile.all():
471456
if file.display_name == "":
472457
continue
@@ -768,7 +753,7 @@ def generateCoverageResults(inFile, azure = False, xml_data_dir = "xml_data", ve
768753
if MCDC_rate != -1.0: print ("mcdc pairs: {:.2f}% ({:d} out of {:d})".format(MCDC_rate*100.0, cov_mcdc, total_mcdc))
769754

770755
if statement_rate != -1.0: print ("coverage: {:.2f}% of statements".format(statement_rate*100.0))
771-
if complexity != -1.0: print ("complexity: {:d}".format(complexity))
756+
print ("complexity: {:d}".format(complexity))
772757
source = etree.SubElement(sources, "source")
773758
source.text = "./"
774759

src/main/resources/scripts/generate_lcov.py

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,12 @@
4040
import subprocess
4141
import argparse
4242

43-
from vcast_utils import dump, checkVectorCASTVersion, getVectorCASTEncoding, checkProjectResults
43+
from vcast_utils import dump, checkVectorCASTVersion, getVectorCASTEncoding
4444
try:
4545
from safe_open import open
4646
except:
4747
pass
4848

49-
try:
50-
import math
51-
INF = math.inf
52-
except Exception:
53-
INF = float("inf") # Py2-compatible
5449
encFmt = getVectorCASTEncoding()
5550

5651
fileList = []
@@ -121,43 +116,28 @@ def has_branches_covered(line):
121116

122117
def get_function_name_line_number(file_path, function, initial_guess):
123118

124-
with open(file_path, "rb") as fd:
119+
with open(file_path,"rb") as fd:
125120
lines = [line.decode(encFmt, "replace") for line in fd.readlines()]
121+
122+
line_number_closest_so_far = initial_guess;
123+
delta = 9999999999;
126124

127-
if initial_guess is None or initial_guess >= len(lines):
128-
initial_guess = len(lines) - 1
129-
130-
line_number_closest_so_far = initial_guess
131-
delta = INF
132-
133-
for count, line in enumerate(reversed(lines[:initial_guess + 1])):
134-
if function in line.replace(" ", ""):
125+
# print(function, line_number_closest_so_far, delta, initial_guess)
126+
for count, line in enumerate(reversed(lines[:initial_guess+1])):
127+
if function in line.replace(" ",""):
135128
line_num = initial_guess - count
136129
if abs(line_num - initial_guess) < delta:
137130
line_number_closest_so_far = line_num
138131
delta = abs(line_num - initial_guess)
139-
140-
return line_number_closest_so_far + 1 # convert 0-based to 1-based
141-
132+
# print(function, line_number_closest_so_far, delta, initial_guess)
133+
134+
# print(line_number_closest_so_far + 1,function)
135+
return line_number_closest_so_far + 1 ## add one since python starts from 0
142136

143137
def runCoverageResultsMP(mpFile, verbose = False, testName = "", source_root = ""):
144138

145139
with VCProjectApi(mpFile) as vcproj:
146-
147-
anyLocalResults, anyImportedResults = checkProjectResults(vcproj)
148-
149-
if anyImportedResults:
150-
importedResultsError = " ** LCOV results does not processing imported results at this time\n\n"
151-
print(importedResultsError)
152-
return importedResultsError
153-
154-
if not anyLocalResults:
155-
localResultsError = " ** No local results in project to process\n\n"
156-
print(localResultsError)
157-
return localResultsError
158-
159140
api = vcproj.project.cover_api
160-
161141
results = runGcovResults(api, verbose = verbose, testName = vcproj.project.name, source_root=source_root)
162142

163143
return results
@@ -173,7 +153,7 @@ def runGcovResults(api, verbose = False, testName = "", source_root = "") :
173153
except:
174154
prj_dir = os.getcwd().replace("\\","/") + "/"
175155

176-
# get a sorted listed of all the files with the proj directory stripped off
156+
# get a sorted listed of all the files with the proj directory stripped off
177157
for file in api.SourceFile.all():
178158
if file.display_name == "":
179159
continue

0 commit comments

Comments
 (0)