coverage stats

5 views
Skip to first unread message

Grzegorz Parka

unread,
Jul 15, 2015, 2:11:34 PM7/15/15
to pgxn-...@googlegroups.com
As we know build results and test coverage statistics are generally useful features. I seriously miss a simple guide how to run coverage on a pure c extension (code in src/) with pg regression-style tests.
Could any more experienced PGXN user provide a simple example?

Jim Nasby

unread,
Jul 15, 2015, 2:41:43 PM7/15/15
to pgxn-...@googlegroups.com
By coverage do you mean unit/regression tests? If so you might find
https://github.com/decibel/variant useful (in particular the Makefile).
Note that it's using pgTap for testing instead of trying to grok raw
test output, but that's optional.
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Data in Trouble? Get it in Treble! http://BlueTreble.com

Grzegorz Parka

unread,
Jul 15, 2015, 3:43:07 PM7/15/15
to pgxn-...@googlegroups.com
What I meant was a report on how many functions/lines of code/branches were covered during the test phase. Just like Postgres itself has here http://pgci.eisentraut.org/jenkins/job/postgresql_master_coverage/Coverage/

One repo that has such statistics:
https://github.com/citusdata/pg_shard

To be honest, I am pretty confused. Is it even possible to get coverage statistics just by executing the regression tests (make installcheck) with some flags turned on?

David E. Wheeler

unread,
Jul 15, 2015, 3:55:49 PM7/15/15
to pgxn-...@googlegroups.com
On Jul 15, 2015, at 12:43 PM, Grzegorz Parka <grzegor...@gmail.com> wrote:

> To be honest, I am pretty confused. Is it even possible to get coverage statistics just by executing the regression tests (make installcheck) with some flags turned on?

I don’t think so. This isn’t specific to PGXN, mind you; it’s a feature I think would be useful in PGXS, which is the Postgres make infrastructure. I suggest inquiring on pgsql-hackers.

http://www.postgresql.org/list/pgsql-hackers/

Best,

David

Ronan Dunklau

unread,
Jul 16, 2015, 2:42:40 AM7/16/15
to pgxn-...@googlegroups.com, David E. Wheeler
I'm not familiar with the proper way to do that, here is how I did it, which
is the most simple thing that worked:

- build postgres with the --enable-coverage configure flag
- build your extension against that version of postgres, and specifically
pg_config.
- run the regression tests (make installcheck)
- I've added a simple Makefile target calling gcov to generate a report,
which is directly copy-pasted from the one in postgres, IIRC (its been a long
time):

coverage:
lcov -d . -c -o lcov.info
genhtml --show-details --legend --output-directory=coverage --
title=PostgreSQL --num-spaces=4 --prefix=./src/ `find . -name lcov.info -
print`





>
> Best,
>
> David

--
Ronan Dunklau

Grzegorz Parka

unread,
Jul 18, 2015, 2:47:24 PM7/18/15
to pgxn-...@googlegroups.com, David E. Wheeler
Thank you :)

The solution of Ronan helped me to view the coverage statistics locally. It just would be even nicer if this didn't require installing postgres from source but I guess it can't be avoided.

Best,
Greg


--
You received this message because you are subscribed to a topic in the Google Groups "PGXN Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pgxn-users/sEg7wh8EhoM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pgxn-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages