Skip to content

Commit

Permalink
Introduce test coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
kristapsdz committed Sep 29, 2024
1 parent 8a204b1 commit 3587a0c
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Makefile.local
# files generated by configure
Makefile.configure
config.h
Expand All @@ -15,5 +16,10 @@ lowdown-diff
lowdown.pc
lowdown.tar.gz
lowdown.tar.gz.sha512
# files for valgrind
*.valgrind
*.diff-valgrind
# files for gcov
*.gcno
*.gcov
*.gcda
25 changes: 24 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
.SUFFIXES: .xml .md .html .pdf .1 .1.html .3 .3.html .5 .5.html .thumb.jpg .png .in.pc .pc .valgrind .old.md .diff-valgrind

include Makefile.configure
WWWDIR = /var/www/vhosts/kristaps.bsd.lv/htdocs/lowdown
sinclude Makefile.local

# Follows semver.
# This is complex because lowdown is both a program and a library; and
Expand Down Expand Up @@ -30,7 +32,6 @@ OBJS = autolink.o \
tree.o \
util.o
COMPAT_OBJS = compats.o
WWWDIR = /var/www/vhosts/kristaps.bsd.lv/htdocs/lowdown
HTMLS = archive.html \
atom.xml \
diff.html \
Expand Down Expand Up @@ -326,6 +327,14 @@ $(HTMLS): versions.xml lowdown
./lowdown $< ; \
echo "</article>" ; ) >$@

index.xml: index.md coverage.md coverage-table.md lowdown
( echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" ; \
echo "<article data-sblg-article=\"1\">" ; \
./lowdown index.md ; \
./lowdown coverage.md ; \
./lowdown coverage-table.md ; \
echo "</article>" ; ) >$@

.1.1.html .3.3.html .5.5.html:
mandoc -Thtml -Ostyle=https://bsd.lv/css/mandoc.css $< >$@

Expand Down Expand Up @@ -372,6 +381,20 @@ clean:
distclean: clean
rm -f Makefile.configure config.h config.log config.h.old config.log.old

coverage-table.md:
$(MAKE) clean
CC=gcc CFLAGS="--coverage" ./configure LDFLAGS="--coverage"
$(MAKE) regress
( echo "| Files | Coverage |" ; \
echo "|-------|----------|" ; \
for f in $(OBJS) ; do \
src=$$(basename $$f .o).c ; \
pct=$$(gcov -H $$src | grep 'Lines executed' | head -n1 | \
cut -d ":" -f 2 | cut -d "%" -f 1) ; \
echo "| $$src | $$pct% | " ; \
done ; \
) >coverage-table.md

regen_regress: bins
@tmp1=`mktemp` ; \
tmp2=`mktemp` ; \
Expand Down
19 changes: 19 additions & 0 deletions coverage-table.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
| Files | Coverage |
|-------|----------|
| autolink.c | 65.73% |
| buffer.c | 71.91% |
| diff.c | 79.40% |
| document.c | 74.01% |
| entity.c | 40.74% |
| gemini.c | 65.91% |
| html.c | 66.51% |
| html_escape.c | 87.65% |
| latex.c | 64.08% |
| library.c | 80.14% |
| libdiff.c | 94.05% |
| nroff.c | 71.38% |
| odt.c | 63.64% |
| smartypants.c | 83.89% |
| term.c | 67.54% |
| tree.c | 34.84% |
| util.c | 6.38% |
7 changes: 7 additions & 0 deletions coverage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Coverage

The regression suite executes the *lowdown* code in many ways. It's
easy to track this by examining run-time coverage using
[gcov](https://gcc.gnu.org/onlinedocs/gcc/Gcov.html) (or the clang
alternative). To examine how the regression suite covers the sources,
run `make coverage`. The current coverage is as follows:

0 comments on commit 3587a0c

Please sign in to comment.