summaryrefslogtreecommitdiff
path: root/t/22_annex-to-annex-dropunused.t
blob: c8bd47a83f161c0c517ababf8c90a794bc908158 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/perl

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

use Test::More;
use File::Spec::Functions qw(rel2abs);
use t::Setup;
use t::Util;
use File::chdir;
use File::Basename qw(dirname);
use File::Copy qw(copy);

plan skip_all => "device ID issues" if device_id_issues;

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

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

    system $a2a, qw(--commit source1/foo source2/other dest);

    {
        local $CWD = "source2";
        system $a2a_du;
        $source2->checkout("master~1");
        ok((lstat "other" and not stat "other"), "other was dropped");
    }
};

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

    system $a2a, qw(--commit source1/foo source2/other dest);

    {
        local $CWD = "source2";

        $source2->checkout("master~1");
        my ($other_key) = $source2->annex(qw(lookupkey other));
        my ($other_content) = $source2->annex("contentlocation", $other_key);
        $source2->checkout("master");

        # break the hardlink
        chmod 0755, dirname $other_content;
        copy $other_content, "$other_content.tmp";
        system "mv", "-f", "$other_content.tmp", $other_content;
        chmod 0555, dirname $other_content;

        system $a2a_du;
        $source2->checkout("master~1");
        ok((lstat "other" and stat "other"), "other was not dropped");
        # $source2->checkout("master");
        # system $a2a_du, "--dest=../dest";
        # $source2->checkout("master~1");
        # ok((lstat "other" and not stat "other"), "other was dropped");
    }
};

# with_temp_annexes {
#     my (undef, undef, $source2, $dest) = @_;

#     system $a2a, qw(--commit source1/foo source2/other dest);

#     $dest->annex(qw(drop --force other));
#     {
#         local $CWD = "source2";

#         $source2->checkout("master~1");
#         my ($other_key) = $source2->annex(qw(lookupkey other));
#         my ($other_content) = $source2->annex("contentlocation", $other_key);
#         $source2->checkout("master");

#         # break the hardlink
#         chmod 0755, dirname $other_content;
#         copy $other_content, "$other_content.tmp";
#         system "mv", "-f", "$other_content.tmp", $other_content;
#         chmod 0555, dirname $other_content;

#         system $a2a_du, "--dest=../dest";
#         $source2->checkout("master~1");
#         ok((lstat "other" and stat "other"), "other was not dropped");
#     }
# };

done_testing;