Skip to content
This repository was archived by the owner on Apr 13, 2021. It is now read-only.

Commit 7569f24

Browse files
committed
add diff-cover target, updated tools, readme
1 parent abbbc8c commit 7569f24

File tree

6 files changed

+65
-1
lines changed

6 files changed

+65
-1
lines changed

DEVELOPMENT.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
libswiftnav development
2+
=======================
3+
4+
Follow these instructions if you intend to make changes to libswiftnav.
5+
6+
Tools needed:
7+
* doxygen
8+
* pip install gcovr diff-cover
9+
10+
To get started, run::
11+
./checks/setup-hooks.sh [DIR]
12+
13+
from within the libswiftnav root directory. The default build-dir will be `build`.
14+
15+
This makes the directory if it doesn't already exist, runs cmake with `Coverage` mode enabled
16+
inside it, and installs a git pre-commit hook that runs style and code-coverage checkers
17+
in this build directory. These checks require doxygen, gcovr, and diff-cover
18+
19+
To manually run the coverage task, use `make coverage`. For syntax, use `make style`.

checks/checkoutput.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
echo "HEY: git diff $1 | $2 --no-tree - > check_output.txt"
1+
#echo "HEY: git diff $1 | $2 --no-tree - > check_output.txt"
22
git diff $1 | $2 --no-tree - > check_output.txt

checks/pre-commit

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
set -e
2+
echo "precommit running. checking build located at ${subdir}."
3+
cd ${subdir}
4+
../checks/run-coverage.sh
5+
6+
#echo "commit failed"
7+
exit 1

checks/run-coverage.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# requires gcovr and diff-cover
2+
# pip install gcovr diff-cover
3+
set -e
4+
gcovr -r .. --object-directory . --xml -o ../.coverage.xml
5+
gcovr -r .. --object-directory . --html -o coverage.html
6+
( cd .. && diff-cover .coverage.xml --fail-under=85 --html-report .diffreport.html )
7+
mv ../.diffreport.html ./diffreport.html

checks/setup-hooks.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# set up build directory
2+
builddir=${1:-build/} # by default use build/
3+
echo "Build directory: ${builddir}"
4+
mkdir -p $builddir
5+
( cd $builddir && cmake -DCMAKE_BUILD_TYPE=Coverage .. )
6+
7+
hooks="`git rev-parse --git-dir`/hooks"
8+
echo "Installing hook at: ${hooks}"
9+
# insert value of builddir as first line of pre-commit
10+
echo "subdir=$builddir" | cat - checks/pre-commit > "$hooks/pre-commit"

tests/CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,29 @@ else (CMAKE_CROSSCOMPILING)
5151
COMMENT "Running unit tests"
5252
COMMAND test_libswiftnav
5353
)
54+
55+
# for convenience:
56+
add_custom_target(tests
57+
DEPENDS test_libswiftnav
58+
COMMAND test_libswiftnav
59+
)
60+
add_custom_target(test
61+
DEPENDS test_libswiftnav
62+
COMMAND test_libswiftnav
63+
)
64+
5465
file(COPY data/waas_check.bin DESTINATION ${CMAKE_BINARY_DIR}/tests)
5566
file(COPY data/waas_data.bin DESTINATION ${CMAKE_BINARY_DIR}/tests)
5667

68+
# TODO run even if tests fail?
69+
# TODO check that we're in a coverage build
70+
add_custom_command(
71+
DEPENDS test
72+
OUTPUT diffreport.html
73+
COMMAND ../checks/run-coverage.sh
74+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
75+
)
76+
add_custom_target(coverage DEPENDS diffreport.html)
77+
5778
endif (NOT CHECK_FOUND)
5879
endif (CMAKE_CROSSCOMPILING)

0 commit comments

Comments
 (0)