Harriet - Daemon manager for testing


    use Harriet;

    my $harriet = Harriet->new('./t/harriet/');
    print $ENV{TEST_STF}, "\n";



In some case, test code requires daemons like memcached, STF, or groonga. If you are running these daemons for each test scripts, it eats lots of time.

Then, you need to keep the processes under the test suite.

Harriet solves this issue.

Harriet loads all daemons when starting prove. And set the daemon's end point to the environment variable. And run the test cases. Test script can use the daemon process (You need to clear the data if you need.).


Writing harriet script

harriet script is just a perl script has .pl extension. Example code is here:

    # t/harriet/
    use strict;
    use utf8;

    use Test::TCP;

    $ENV{TEST_MEMCACHED} ||= do {
        my $server = Test::TCP->new(
            code => sub {
                my $port = shift;
                exec '/usr/bin/memcached', '-p', $port;
                die $!;
        $HARRIET_GUARDS::MEMCACHED = $server;
        '' . $server->port;

This code runs memcached. It returns memcached's end point information and guard object. Harriet keeps guard objects while perl process lives.

(Guard object is optional.)

Load harriet script

    use Harriet;

    my $harriet = Harriet->new('./t/harriet');
    print $ENV{memcached}, "\n";

This script load the memcached daemon setup script. harriet loads harriet script named 't/harriet/'.

Save daemon process under the prove

    # .proverc

App::Prove::Plugin::Harriet loads harriet scripts under the t/harriet/, and set these to environment variables.

This plugin starts daemons before running test cases!

WHY Harriet?

Harriet is very long lived tortoise. makes long lived process.


Copyright (C) tokuhirom.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


tokuhirom <>