Hi folks, By happenstance I noticed the gnulib developers talking about how they had a GNUMakefile target for generating code coverage reports for you.
In groff, we don't use GNUMakefiles--we try to use portable Make, and
have largely succeeded. If *BSD makes have gotten current with POSIX
2024, they may even be able to run these targets. The most exotic thing
I see is the `?=` macro definition operator.
So I experimentally smuggled over ("vendored") the relevant target and
macro definition from gnulib's maint.mk file, dropped them into groff's
Makefile.am in my working copy (diff attached), ran "make coverage", and
waited to see what would break.
Nothing did! It ran to successful completion on the first try!
lcov produces its report as a hierarchy of HTML documents. I've tarred
them up, gzipped them, and stuck them up on paste.c-net.org, a "paste
bin"-style site.
https://paste.c-net.org/CharleyCoverage
This is something I've been wanting to do for a long time, and my hat's
off to the gnulib folks for making it seamless and painless.
I'm not too surprised by the results. With a code base this old, it's
not a surprise that we have a lot of red. And for little-used parts of
the codebase, like refer(1) and the related libbib, coverage is poor.
On the other hand, in a lot of other places, our coverage is fairly
good, though my propensity to add error handling and then not write test
scripts to exercise it (because I'm philosophically opposed to
pattern-matching natural language in diagnostic messages) has doubtless
dragged down some of our percentages (even as I think it otherwise
improves code quality, by not permitting programs to get into an
undefined state--this report shows at least that in an "everything"
groff build and running all 308 test scripts, we seldom do get into
aforementioned undefined states).
I wanted to share the news, which is not so much good or bad, as much as
it shows the way for the next 300 or so test scripts that need
writing...
Anyone salty old software engineers or high-speed whippersnappers want
to venture any perspectives? Does anything stick out that I should
consider prioritizing?
Regards,
Branden
diff --git a/Makefile.am b/Makefile.am index ef3754845..db9362e43 100644 --- a/Makefile.am +++ b/Makefile.am @@ -877,6 +877,36 @@ $(top_srcdir)/.version: dist-hook: echo $(VERSION) > $(distdir)/.tarball-version +# maintainer-mode targets + +init-coverage: + $(MAKE) $(AM_MAKEFLAGS) clean + lcov --directory . --zerocounters + +COVERAGE_CCOPTS ?= "-g --coverage" +COVERAGE_OUT ?= doc/coverage + +build-coverage: + $(MAKE) $(AM_MAKEFLAGS) CFLAGS=$(COVERAGE_CCOPTS) \ + CXXFLAGS=$(COVERAGE_CCOPTS) + $(MAKE) $(AM_MAKEFLAGS) CFLAGS=$(COVERAGE_CCOPTS) \ + CXXFLAGS=$(COVERAGE_CCOPTS) check + $(MKDIR_P) $(COVERAGE_OUT) + lcov --directory . --output-file \ + $(COVERAGE_OUT)/$(PACKAGE).info --capture + +gen-coverage: + genhtml --output-directory $(COVERAGE_OUT) \ + $(COVERAGE_OUT)/$(PACKAGE).info \ + --frames --legend \ + --title "$(PACKAGE_NAME)" + +coverage: + $(MAKE) init-coverage + $(MAKE) build-coverage + $(MAKE) gen-coverage + + # Local Variables: # fill-column: 72 # mode: makefile-automake
signature.asc
Description: PGP signature
