diff options
Diffstat (limited to 't/22_annex-to-annex-dropunused.t')
-rwxr-xr-x | t/22_annex-to-annex-dropunused.t | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/t/22_annex-to-annex-dropunused.t b/t/22_annex-to-annex-dropunused.t new file mode 100755 index 0000000..88affd7 --- /dev/null +++ b/t/22_annex-to-annex-dropunused.t @@ -0,0 +1,91 @@ +#!/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 File::chdir; +use File::Basename qw(dirname); +use File::Copy qw(copy); + +# 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-dropunuesd"; + +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; |