Before running the test suite you must edit the
test.conf file which comes with Daizu. If you can log in to
PostgreSQL without a password, and that will allow the test suite to
create and drop the test database, then you can simply comment out the
not-configured line, to confirm that you've checked the
configuration. The file describes the other settings you might want
to change.
If you don't configure the test suite, or if there's an error in your test.conf file, the first test program will tell you about the problem, and all the rest will be skipped.
Once configured, you can run the Daizu test suite like this:
perl Build.PL ./Build test
The test suite must always be run from within the directory created by unpacking the source package, since it refers to files which come with Daizu and expects them to be in the directory it is run from.
The first test program, t/00setup.t, creates a PostgreSQL
database (called daizu_test by default). If it already
exists then it will be deleted, so don't use it for any real work.
Note that sometimes the first part of the test suite fails. I'm not exactly sure why, but it usually works if you just run it again. This is the error message it produces:
DBD::Pg::db do failed: ERROR: source database "template1" is being accessed by other users
How it works
The first test program, t/00setup.t, is devoted to setting up the test environment for the other scripts, which won't work until it is run. It does the following things:
- Issues error messages if test.conf isn't set up correctly.
- Creates a new PostgreSQL database called
daizu_test, deleting the existing version first. It also loads the database with the schema found in db.sql by parsing it (in a very simplistic way) and running each SQL statement on the new database. - Adds information about some authors to the database. This isn't in the schema because it's only relevant to the test repository.
- Creates an empty Subversion repository in the directory .test-repos and loads the test data from the Subversion dump file test-repos.dump in to it. This adds content which the rest of the test suite expects to find.
- Creates the Daizu configuration file used by the rest of the test programs, test-config.xml, by making a copy of the template file test-config.xml.tmpl and substituting some absolute paths in.
The test suite programs use utility functions provided by the Daizu::Test module, which isn't needed for normal operation of Daizu.
Hacking on it
If you're working on the test suite and want to add additional revisions to the test repository, here's how to do it. First run the setup program to create the test repository. Then check it out as normal, like this:
svn co file://`pwd`/.test-repos test
You can then commit changes to it as normal. Obviously it's important not to accidentally run the setup program from the test suite again because it will wipe out your changes. Finally, update the dump file:
svnadmin dump --deltas .test-repos >test-repos.dump
Assuming Subversion hasn't introduced a new version of the dump file format in the mean time, the output from this should be identical to the dump file you started with except with some more information added on at the end.