On Sun, Nov 23, 2014 at 03:06:16PM +0100, Thien-Thi Nguyen wrote: | Is there any way to specify an unconditionally executed | clean-up action for "make check"? | | In Guile-PG, "make check" arranges to kick a daemon prior to | running the tests in the test wrapper script, and to kill it | afterwards via a ‘check-local’ Makefile.am target. This works | fine when all the tests pass, but leaves the daemon up should | any of the tests fail. | | For now, i've documented this in the README: | | http://git.savannah.gnu.org/cgit/guile-pg.git/tree/README?h=p#n109 | | but we all know how such hints are easily overlooked, and i'd | prefer a more robust solution that can DTRT noninteractively.
I work around this by having specific test groups to start the daemons with AT_KEYWORDS([start]), and separate test groups I run at the end with AT_KEYWORDS([stop]). The tests for stopping the daemons don't fail if the daemon isn't running; the exit 77 if the daemon isn't running to skip that stop group. Even if test groups fail, the specific "stop" groups get executed. If I've interrupted the "make check" mid-way, I can manually terminate the daemons with: make check TESTSUITEFLAGS='-k stop' (and start with TESTSUITEFLAGS="-k start", of course) The TESTSUITEFLAGS is implememented as: check-local: atconfig atlocal $(TESTSUITE) $(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS) For simpler tests where I start the daemon just for a test group I've used something like this pattern: AT_SETUP([foo]) cleanup() { # do what's required to cleanup daemon if its running } AT_CHECK([start daemon]) AT_CHECK([test 1], [0], [], [], [cleanup]) AT_CHECK([test 2], [0], [], [], [cleanup]) cleanup AT_CLEANUP() Luke.
pgp8aZXwnqFv9.pgp
Description: PGP signature