From 0c38a95ec83f7adb5fc1b7a5133a2ac2668cdd4a Mon Sep 17 00:00:00 2001 From: Thomas Rast Date: Mon, 13 May 2013 23:27:25 +0200 Subject: coverage: split build target into compile and test Confusingly, the coverage-build target in fact builds with gcov support _and runs tests_. Split it into two targets that actually are named after what they do. Signed-off-by: Thomas Rast Signed-off-by: Junio C Hamano --- Makefile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 0f931a2030..f98296be2f 100644 --- a/Makefile +++ b/Makefile @@ -2524,10 +2524,10 @@ check-builtins:: ### Test suite coverage testing # -.PHONY: coverage coverage-clean coverage-build coverage-report +.PHONY: coverage coverage-clean coverage-compile coverage-test coverage-report coverage: - $(MAKE) coverage-build + $(MAKE) coverage-test $(MAKE) coverage-report object_dirs := $(sort $(dir $(OBJECTS))) @@ -2543,8 +2543,10 @@ COVERAGE_CFLAGS = $(CFLAGS) -O0 -ftest-coverage -fprofile-arcs COVERAGE_LDFLAGS = $(CFLAGS) -O0 -lgcov GCOVFLAGS = --preserve-paths --branch-probabilities --all-blocks -coverage-build: coverage-clean +coverage-compile: $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" all + +coverage-test: coverage-clean-results coverage-compile $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" \ -j1 test -- cgit v1.2.3 From dcbe7f1ab8b96b3875ae820d71c1364ee3bd99f5 Mon Sep 17 00:00:00 2001 From: Thomas Rast Date: Mon, 13 May 2013 23:27:26 +0200 Subject: 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 Signed-off-by: Junio C Hamano --- Makefile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index f98296be2f..99e4d0976e 100644 --- a/Makefile +++ b/Makefile @@ -2443,7 +2443,7 @@ profile-clean: $(RM) $(addsuffix *.gcda,$(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 \ builtin/*.o $(LIB_FILE) $(XDIFF_LIB) $(VCSSVN_LIB) $(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) git$X @@ -2525,20 +2525,23 @@ check-builtins:: ### Test suite coverage testing # .PHONY: coverage coverage-clean coverage-compile coverage-test coverage-report +.PHONY: coverage-clean-results coverage: $(MAKE) coverage-test $(MAKE) coverage-report object_dirs := $(sort $(dir $(OBJECTS))) -coverage-clean: +coverage-clean-results: $(RM) $(addsuffix *.gcov,$(object_dirs)) $(RM) $(addsuffix *.gcda,$(object_dirs)) - $(RM) $(addsuffix *.gcno,$(object_dirs)) $(RM) coverage-untested-functions $(RM) -r cover_db/ $(RM) -r cover_db_html/ +coverage-clean: coverage-clean-results + $(RM) $(addsuffix *.gcno,$(object_dirs)) + COVERAGE_CFLAGS = $(CFLAGS) -O0 -ftest-coverage -fprofile-arcs COVERAGE_LDFLAGS = $(CFLAGS) -O0 -lgcov GCOVFLAGS = --preserve-paths --branch-probabilities --all-blocks -- cgit v1.2.3 From c14cc77c1126c04b35ce0ea16989af50af6cebc1 Mon Sep 17 00:00:00 2001 From: Thomas Rast Date: Mon, 13 May 2013 23:27:27 +0200 Subject: coverage: set DEFAULT_TEST_TARGET to avoid using prove If the user sets DEFAULT_TEST_TARGET=prove in his config.mak, that carries over into the coverage tests. Which is really bad if he also sets GIT_PROVE_OPTS=-j<..> as that completely breaks the coverage runs. Instead of attempting to mess with the GIT_PROVE_OPTS, just force the test target to 'test' so that we run under make, like we intended all along. Signed-off-by: Thomas Rast Signed-off-by: Junio C Hamano --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 99e4d0976e..153d24dc39 100644 --- a/Makefile +++ b/Makefile @@ -2551,7 +2551,7 @@ coverage-compile: coverage-test: coverage-clean-results coverage-compile $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" \ - -j1 test + DEFAULT_TEST_TARGET=test -j1 test coverage-report: $(QUIET_GCOV)for dir in $(object_dirs); do \ -- cgit v1.2.3 From 5ce4367d644060821a264e00f7e2e98e35dd2d59 Mon Sep 17 00:00:00 2001 From: Thomas Rast Date: Mon, 13 May 2013 23:27:28 +0200 Subject: coverage: build coverage-untested-functions by default Change the 'coverage' target to build coverage-untested-functions by default, so as to make it more discoverable. Signed-off-by: Thomas Rast Signed-off-by: Junio C Hamano --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 153d24dc39..6f9d1c7c0f 100644 --- a/Makefile +++ b/Makefile @@ -2529,7 +2529,7 @@ check-builtins:: coverage: $(MAKE) coverage-test - $(MAKE) coverage-report + $(MAKE) coverage-untested-functions object_dirs := $(sort $(dir $(OBJECTS))) coverage-clean-results: -- cgit v1.2.3