mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Build a code coverage report with gcov and lcov (#1221)
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -3,9 +3,13 @@
|
||||
/rgbfix
|
||||
/rgbgfx
|
||||
/rgbshim.sh
|
||||
/coverage/
|
||||
*.o
|
||||
*.exe
|
||||
*.dll
|
||||
*.gcno
|
||||
*.gcda
|
||||
*.gcov
|
||||
.checkpatch-camelcase.*
|
||||
CMakeCache.txt
|
||||
CMakeFiles/
|
||||
|
||||
10
Makefile
10
Makefile
@@ -3,7 +3,8 @@
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .cpp .y .o
|
||||
|
||||
.PHONY: all clean install checkcodebase checkpatch checkdiff develop debug mingw32 mingw64 wine-shim dist
|
||||
.PHONY: all clean install checkcodebase checkpatch checkdiff \
|
||||
develop debug coverage mingw32 mingw64 wine-shim dist
|
||||
|
||||
# User-defined variables
|
||||
|
||||
@@ -182,6 +183,7 @@ clean:
|
||||
$Q${RM} rgbfix rgbfix.exe
|
||||
$Q${RM} rgbgfx rgbgfx.exe
|
||||
$Qfind src/ -name "*.o" -exec rm {} \;
|
||||
$Qfind . -type f \( -name "*.gcno" -o -name "*.gcda" -o -name "*.gcov" \) -exec rm {} \;
|
||||
$Q${RM} rgbshim.sh
|
||||
$Q${RM} src/asm/parser.cpp src/asm/parser.hpp
|
||||
$Q${RM} test/gfx/randtilegen test/gfx/rgbgfx_test
|
||||
@@ -253,6 +255,12 @@ debug:
|
||||
$Qenv ${MAKE} \
|
||||
CXXFLAGS="-ggdb3 -Og -fno-omit-frame-pointer -fno-optimize-sibling-calls"
|
||||
|
||||
# This target is used during development in order to inspect code coverage with gcov.
|
||||
|
||||
coverage:
|
||||
$Qenv ${MAKE} \
|
||||
CXXFLAGS="-ggdb3 -Og --coverage -fno-omit-frame-pointer -fno-optimize-sibling-calls"
|
||||
|
||||
# Targets for the project maintainer to easily create Windows exes.
|
||||
# This is not for Windows users!
|
||||
# If you're building on Windows with Cygwin or Mingw, just follow the Unix
|
||||
|
||||
27
contrib/coverage.bash
Executable file
27
contrib/coverage.bash
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# Build RGBDS with gcov support
|
||||
make coverage -j
|
||||
|
||||
# Run the tests
|
||||
for dir in asm link fix gfx; do
|
||||
pushd test/$dir
|
||||
./test.sh
|
||||
popd
|
||||
done
|
||||
|
||||
# Generate coverage logs
|
||||
gcov src/**/*.{c,cpp}
|
||||
mkdir -p coverage
|
||||
|
||||
# Generate coverage report
|
||||
lcov -c --no-external -d . -o coverage/coverage.info
|
||||
genhtml -f -s -o coverage/ coverage/coverage.info
|
||||
|
||||
# Open report in web browser
|
||||
if [ "$(uname)" == "Darwin" ]; then
|
||||
open coverage/index.html
|
||||
else
|
||||
xdg-open coverage/index.html
|
||||
fi
|
||||
Reference in New Issue
Block a user