Bump version to 2.1.1
[gnu-stow.git] / t / foldable.t
blobebb3b82e8128c0d5668e9a0975b293b1ced82704
1 #!/usr/local/bin/perl
4 # Testing foldable()
7 use strict;
8 use warnings;
10 use testutil;
12 use Test::More tests => 4;
13 use English qw(-no_match_vars);
15 init_test_dirs();
16 cd("$OUT_DIR/target");
18 my $stow = new_Stow(dir => '../stow');
20 # Note that each of the following tests use a distinct set of files
23 # can fold a simple tree
26 make_dir('../stow/pkg1/bin1');
27 make_file('../stow/pkg1/bin1/file1');
28 make_dir('bin1');
29 make_link('bin1/file1','../../stow/pkg1/bin1/file1');
31 is( $stow->foldable('bin1'), '../stow/pkg1/bin1' => q(can fold a simple tree) );
34 # can't fold an empty directory
37 make_dir('../stow/pkg2/bin2');
38 make_file('../stow/pkg2/bin2/file2');
39 make_dir('bin2');
41 is( $stow->foldable('bin2'), '' => q(can't fold an empty directory) );
44 # can't fold if dir contains a non-link
47 make_dir('../stow/pkg3/bin3');
48 make_file('../stow/pkg3/bin3/file3');
49 make_dir('bin3');
50 make_link('bin3/file3','../../stow/pkg3/bin3/file3');
51 make_file('bin3/non-link');
53 is( $stow->foldable('bin3'), '' => q(can't fold a dir containing non-links) );
56 # can't fold if links point to different directories
59 make_dir('bin4');
60 make_dir('../stow/pkg4a/bin4');
61 make_file('../stow/pkg4a/bin4/file4a');
62 make_link('bin4/file4a','../../stow/pkg4a/bin4/file4a');
63 make_dir('../stow/pkg4b/bin4');
64 make_file('../stow/pkg4b/bin4/file4b');
65 make_link('bin4/file4b','../../stow/pkg4b/bin4/file4b');
67 is( $stow->foldable('bin4'), '' => q(can't fold if links point to different dirs) );