#!/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 calls C<prove --exec raku -Ilib> to test a Raku module
package. It only does so if three conditions are met:

=over

=item *

A 't' directory exists

=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.

=head2 Breaking build dependency loop

This script use to call c<prove6> but it caused a lot of problems
because of dependency loop. Now only Perl's prove is used.

=head1 SEE ALSO

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

=cut

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

my @prove_cmd = ('/usr/bin/prove', '--exec', 'raku -Ilib');

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