2019-06-27 15:37:50 -04:00
|
|
|
#!/usr/bin/perl
|
2019-06-27 09:02:19 -04:00
|
|
|
#
|
|
|
|
# This file is part of GNU Stow.
|
|
|
|
#
|
|
|
|
# GNU Stow is free software: you can redistribute it and/or modify it
|
|
|
|
# under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# GNU Stow is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see https://www.gnu.org/licenses/.
|
2011-11-16 09:04:03 -05:00
|
|
|
|
|
|
|
#
|
|
|
|
# Testing foldable()
|
|
|
|
#
|
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use testutil;
|
2011-11-16 09:04:03 -05:00
|
|
|
|
|
|
|
use Test::More tests => 4;
|
|
|
|
use English qw(-no_match_vars);
|
|
|
|
|
2011-11-23 18:45:48 -05:00
|
|
|
init_test_dirs();
|
2019-06-27 19:53:12 -04:00
|
|
|
cd("$TEST_DIR/target");
|
2011-11-16 09:04:03 -05:00
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
my $stow = new_Stow(dir => '../stow');
|
2011-11-16 09:04:03 -05:00
|
|
|
|
|
|
|
# Note that each of the following tests use a distinct set of files
|
|
|
|
|
|
|
|
#
|
|
|
|
# can fold a simple tree
|
|
|
|
#
|
|
|
|
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('../stow/pkg1/bin1');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_file('../stow/pkg1/bin1/file1');
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('bin1');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_link('bin1/file1','../../stow/pkg1/bin1/file1');
|
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
is( $stow->foldable('bin1'), '../stow/pkg1/bin1' => q(can fold a simple tree) );
|
2011-11-16 09:04:03 -05:00
|
|
|
|
|
|
|
#
|
|
|
|
# can't fold an empty directory
|
|
|
|
#
|
|
|
|
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('../stow/pkg2/bin2');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_file('../stow/pkg2/bin2/file2');
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('bin2');
|
2011-11-16 09:04:03 -05:00
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
is( $stow->foldable('bin2'), '' => q(can't fold an empty directory) );
|
2011-11-16 09:04:03 -05:00
|
|
|
|
|
|
|
#
|
|
|
|
# can't fold if dir contains a non-link
|
|
|
|
#
|
|
|
|
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('../stow/pkg3/bin3');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_file('../stow/pkg3/bin3/file3');
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('bin3');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_link('bin3/file3','../../stow/pkg3/bin3/file3');
|
|
|
|
make_file('bin3/non-link');
|
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
is( $stow->foldable('bin3'), '' => q(can't fold a dir containing non-links) );
|
2011-11-16 09:04:03 -05:00
|
|
|
|
|
|
|
#
|
|
|
|
# can't fold if links point to different directories
|
|
|
|
#
|
|
|
|
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('bin4');
|
|
|
|
make_path('../stow/pkg4a/bin4');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_file('../stow/pkg4a/bin4/file4a');
|
|
|
|
make_link('bin4/file4a','../../stow/pkg4a/bin4/file4a');
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('../stow/pkg4b/bin4');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_file('../stow/pkg4b/bin4/file4b');
|
|
|
|
make_link('bin4/file4b','../../stow/pkg4b/bin4/file4b');
|
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
is( $stow->foldable('bin4'), '' => q(can't fold if links point to different dirs) );
|