Skip to content

Commit 193cc76

Browse files
authored
Python Coverage.py version differences. (#358)
GitHub regression fixes. #343, #348 Signed-off-by: Henry Cox <[email protected]>
1 parent ae8e517 commit 193cc76

File tree

8 files changed

+48
-36
lines changed

8 files changed

+48
-36
lines changed

.github/workflows/run_test_suite.yml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,18 @@ jobs:
8181
- name: make check
8282
run: |-
8383
set -x -o pipefail
84-
# NOTE: There are two things going on in this hackery:
85-
# - So far "make check" exits with code 0 despite failures —
86-
# see issue #348 — so we need a more manual approach to detect
87-
# failing tests
88-
# - We compare the number of failing tests to the known status
89-
# quo — see issue #343 — so that
90-
# - we have a chance for a green CI while also
91-
# - we will notice when more of the existing tests start
92-
# to fail.
93-
make check |& tee /dev/stderr \
94-
| grep -F ' failed, ' | tee /dev/stderr \
95-
| grep -F -q ', 1 failed, ' \
96-
|| { echo 'Number of tests expected to fail^^ does not match -- did you break an existing test?' >&2 ; false ; }
84+
make check
9785
9886
- name: Upload test log as an artifact
9987
uses: actions/upload-artifact@v4
10088
with:
10189
name: "lcov-${{ github.sha }}-${{ runner.os }}-test-log" # .zip
10290
path: tests/test.log
10391
if-no-files-found: error
92+
93+
- name: Upload test directory shrapnel as an artifact
94+
uses: actions/upload-artifact@v4
95+
with:
96+
name: "lcov-${{ github.sha }}-${{ runner.os }}-shrapnel" # .zip
97+
path: tests
98+
#if-no-files-found: error

bin/py2lcov

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ Example:
140140
help="specify the test name for the TN: entry in LCOV .info file")
141141
parser.add_argument('-e', '--exclude', dest='excludePatterns', default='',
142142
help="specify the exclude file patterns separated by ','")
143-
parser.add_argument('-v', '--verbose', dest='verbose', default=False, action='store_true',
143+
parser.add_argument('-v', '--verbose', dest='verbose', default=0, action='count',
144144
help="print debug messages")
145145
parser.add_argument('--version-script', dest='version',
146146
help="version extract callback")
@@ -195,7 +195,6 @@ Example:
195195
env["COVERAGE_FILE"] = f
196196
cmd = [args.cover_cmd, "xml", "-o", xml]
197197
try:
198-
#x = subprocess.run(cmd, capture_output=True, shell=False, check=True, env=env)
199198
x = subprocess.run(cmd, shell=False, check=True, stdout=True, stderr=True, env=env)
200199
except subprocess.CalledProcessError as err:
201200
print("Error: error during XML conversion of %s: %s" % (

bin/xml2lcov

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Example:
8080
help="specify the test name for the TN: entry in LCOV .info file")
8181
parser.add_argument('-e', '--exclude', dest='excludePatterns', default='',
8282
help="specify the exclude file patterns separated by ','")
83-
parser.add_argument('-v', '--verbose', dest='verbose', default=False, action='store_true',
83+
parser.add_argument('-v', '--verbose', dest='verbose', default=0, action='count',
8484
help="print debug messages")
8585
parser.add_argument('--version-script', dest='version',
8686
help="version extract callback")

bin/xml2lcovutil.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,14 @@ def process_xml_file(self, xml_file):
152152
for source in root[0]:
153153
# keep track of number of times we use each source_path to find
154154
# some file. Unused source paths are likely a problem.
155-
source_paths.append([source.text, 0])
156155
if self._args.verbose:
157-
print("source: " + source.text)
156+
print("source: '%s'" %(source.text))
157+
# unclear why the Coverage.py version on GitHub node
158+
# generates empty sources
159+
if source.text == None:
160+
print("skipping empty source (???)")
161+
continue
162+
source_paths.append([source.text, 0])
158163
else:
159164
print("Error: parse xml fail: no 'sources' in %s" %(xml_file))
160165
sys.exit(1)
@@ -174,17 +179,24 @@ def process_xml_file(self, xml_file):
174179
# name="." means current directory
175180
# name=".folder1.folder2" means external module or directory
176181
# name="abc" means internal module or directory
177-
isExternal = (package.attrib['name'].startswith('.') and package.attrib['name'] != '.')
182+
pname = package.attrib['name']
183+
if self._args.verbose:
184+
print("package: '%s'" % (pname))
185+
isExternal = (pname.startswith('.') and pname != '.')
178186
#pdb.set_trace()
179187
for classes in package:
180188
for fileNode in classes:
181-
if self._args.excludePatterns and any([fnmatch.fnmatchcase(fileNode.attrib['filename'], ef) for ef in self._excludePatterns]):
189+
name = fileNode.attrib['filename']
190+
if self._args.excludePatterns and any([fnmatch.fnmatchcase(name, ef) for ef in self._excludePatterns]):
182191
if self._args.verbose:
183-
print("%s is excluded" % fileNode.attrib['filename'])
192+
print("%s is excluded" % name)
184193
continue
185-
name = fileNode.attrib['filename']
194+
if self._args.verbose > 1:
195+
print(" file: %s" % (name))
186196
if not isExternal:
187197
for s in source_paths:
198+
if self._args.verbose > 1:
199+
print(" check src_path (%s %d)" % (s[0], s[1]))
188200
path = os.path.join(s[0], name)
189201
if os.path.exists(path):
190202
name = path

tests/bin/test_run

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,5 @@ fi
157157
[ ! -z "$ELAPSED" ] && t_detail "TIME" "${ELAPSED}ms" >>"$LOGFILE"
158158
[ ! -z "$RESIDENT" ] && t_detail "MEM" "${RESIDENT}kB" >>"$LOGFILE"
159159
t_detail "RESULT" "$RESULT" >> "$LOGFILE"
160+
161+
exit $RC

tests/gendiffcov/errs/msgtest.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,9 @@ if [ 0 != $? ] ; then
817817
exit 1
818818
fi
819819
fi
820+
if [ -d mycache ] ; then
821+
find mycache -type f -exec chmod ugo+r {} \;
822+
fi
820823
821824
echo "Tests passed"
822825

tests/lcov/errs/errs.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ if [ 0 != ${PIPESTATUS[0]} ] ; then
305305
exit $status
306306
fi
307307
fi
308+
chmod ugo+rx emptyDir
308309
309310
# data consistency errors:
310311
# - function marked 'hit' but no contained lines are hit

tests/py2lcov/py2lcov.sh

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
set +x
2+
set -x
33

44
CLEAN_ONLY=0
55
COVER=
@@ -154,7 +154,7 @@ if [ 0 != $? ] ; then
154154
fi
155155

156156
# some corner cases:
157-
COVERAGE_FILE=./functions.dat $CMD run --branch ./test.py
157+
COVERAGE_FILE=./functions.dat $CMD run --branch ./test.py -v -v
158158
if [ 0 != $? ] ; then
159159
echo "coverage functions failed"
160160
if [ 0 == $KEEP_GOING ] ; then
@@ -182,19 +182,19 @@ done
182182
# look for expected location and function hit counts:
183183
for d in \
184184
'FN functions.info' \
185-
'FNL:0,10,12' \
186-
'FNA:0,0,unusedFunc' \
187-
'FNL:1,2,7' \
188-
'FNA:1,1,enter' \
189-
'FNL:0,10,18' \
190-
'FNA:0,0,main.localfunc' \
191-
'FNL:1,12,16' \
192-
'FNA:1,0,main.localfunc.nested1' \
193-
'FNL:2,13,14' \
194-
'FNA:2,0,main.localfunc.nested1.nested2' \
195-
'FNL:3,5,18' \
185+
'FNL:[0-9],10,12' \
186+
'FNA:[0-9],0,unusedFunc' \
187+
'FNL:[0-9],2,7' \
188+
'FNA:[0-9],1,enter' \
189+
'FNL:[0-9],10,18' \
190+
'FNA:[0-9],0,main.localfunc' \
191+
'FNL:[0-9],12,16' \
192+
'FNA:[0-9],0,main.localfunc.nested1' \
193+
'FNL:[0-9],13,14' \
194+
'FNA:[0-9],0,main.localfunc.nested1.nested2' \
195+
'FNL:[0-9],5,18' \
196196
; do
197-
grep $d functions.info
197+
grep -E $d functions.info
198198
if [ 0 != $? ] ; then
199199
echo "did not find expected function data $d"
200200
if [ 0 == $KEEP_GOING ] ; then

0 commit comments

Comments
 (0)