#!/usr/bin/perl

use strict;
use warnings;
use Cwd qw/getcwd/;

use Debian::Debhelper::Dh_Lib;

=head1 NAME

dh_raku_test -- automatically test perl 6 module packages

=head1 SYNOPSIS

B<dh_raku_test>

=head1 DESCRIPTION

This script will call C<prove6 -l -v> to self-test a Raku module package. It will
only do so if three conditions are met:

=over

=item *

A 't' directory exists

=item *

raku-tap-harness is installed, typically by adding it to the build-depencies
of the package being built

=item *

The debhelper build option 'nocheck' is not set

=back

=head2 HOME directory

Before launching tests, the C<HOME> directory is set to C<debian/tmp/home>. This
directory is cleaned up after the tests are done.

=head1 SEE ALSO

L<dh_raku_maintscript>(1), L<dh_raku_depsfile>(1), L<debhelper>(7), L<dh>(1)

=cut

if (get_buildoption("nocheck")) {
	exit 0;
}

if ((-d 't') && (-e '/usr/bin/prove6')) {
    my $tmp_home = getcwd."/debian/tmp/home/";
    print_and_doit(
        {
            update_env => {
                HOME => $tmp_home
            }
        },
        qw!/usr/bin/prove6 -l -v!
    );
    # clean up
    doit(qw!rm -rf!, $tmp_home);
}
