Skip to content

Commit

Permalink
add code coverage report make option (#480)
Browse files Browse the repository at this point in the history
  • Loading branch information
nshaheed authored Nov 21, 2024
1 parent 3461265 commit 328742f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,10 @@ xcshareddata/
.vscode
.vs
chuck.vcxproj.user

# code coverage
*.gcov
*.gcda
*.gcno
*.info
/report/
7 changes: 7 additions & 0 deletions src/core/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ LD=g++

CFLAGS+=-I. -Ilo

ifneq ($(COVERAGE_REPORT),)
CFLAGS+=-fprofile-arcs
CFLAGS+=-ftest-coverage
LDFLAGS+=-lgcov
LDFLAGS+=--coverage
endif

ifneq ($(CHUCK_STAT),)
CFLAGS+= -D__CHUCK_STAT_TRACK__
endif
Expand Down
19 changes: 18 additions & 1 deletion src/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ LD=$(CXX)
# note: to compile with a specific c++ version (e.g., c++11) add: -std=c++11
CFLAGS+=-I. -I$(CK_CORE_DIR) -I$(CK_CORE_DIR)/lo

# Code coverage

# enable chuck debug macros?
ifneq ($(COVERAGE_REPORT),)
CFLAGS+=-fprofile-arcs
CFLAGS+=-ftest-coverage
LDFLAGS+=-lgcov
LDFLAGS+=--coverage
endif

# track stats?
ifneq ($(CHUCK_STAT),)
CFLAGS+= -D__CHUCK_STAT_TRACK__
Expand Down Expand Up @@ -279,6 +289,12 @@ $(CXXOBJS_HOST): %.o: %.cpp
test:
@make -C test

###################### GENERATE CODE COVERAGE REPORT ###########################
.PHONY: coverage
coverage: test
lcov --capture --directory . --output-file coverage.info
genhtml coverage.info --output-directory report


####################### GENERATE API DOCUMENTATION ############################
.PHONY: doc ckdoc
Expand Down Expand Up @@ -333,7 +349,8 @@ clean-src:
$(CK_CORE_DIR)/chuck.tab.h $(CK_CORE_DIR)/chuck.tab.c $(CK_CORE_DIR)/chuck.yy.c \
$(DIST_ROOT)/$(DIST_DIR) $(DIST_ROOT)/$(DIST_DIR){,.tgz,.zip} \
host-web/webchuck/js/webchuck.js host-web/webchuck/js/webchuck.wasm \
Release Debug
Release Debug \
@rf -rf report/ */*.gcov */*.gcda */*.gcno */*.info

.PHONY: clean
clean: clean-src
Expand Down

0 comments on commit 328742f

Please sign in to comment.