summaryrefslogtreecommitdiff
path: root/bashrc
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-05-02 15:46:38 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2021-05-02 15:46:38 +0100
commit4224aa0e760ed2abcce3799b05f2290aa66889cc (patch)
treeede0177b902c8d9d54d7b5edd81bf95c880d7271 /bashrc
parentConsider distcc when calculating number of tasks (diff)
downloadutil-4224aa0e760ed2abcce3799b05f2290aa66889cc.tar.bz2
util-4224aa0e760ed2abcce3799b05f2290aa66889cc.tar.xz
util-4224aa0e760ed2abcce3799b05f2290aa66889cc.zip
Latest cov function
Diffstat (limited to 'bashrc')
-rw-r--r--bashrc45
1 files changed, 29 insertions, 16 deletions
diff --git a/bashrc b/bashrc
index 64efbbc..6146ca8 100644
--- a/bashrc
+++ b/bashrc
@@ -28,27 +28,40 @@ showimage() {
}
cov() {
- src=${1}
- src=$(realpath ${src:=$(pwd)})
- cov=/tmp/cov.$$
- all=$cov/all
- key=$cov/key
- html=$src/bin/cov/html
- test -d $src || ( echo "$src not a directory" && return 1 )
- echo "Cleaning $src"
- find $src -name "*.gcda" -type f -delete
- find $src -name "*.run" -type f -delete
- echo "Building in ${src}"
- build $src -d0 variant=coverage
+ local cov=/tmp/cov.$$
+ local all=$cov/all
+ local key=$cov/key
+ local html=$cov/html
+ local htmlfin=bin/cov
+ local gcov=$(which $(build $@ -qand1 variant=coverage | grep -w compile | \
+ sed -n "s/.*\/gcc-\([0-9]\+\.[0-9]\+\.[0-9]\+\)\/.*/gcov-\1/p" | head -n1))
+ if [[ ! -x $gcov ]] ; then
+ echo "Couldn't find a suitable gcov"
+ return 1
+ fi
+ echo "Using $gcov"
+
+ echo "Removing previous GC notes and runs"
+ lcov -z -d .
+ find -path */coverage/*.run -delete
+
+ echo "Building $@"
+ build $@ -q variant=coverage || return 2
+
echo "Extracting coverage data"
mkdir -p $cov
- lcov -d $src -c -o $all --derive-func-data --no-external -b $src -q
- lcov --remove $all "*/bin/*" -o $key -q
+ lcov -d . -c -o $all --derive-func-data --no-external --rc geninfo_auto_base=1 -q --gcov-tool $gcov || return 3
+ lcov --remove $all "*/bin/*" -o $key -q || return 4
+
echo "Generating HTML"
mkdir -p $html
- genhtml $key -o $html -s -k -t $src --demangle-cpp --sort --function-coverage -q --num-spaces=2
+ genhtml $key -o $html -s -k -t . --demangle-cpp --sort --function-coverage -q --num-spaces=2 || return 5
+ rsync -a --delete-after $html/ $htmlfin/
rm -rf $cov
- [ "${2}" != "0" ] && xdg-open file://$src/bin/cov/html/index.html
+
+ xdotool search --name LCOV windowactivate --sync key F5 windowactivate $(xdotool getactivewindow) || \
+ xdg-open "file://$(realpath $htmlfin)/index.html"
+ echo "Done"
}
sizes() {