Skip to content

Commit dcbe7f1

Browse files
Thomas Rastgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0c38a95 commit dcbe7f1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2443,7 +2443,7 @@ profile-clean:
24432443
$(RM) $(addsuffix *.gcda,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))
24442444
$(RM) $(addsuffix *.gcno,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))
24452445

2446-
clean: profile-clean
2446+
clean: profile-clean coverage-clean
24472447
$(RM) *.o block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o xdiff/*.o vcs-svn/*.o \
24482448
builtin/*.o $(LIB_FILE) $(XDIFF_LIB) $(VCSSVN_LIB)
24492449
$(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) git$X
@@ -2525,20 +2525,23 @@ check-builtins::
25252525
### Test suite coverage testing
25262526
#
25272527
.PHONY: coverage coverage-clean coverage-compile coverage-test coverage-report
2528+
.PHONY: coverage-clean-results
25282529

25292530
coverage:
25302531
$(MAKE) coverage-test
25312532
$(MAKE) coverage-report
25322533

25332534
object_dirs := $(sort $(dir $(OBJECTS)))
2534-
coverage-clean:
2535+
coverage-clean-results:
25352536
$(RM) $(addsuffix *.gcov,$(object_dirs))
25362537
$(RM) $(addsuffix *.gcda,$(object_dirs))
2537-
$(RM) $(addsuffix *.gcno,$(object_dirs))
25382538
$(RM) coverage-untested-functions
25392539
$(RM) -r cover_db/
25402540
$(RM) -r cover_db_html/
25412541

2542+
coverage-clean: coverage-clean-results
2543+
$(RM) $(addsuffix *.gcno,$(object_dirs))
2544+
25422545
COVERAGE_CFLAGS = $(CFLAGS) -O0 -ftest-coverage -fprofile-arcs
25432546
COVERAGE_LDFLAGS = $(CFLAGS) -O0 -lgcov
25442547
GCOVFLAGS = --preserve-paths --branch-probabilities --all-blocks

0 commit comments

Comments
 (0)