diff options
Diffstat (limited to 't/lib/t/Setup.pm')
-rw-r--r-- | t/lib/t/Setup.pm | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/t/lib/t/Setup.pm b/t/lib/t/Setup.pm index 980aade..15dd49b 100644 --- a/t/lib/t/Setup.pm +++ b/t/lib/t/Setup.pm @@ -9,18 +9,41 @@ use File::Slurp; use File::Temp qw(tempdir); use Git::Wrapper; use File::Spec::Functions qw(catfile); +use File::chdir; +use File::Path qw(rmtree); -our @EXPORT = qw( with_temp_annex ); +our @EXPORT = qw( with_temp_annexes ); -sub with_temp_annex (&) { +sub with_temp_annexes (&) { my $temp = tempdir CLEANUP => 1; - my $git = Git::Wrapper->new($temp); - $git->init; - $git->annex("init"); - write_file catfile($temp, "foo"), "my cool big file\n"; - $git->annex(qw(add foo)); - $git->commit({message => "add"}); - &{$_[0]}($temp); + { + local $CWD = $temp; + my ($source1, $source2, $dest) + = map { Git::Wrapper->new($_) } qw(source1 source2 dest); + mkdir for qw(source1 source2 dest); + for ($source1, $source2, $dest) { + $_->init; + $_->annex("init"); + $_->config(qw(annex.thin false)); + } + + # source1 setup + mkdir catfile qw(source1 foo); + write_file catfile(qw(source1 foo bar)), "bar\n"; + mkdir catfile qw(source1 foo foo2); + write_file catfile(qw(source1 foo foo2 baz)), "baz\n"; + $source1->RUN(qw(-c annex.gitaddtoannex=false add foo/bar)); + $source1->RUN(qw(-c annex.gitaddtoannex=false annex add foo/foo2/baz)); + $source1->commit({ message => "add" }); + + # source2 setup + write_file catfile(qw(source2 other)), "other\n"; + $source2->RUN(qw(-c annex.addunlocked=false annex add other)); + $source2->commit({ message => "add" }); + + &{ $_[0] }($temp); + } + rmtree $temp; } 1; |