[Nix-dev] package test set up and tear down

Tomas Hlavaty tomas.hlavaty at knowledgetools.de
Tue Apr 14 14:54:35 CEST 2015


Hi all,

I have a nix package expression with "doCheck = true;".  The tests
require a RDBMS (postgresql for now).  preCheck creates postgresql roles
and database and postCheck drops the roles and database.  However, if
make check fails, postCheck is not executed and the database remains
polluted (and needs manual intervention).  Is there a way to revert the
changes made by preCheck reliably even if make check fails?  Something
like postCheckFinally, maybe?

What is the recommended way of testing such packages?  The only one I
found was nixos/tests/trac.nix which somehow runs nixos specific tests
and creates a VM for the database, which is then discarded somehow.  If
this is the way to go, do you have some pointers or examples I could
follow about how to create and run these tests?

I also found
https://nixos.org/wiki/Kiberpipa_sprint_2014_topics_wiki_backup#Nixtest_-_testing_for_nixpkgs
so it seems that there is a demand better package testing.  Have there
been any progress on this front?

Thank you,

Tomas


More information about the nix-dev mailing list