Skip to content

Commit 21685cc

Browse files
committed
Simplify extracted function name for Python code: ignore params.
Signed-off-by: Henry Cox <[email protected]>
1 parent ecfe22c commit 21685cc

File tree

3 files changed

+28
-22
lines changed

3 files changed

+28
-22
lines changed

bin/py2lcov

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,9 @@ class ProcessFile:
204204
'end' : currentObj['end'],
205205
'hit' : hit})
206206

207-
208-
parseLine = re.compile('(\s*)((def|class)\s*([^:]+)(:|$))?');
207+
# just collect the function/class name - ignore the params
208+
parseLine = re.compile('(\s*)((def|class)\s*([^\( \t]+))?')
209+
#parseLine = re.compile('(\s*)((def|class)\s*([^:]+)(:|$))?')
209210
for node in fileNode:
210211
if node.tag != 'lines':
211212
continue
@@ -284,7 +285,7 @@ class ProcessFile:
284285
}
285286
else:
286287
# just a line - may be the first executable
287-
# lline in some function:
288+
# line in some function:
288289
if currentObj and not 'hit' in currentObj:
289290
currentObj['hit'] = hit
290291
# mark that function decl line is not

tests/gendiffcov/simple/script.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ COVER=
77
PARALLEL='--parallel 0'
88
PROFILE="--profile"
99
CXX='g++'
10-
COVER_DB='cover_db'
1110
LOCAL_COVERAGE=1
1211
KEEP_GOING=0
1312

@@ -34,8 +33,12 @@ while [ $# -gt 0 ] ; do
3433
COVER_DB=$1
3534
LOCAL_COVERAGE=0
3635
shift
36+
else
37+
COVER_DB='cover_db.dat'
3738
fi
38-
COVER="perl -MDevel::Cover=-db,${COVER_DB},-coverage,statement,branch,condition,subroutine "
39+
export PYCOV_DB="${COVER_DB}_py"
40+
COVER="perl -MDevel::Cover=-db,${COVER_DB},-coverage,statement,branch,condition,subroutine,-silent,1 "
41+
PYCOVER="COVERAGE_FILE=$PYCOV_DB coverage run --branch --append"
3942
;;
4043

4144
--home | -home )
@@ -125,8 +128,8 @@ DIFFCOV_OPTS="--function-coverage --branch-coverage --highlight --demangle-cpp -
125128
#DIFFCOV_OPTS="--function-coverage --branch-coverage --highlight --demangle-cpp --frame"
126129
#DIFFCOV_OPTS='--function-coverage --branch-coverage --highlight --demangle-cpp'
127130

128-
rm -f test.cpp *.gcno *.gcda a.out *.info *.info.gz diff.txt diff_r.txt diff_broken.txt *.log *.err *.json dumper* results.xlsx annotate.{cpp,exe} c d
129-
rm -rf ./cover_db ./baseline ./current ./differential* ./reverse ./diff_no_baseline ./no_baseline ./no_annotation ./no_owners differential_nobranch reverse_nobranch baseline-filter* noncode_differential* broken mismatchPath elidePath ./cover_db ./criteria ./mismatched ./navigation differential_prop proportion ./annotate ./current-* ./current_prefix* select select2
131+
rm -f test.cpp *.gcno *.gcda a.out *.info *.info.gz diff.txt diff_r.txt diff_broken.txt *.log *.err *.json dumper* results.xlsx annotate.{cpp,exe} c d ./cover_db_py
132+
rm -rf ./cover_db ./baseline ./current ./differential* ./reverse ./diff_no_baseline ./no_baseline ./no_annotation ./no_owners differential_nobranch reverse_nobranch baseline-filter* noncode_differential* broken mismatchPath elidePath ./cover_db ./criteria ./mismatched ./navigation differential_prop proportion ./annotate ./current-* ./current_prefix* select select2 html_report
130133

131134
if [ "x$COVER" != 'x' ] && [ 0 != $LOCAL_COVERAGE ] ; then
132135
cover -delete
@@ -1231,7 +1234,7 @@ if [ ! -f $SPREADSHEET ] ; then
12311234
SPREADSHEET=$LCOV_HOME/share/lcov/support-scripts/spreadsheet.py
12321235
fi
12331236
if [ -f $SPREADSHEET ] ; then
1234-
$PYCOVER $SPREADSHEET -o results.xlsx `find . -name "*.json"`
1237+
eval $PYCOVER $SPREADSHEET -o results.xlsx `find . -name "*.json"`
12351238
if [ 0 != $? ] ; then
12361239
status=1
12371240
echo "ERROR: spreadsheet generation failed"
@@ -1252,7 +1255,9 @@ fi
12521255
if [ "x$COVER" != "x" ] && [ 0 != $LOCAL_COVERAGE ] ; then
12531256
cover
12541257
${LCOV_HOME}/bin/perl2lcov -o perlcov.info --testname simple --version-script $GET_VERSION ./cover_db
1255-
${LCOV_HOME}/bin/genhtml -o perlcov perlcov.info --flat --show-navigation --show_proportion --version-script $GET_VERSION --annotate-script $P4ANNOTATE
1258+
${LCOV_HOME}/bin/py2lcov -o pycov.info --testname simple --version-script $GET_VERSION $PYCOV_DB
1259+
${LCOV_HOME}/bin/genhtml -o html_report perlcov.info pycov.info --branch --flat --show-navigation --show-proportion --version-script $GET_VERSION --annotate-script $P4ANNOTATE --parallel --ignore empty,usage
1260+
echo "see HTML report 'html_report'"
12561261
fi
12571262
12581263
exit $status

tests/py2lcov/py2lcov.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ while [ $# -gt 0 ] ; do
2828
set -x
2929
;;
3030

31-
--keep-going )
31+
-k | --keep-going )
3232
KEEP_GOING=1
3333
;;
3434

@@ -174,18 +174,18 @@ for line in 10 12 13 ; do
174174
done
175175
# look for expected location and function hit counts:
176176
for d in \
177-
'FN:2,4,enter(s,...)' \
178-
'FNDA:1,enter(s,...)' \
179-
'FN:6,8,unusedFunc()' \
180-
'FNDA:0,unusedFunc()' \
181-
'FN:13,14,main().localfunc().nested1().nested2()' \
182-
'FNDA:0,main().localfunc().nested1().nested2()' \
183-
'FN:12,16,main().localfunc().nested1()' \
184-
'FNDA:0,main().localfunc().nested1()' \
185-
'FN:10,18,main().localfunc()' \
186-
'FNDA:0,main().localfunc()' \
187-
'FN:5,18,main()' \
188-
'FNDA:1,main()' ; do
177+
'FN:2,4,enter' \
178+
'FNDA:1,enter' \
179+
'FN:6,8,unusedFunc' \
180+
'FNDA:0,unusedFunc' \
181+
'FN:13,14,main.localfunc.nested1.nested2' \
182+
'FNDA:0,main.localfunc.nested1.nested2' \
183+
'FN:12,16,main.localfunc.nested1' \
184+
'FNDA:0,main.localfunc.nested1' \
185+
'FN:10,18,main.localfunc' \
186+
'FNDA:0,main.localfunc' \
187+
'FN:5,18,main' \
188+
'FNDA:1,main' ; do
189189

190190
grep $d functions.info
191191
if [ 0 != $? ] ; then

0 commit comments

Comments
 (0)