@@ -141,21 +141,27 @@ if [[ 1 == $CLEAN_ONLY ]] ; then
141141 exit 0
142142fi
143143
144- which coverage
144+ CMD=' coverage'
145+ which $CMD
145146if [ 0 != $? ] ; then
147+ CMD=' python3-coverage' # ubuntu?
148+ fi
149+ which $CMD
150+ if [ 0 != $? ] ; then
151+ echo " cannot find 'coverage' or 'python3-coverage'"
146152 echo " unable to run py2lcov - please install python Coverage.py package"
147153 exit 1
148154fi
149155
150156# some corner cases:
151- COVERAGE_FILE=./functions.dat coverage run --branch ./test.py
157+ COVERAGE_FILE=./functions.dat $CMD run --branch ./test.py
152158if [ 0 != $? ] ; then
153159 echo " coverage functions failed"
154160 if [ 0 == $KEEP_GOING ] ; then
155161 exit 1
156162 fi
157163fi
158- eval ${PYCOV} ${PY2LCOV_TOOL} -o functions.info functions.dat $VERSION
164+ eval ${PYCOV} ${PY2LCOV_TOOL} -o functions.info --cmd $CMD functions.dat $VERSION
159165if [ 0 != $? ] ; then
160166 echo " py2lcov failed function example"
161167 if [ 0 == $KEEP_GOING ] ; then
208214
209215
210216# legacy mode: run with intermediate XML file
211- COVERAGE_FILE=./functions.dat coverage xml -o functions.xml
217+ COVERAGE_FILE=./functions.dat $CMD xml -o functions.xml
212218if [ 0 != $? ] ; then
213219 echo " coverage xml failed"
214220 exit 1
@@ -232,7 +238,7 @@ if [ 0 != $? ] ; then
232238fi
233239
234240# run again, generating checksum data...
235- eval ${PYCOV} ${PY2LCOV_TOOL} -o checksum.info functions.dat $VERSION --checksum
241+ eval ${PYCOV} ${PY2LCOV_TOOL} --cmd $CMD - o checksum.info functions.dat $VERSION --checksum
236242if [ 0 != $? ] ; then
237243 echo " py2lcov failed function example"
238244 if [ 0 == $KEEP_GOING ] ; then
262268
263269
264270# run without generating function data:
265- eval ${PYCOV} ${PY2LCOV_TOOL} functions.dat -o no_functions.info $VERSION --no-function
271+ eval ${PYCOV} ${PY2LCOV_TOOL} functions.dat --cmd $CMD - o no_functions.info $VERSION --no-function
266272if [ 0 != $? ] ; then
267273 echo " coverage no_functions failed"
268274 if [ 0 == $KEEP_GOING ] ; then
@@ -279,7 +285,7 @@ if [ 0 != $COUNT ] ; then
279285fi
280286
281287# run without extracting version
282- eval ${PYCOV} ${PY2LCOV_TOOL} functions.dat -o no_version.info
288+ eval ${PYCOV} ${PY2LCOV_TOOL} functions.dat --cmd $CMD - o no_version.info
283289if [ 0 != $? ] ; then
284290 echo " coverage no_functions failed"
285291 if [ 0 == $KEEP_GOING ] ; then
@@ -296,7 +302,7 @@ if [ 0 != $COUNT ] ; then
296302fi
297303
298304# test exclusion
299- eval ${PYCOV} ${PY2LCOV_TOOL} -o excl.info --exclude test.py functions.dat
305+ eval ${PYCOV} ${PY2LCOV_TOOL} -o excl.info --cmd $CMD -- exclude test.py functions.dat
300306if [ 0 != $? ] ; then
301307 echo " coverage no_functions failed"
302308 if [ 0 == $KEEP_GOING ] ; then
@@ -330,7 +336,7 @@ if [ 0 != $? ] ; then
330336fi
331337
332338# some usage errors
333- eval ${PYCOV} ${PY2LCOV_TOOL} functions.dat -o paramErr.info ${VERSION} ,-x
339+ eval ${PYCOV} ${PY2LCOV_TOOL} functions.dat -o paramErr.info --cmd $CMD ${VERSION} ,-x
334340if [ 0 == $? ] ; then
335341 echo " coverage version did not see error"
336342 if [ 0 == $KEEP_GOING ] ; then
@@ -339,7 +345,7 @@ if [ 0 == $? ] ; then
339345fi
340346
341347# run again with --keep-going flag - should generate same result as we see without version script
342- eval ${PYCOV} ${PY2LCOV_TOOL} functions.dat -o keepGoing.info ${VERSION} ,-x --keep-going --verbose
348+ eval ${PYCOV} ${PY2LCOV_TOOL} functions.dat -o keepGoing.info --cmd $CMD ${VERSION} ,-x --keep-going --verbose
343349if [ 0 != $? ] ; then
344350 echo " keepGoing version saw error"
345351 if [ 0 == $KEEP_GOING ] ; then
359365# can't run this unless we have a new enough 'coverage' version
360366# to support the --data-file input
361367if [[ " ${PYCOV} " =~ " COVERAGE_FILE=" || " ${PY2LCOV_TOOL} " =~ " COVERAGE_FILE=" ]] ; then
362- ${LCOV_HOME} /bin/py2lcov -o missing.info
368+ ${LCOV_HOME} /bin/py2lcov -o missing.info --cmd $CMD
363369else
364- eval ${PYCOV} ${PY2LCOV_TOOL} -o missing.info
370+ eval ${PYCOV} ${PY2LCOV_TOOL} -o missing.info --cmd $CMD
365371fi
366372if [ 0 == $? ] ; then
367373 echo " did not see error with missing input data"
@@ -371,7 +377,7 @@ if [ 0 == $? ] ; then
371377fi
372378
373379# usage error:
374- eval ${PYCOV} ${PY2LCOV_TOOL} -o noFile.info run.dat y.xml
380+ eval ${PYCOV} ${PY2LCOV_TOOL} -o noFile.info run.dat y.xml --cmd $CMD
375381if [ 0 == $? ] ; then
376382 echo " did not see error with missing input file"
377383 if [ 0 == $KEEP_GOING ] ; then
@@ -380,7 +386,7 @@ if [ 0 == $? ] ; then
380386fi
381387
382388# usage error:
383- eval ${PYCOV} ${PY2LCOV_TOOL} -o badArg.info --noSuchParam run_help.dat
389+ eval ${PYCOV} ${PY2LCOV_TOOL} -o badArg.info --noSuchParam run_help.dat --cmd $CMD
384390if [ 0 == $? ] ; then
385391 echo " did not see error with unsupported param"
386392 if [ 0 == $KEEP_GOING ] ; then
392398# to support the --data-file input
393399if [[ " ${PYCOV} " =~ " COVERAGE_FILE=" || " ${PY2LCOV_TOOL} " =~ " COVERAGE_FILE=" ]] ; then
394400 # can't generate coverage report for this feature...
395- COVERAGE_FILE=functions.dat ${LCOV_HOME} /bin/py2lcov -o fromEnv.info
401+ COVERAGE_FILE=functions.dat ${LCOV_HOME} /bin/py2lcov -o fromEnv.info --cmd $CMD
396402else
397403 # get input from environment var:
398- eval COVERAGE_FILE=functions.dat ${PYCOV} ${PY2LCOV_TOOL} -o fromEnv.info
404+ eval COVERAGE_FILE=functions.dat ${PYCOV} ${PY2LCOV_TOOL} -o fromEnv.info --cmd $CMD
399405fi
400406
401407if [ 0 != $? ] ; then
@@ -480,6 +486,6 @@ echo "Tests passed"
480486if [[ " x$COVER " != " x" && $LOCAL_COVERAGE == 1 ]] ; then
481487 cover
482488 ${LCOV_HOME} /bin/perl2lcov -o perlcov.info --testname py2lcov $VERSION ./cover_db
483- ${PY2LCOV_TOOL} -o pycov.info --testname py2lcov $VERSION ${PYCOV_DB}
489+ ${PY2LCOV_TOOL} -o pycov.info --testname py2lcov --cmd $CMD $VERSION ${PYCOV_DB}
484490 ${GENHTML_TOOL} -o pycov pycov.info perlcov.info --flat --show-navigation --show-proportion --branch $VERSION $ANNOTATE --ignore inconsistent,version
485491fi
0 commit comments