coverage: do not delete .gcno files before building

The coverage-compile target depends on coverage-clean, which is
supposed to remove the earlier build products that would get in the
way of the next coverage test run.

However, removing *.gcno is actively wrong.  These are the files that
contain the compile-time coverage related data.  They are only rebuilt
if the source is compiled.  So if one ran 'make coverage' two times in
a row, the second run would remove *.gcno, but then fail to recreate
them because neither source files nor build flags have changed.  (This
remained hidden for so long most likely because any other intervening
use of 'make' will change the build flags, causing a full rebuild.)

So we make an exception for *.gcno.  The *.gcda are the coverage
results, written when the gcov-instrumented program is run.  We still
remove those, so as to get a one-test-run view of the data; you could
probably argue the other way too.

Signed-off-by: Thomas Rast <trast@inf.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Thomas Rast 2013-05-13 23:27:26 +02:00 коммит произвёл Junio C Hamano
Родитель 0c38a95ec8
Коммит dcbe7f1ab8
1 изменённых файлов: 6 добавлений и 3 удалений

Просмотреть файл

@ -2443,7 +2443,7 @@ profile-clean:
$(RM) $(addsuffix *.gcda,$(addprefix $(PROFILE_DIR)/, $(object_dirs))) $(RM) $(addsuffix *.gcda,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))
$(RM) $(addsuffix *.gcno,$(addprefix $(PROFILE_DIR)/, $(object_dirs))) $(RM) $(addsuffix *.gcno,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))
clean: profile-clean clean: profile-clean coverage-clean
$(RM) *.o block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o vcs-svn/*.o \ $(RM) *.o block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o vcs-svn/*.o \
builtin/*.o $(LIB_FILE) $(XDIFF_LIB) $(VCSSVN_LIB) builtin/*.o $(LIB_FILE) $(XDIFF_LIB) $(VCSSVN_LIB)
$(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) git$X $(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) git$X
@ -2525,20 +2525,23 @@ check-builtins::
### Test suite coverage testing ### Test suite coverage testing
# #
.PHONY: coverage coverage-clean coverage-compile coverage-test coverage-report .PHONY: coverage coverage-clean coverage-compile coverage-test coverage-report
.PHONY: coverage-clean-results
coverage: coverage:
$(MAKE) coverage-test $(MAKE) coverage-test
$(MAKE) coverage-report $(MAKE) coverage-report
object_dirs := $(sort $(dir $(OBJECTS))) object_dirs := $(sort $(dir $(OBJECTS)))
coverage-clean: coverage-clean-results:
$(RM) $(addsuffix *.gcov,$(object_dirs)) $(RM) $(addsuffix *.gcov,$(object_dirs))
$(RM) $(addsuffix *.gcda,$(object_dirs)) $(RM) $(addsuffix *.gcda,$(object_dirs))
$(RM) $(addsuffix *.gcno,$(object_dirs))
$(RM) coverage-untested-functions $(RM) coverage-untested-functions
$(RM) -r cover_db/ $(RM) -r cover_db/
$(RM) -r cover_db_html/ $(RM) -r cover_db_html/
coverage-clean: coverage-clean-results
$(RM) $(addsuffix *.gcno,$(object_dirs))
COVERAGE_CFLAGS = $(CFLAGS) -O0 -ftest-coverage -fprofile-arcs COVERAGE_CFLAGS = $(CFLAGS) -O0 -ftest-coverage -fprofile-arcs
COVERAGE_LDFLAGS = $(CFLAGS) -O0 -lgcov COVERAGE_LDFLAGS = $(CFLAGS) -O0 -lgcov
GCOVFLAGS = --preserve-paths --branch-probabilities --all-blocks GCOVFLAGS = --preserve-paths --branch-probabilities --all-blocks