summaryrefslogtreecommitdiff
path: root/t/24_annex-review-unused.t
blob: 30e428869ae989d815e18fd0e8f53fe04851031d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/perl

use 5.028;
use strict;
use warnings;
use lib 't/lib';

use Test::More;
use t::Setup;
use File::chdir;
use File::Spec::Functions qw(rel2abs);

# make sure that `make test` will always use the right version of the
# script we seek to test
my $aru = "annex-review-unused";
$aru = rel2abs "blib/script/annex-review-unused"
  if -x "blib/script/annex-review-unused";

with_temp_annexes {
    my (undef, $source1) = @_;

    {
        local $CWD = "source1";
        system $aru;
        ok !$?, "it exits zero when no unused files";
        sleep 1;
        $source1->rm("foo/foo2/baz");
        $source1->commit({ message => "rm" });
        my @output = `$aru --just-print`;
        my $exit = $? >> 8;
        ok $?, "it exits nonzero when unused files";
        ok 20 < @output && @output < 30, "it prints ~two log entries";
        like $output[5], qr/unused file #1/, "it prints an expected line";
    }
}
;

done_testing;