summaryrefslogtreecommitdiffhomepage
path: root/run-show-coverage.sh
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-20 19:09:48 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-20 19:09:48 +0200
commit2dff88addc61164f3c189381644767dc8dd50061 (patch)
treec43535dc36d7af20cbcfca73211defb105ec3d27 /run-show-coverage.sh
parent0bdae5b7ae67f47f637dd953dcb867df7f1ef404 (diff)
a
Diffstat (limited to 'run-show-coverage.sh')
-rw-r--r--run-show-coverage.sh68
1 files changed, 40 insertions, 28 deletions
diff --git a/run-show-coverage.sh b/run-show-coverage.sh
index fe30785d..f767ea7a 100644
--- a/run-show-coverage.sh
+++ b/run-show-coverage.sh
@@ -9,7 +9,7 @@ esac
self="$(basename -- "$1")"
usage() {
- echo "usage: ${self} <run|run-only|show|generate>" >&2
+ echo "usage: ${self} <all|compile|run|generate|open>..." >&2
exit 64
}
@@ -17,32 +17,45 @@ if test -z "$1"; then
usage
fi
+compile=0
run=0
generate=0
-show=0
-
-case "$1" in
- run) run=1; generate=1; show=1 ;;
- run-only) run=1 ;;
- show) generate=1; show=1 ;;
- generate) generate=1 ;;
- *) echo "error: invalid command-line argument '$1'" >&2; usage ;;
-esac
+open=0
+
+while test $# -gt 0; do
+ case "$1" in
+ all) compile=1; run=1; generate=1; open=1 ;;
+ compile) compile=1 ;;
+ run) compile=1; run=1 ;;
+ generate) generate=1 ;;
+ open) open=1 ;;
+ *) echo "error: invalid command-line argument '$1'" >&2; usage ;;
+ esac
+ shift
+done
#find build directory
+build="build-coverage"
if test -f CMakeLists.txt && test -f resources.conf; then
- cd build
+ cd ./"${build}"
elif test -d bin; then
- cd ..
+ cd ../../"${build}"
elif test -x floormat || test -x floormat.exe; then
- cd ../..
+ cd ../../"${build}"
elif test -d install/bin && test -d install/share/floormat; then
- :
+ cd ../"${build}"
+elif test "./CMakeCache.txt"; then
+ cd ../"${build}"
else
echo "error: can't find build directory!" >&2
exit 65
fi
+if ! test -f "./CMakeCache.txt"; then
+ echo "error: no CMakeCache.txt in build directory!"
+ exit 65
+fi
+
exe=
for i in ./install/bin/floormat.exe ./install/bin/floormat; do
if test -x "$i"; then
@@ -51,22 +64,21 @@ for i in ./install/bin/floormat.exe ./install/bin/floormat; do
fi
done
-if ! test -n "$exe"; then
- echo "error: no 'floormat' executable" >&2
- exit 65
-fi
prof=coverage
-if test $run -gt 0; then
+if test $compile -gt 0; then
rm -f -- ./"${prof}".profraw ./"${prof}".profdata ../"${prof}".lcov
- (
- export FLOORMAT_WITH_COVERAGE=1
- cmake .
- cmake --build . --target install
- )
- LLVM_PROFILE_FILE="../${prof}.profraw" FLOORMAT_WITH_COVERAGE=1 \
- "$exe" --magnum-gpu-validation on
+ cmake -DFLOORMAT_WITH-COVERAGE:BOOL=1 .
+ cmake --build . --target install
+fi
+
+if test $run -gt 0; then
+ if ! test -n "$exe"; then
+ echo "error: no 'floormat' executable" >&2
+ exit 65
+ fi
+ LLVM_PROFILE_FILE="../${prof}.profraw" "$exe" --magnum-gpu-validation on --vsync on
fi
if test $generate -gt 0; then
@@ -78,12 +90,12 @@ if test $generate -gt 0; then
genhtml -o "./${prof}" -s "./${prof}.lcov"
fi
-if test $show -gt 0; then
+if test $open -gt 0; then
if command -v xdg-open >/dev/null; then
xdg-open "./${prof}/index.html"
else
start "./${prof}/index.html"
-
fi
fi
+
exit 0