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
|
|
|
|
|
|
|
#
|
2012-01-09 16:32:31 -05:00
|
|
|
# Test stowing packages.
|
2011-11-16 09:04:03 -05:00
|
|
|
#
|
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
2011-11-16 09:04:03 -05:00
|
|
|
|
2015-01-01 14:02:46 -05:00
|
|
|
use Test::More tests => 118;
|
2011-11-16 10:16:53 -05:00
|
|
|
use Test::Output;
|
2011-11-16 09:04:03 -05:00
|
|
|
use English qw(-no_match_vars);
|
|
|
|
|
2019-06-28 05:32:18 -04:00
|
|
|
use Stow::Util qw(canon_path set_debug_level);
|
2011-11-24 11:28:09 -05:00
|
|
|
use testutil;
|
2011-11-16 09:04:03 -05:00
|
|
|
|
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-24 11:28:09 -05:00
|
|
|
|
|
|
|
my $stow;
|
2011-11-24 17:49:22 -05:00
|
|
|
my %conflicts;
|
2011-11-16 09:04:03 -05:00
|
|
|
|
|
|
|
# Note that each of the following tests use a distinct set of files
|
|
|
|
|
|
|
|
#
|
|
|
|
# stow a simple tree minimally
|
2014-09-21 19:40:25 -04:00
|
|
|
#
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow = new_Stow(dir => '../stow');
|
2011-11-16 09:04:03 -05:00
|
|
|
|
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');
|
2011-11-24 11:28:09 -05:00
|
|
|
|
|
|
|
$stow->plan_stow('pkg1');
|
|
|
|
$stow->process_tasks();
|
2012-02-18 15:13:32 -05:00
|
|
|
is_deeply([ $stow->get_conflicts ], [], 'no conflicts with minimal stow');
|
2014-09-21 19:40:25 -04:00
|
|
|
is(
|
|
|
|
readlink('bin1'),
|
|
|
|
'../stow/pkg1/bin1',
|
|
|
|
=> 'minimal stow of a simple tree'
|
2011-11-16 09:04:03 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
#
|
|
|
|
# stow a simple tree into an existing directory
|
|
|
|
#
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow = new_Stow();
|
2011-11-16 09:04:03 -05:00
|
|
|
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('../stow/pkg2/lib2');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_file('../stow/pkg2/lib2/file2');
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('lib2');
|
2012-01-09 16:25:35 -05:00
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow->plan_stow('pkg2');
|
|
|
|
$stow->process_tasks();
|
2014-09-21 19:40:25 -04:00
|
|
|
is(
|
2011-11-16 09:04:03 -05:00
|
|
|
readlink('lib2/file2'),
|
2014-09-21 19:40:25 -04:00
|
|
|
'../../stow/pkg2/lib2/file2',
|
|
|
|
=> 'stow simple tree to existing directory'
|
2011-11-16 09:04:03 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
#
|
2014-09-21 19:40:25 -04:00
|
|
|
# unfold existing tree
|
2011-11-16 09:04:03 -05:00
|
|
|
#
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow = new_Stow();
|
2011-11-16 09:04:03 -05:00
|
|
|
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('../stow/pkg3a/bin3');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_file('../stow/pkg3a/bin3/file3a');
|
|
|
|
make_link('bin3' => '../stow/pkg3a/bin3'); # emulate stow
|
|
|
|
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('../stow/pkg3b/bin3');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_file('../stow/pkg3b/bin3/file3b');
|
2012-01-09 16:25:35 -05:00
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow->plan_stow('pkg3b');
|
|
|
|
$stow->process_tasks();
|
2014-09-21 19:40:25 -04:00
|
|
|
ok(
|
2011-11-16 09:04:03 -05:00
|
|
|
-d 'bin3' &&
|
|
|
|
readlink('bin3/file3a') eq '../../stow/pkg3a/bin3/file3a' &&
|
2014-09-21 19:40:25 -04:00
|
|
|
readlink('bin3/file3b') eq '../../stow/pkg3b/bin3/file3b'
|
2011-11-16 09:04:03 -05:00
|
|
|
=> 'target already has 1 stowed package'
|
|
|
|
);
|
|
|
|
|
|
|
|
#
|
2012-01-09 16:25:35 -05:00
|
|
|
# Link to a new dir 'bin4' conflicts with existing non-dir so can't
|
|
|
|
# unfold
|
2011-11-16 09:04:03 -05:00
|
|
|
#
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow = new_Stow();
|
2011-11-16 09:04:03 -05:00
|
|
|
|
|
|
|
make_file('bin4'); # this is a file but named like a directory
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('../stow/pkg4/bin4');
|
2014-09-21 19:40:25 -04:00
|
|
|
make_file('../stow/pkg4/bin4/file4');
|
2012-01-09 16:25:35 -05:00
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow->plan_stow('pkg4');
|
2011-11-24 17:49:22 -05:00
|
|
|
%conflicts = $stow->get_conflicts();
|
2012-01-09 16:25:35 -05:00
|
|
|
ok(
|
|
|
|
$stow->get_conflict_count == 1 &&
|
|
|
|
$conflicts{stow}{pkg4}[0] =~
|
|
|
|
qr/existing target is neither a link nor a directory/
|
|
|
|
=> 'link to new dir bin4 conflicts with existing non-directory'
|
|
|
|
);
|
|
|
|
|
|
|
|
#
|
|
|
|
# Link to a new dir 'bin4a' conflicts with existing non-dir so can't
|
|
|
|
# unfold even with --adopt
|
|
|
|
#
|
|
|
|
#$stow = new_Stow(adopt => 1);
|
|
|
|
$stow = new_Stow();
|
|
|
|
|
|
|
|
make_file('bin4a'); # this is a file but named like a directory
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('../stow/pkg4a/bin4a');
|
2014-09-21 19:40:25 -04:00
|
|
|
make_file('../stow/pkg4a/bin4a/file4a');
|
2012-01-09 16:25:35 -05:00
|
|
|
|
|
|
|
$stow->plan_stow('pkg4a');
|
|
|
|
%conflicts = $stow->get_conflicts();
|
|
|
|
ok(
|
|
|
|
$stow->get_conflict_count == 1 &&
|
2014-09-21 19:40:25 -04:00
|
|
|
$conflicts{stow}{pkg4a}[0] =~
|
2012-01-09 16:25:35 -05:00
|
|
|
qr/existing target is neither a link nor a directory/
|
|
|
|
=> 'link to new dir bin4a conflicts with existing non-directory'
|
2011-11-16 09:04:03 -05:00
|
|
|
);
|
|
|
|
|
2012-01-09 16:25:35 -05:00
|
|
|
#
|
|
|
|
# Link to files 'file4b' and 'bin4b' conflict with existing files
|
|
|
|
# without --adopt
|
|
|
|
#
|
|
|
|
$stow = new_Stow();
|
|
|
|
|
|
|
|
# Populate target
|
|
|
|
make_file('file4b', 'file4b - version originally in target');
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path ('bin4b');
|
2012-01-09 16:25:35 -05:00
|
|
|
make_file('bin4b/file4b', 'bin4b/file4b - version originally in target');
|
|
|
|
|
|
|
|
# Populate
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path ('../stow/pkg4b/bin4b');
|
2012-01-09 16:25:35 -05:00
|
|
|
make_file('../stow/pkg4b/file4b', 'file4b - version originally in stow package');
|
|
|
|
make_file('../stow/pkg4b/bin4b/file4b', 'bin4b/file4b - version originally in stow package');
|
|
|
|
|
|
|
|
$stow->plan_stow('pkg4b');
|
|
|
|
%conflicts = $stow->get_conflicts();
|
|
|
|
is($stow->get_conflict_count, 2 => 'conflict per file');
|
|
|
|
for my $i (0, 1) {
|
|
|
|
like(
|
|
|
|
$conflicts{stow}{pkg4b}[$i],
|
|
|
|
qr/existing target is neither a link nor a directory/
|
|
|
|
=> 'link to file4b conflicts with existing non-directory'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Link to files 'file4b' and 'bin4b' do not conflict with existing
|
|
|
|
# files when --adopt is given
|
|
|
|
#
|
|
|
|
$stow = new_Stow(adopt => 1);
|
|
|
|
|
|
|
|
# Populate target
|
|
|
|
make_file('file4c', "file4c - version originally in target\n");
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path ('bin4c');
|
2012-01-09 16:25:35 -05:00
|
|
|
make_file('bin4c/file4c', "bin4c/file4c - version originally in target\n");
|
|
|
|
|
|
|
|
# Populate
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path ('../stow/pkg4c/bin4c');
|
2012-01-09 16:25:35 -05:00
|
|
|
make_file('../stow/pkg4c/file4c', "file4c - version originally in stow package\n");
|
|
|
|
make_file('../stow/pkg4c/bin4c/file4c', "bin4c/file4c - version originally in stow package\n");
|
|
|
|
|
|
|
|
$stow->plan_stow('pkg4c');
|
|
|
|
is($stow->get_conflict_count, 0 => 'no conflicts with --adopt');
|
2012-01-11 09:01:40 -05:00
|
|
|
is($stow->get_tasks, 4 => 'two tasks per file');
|
2012-01-09 16:25:35 -05:00
|
|
|
$stow->process_tasks();
|
|
|
|
for my $file ('file4c', 'bin4c/file4c') {
|
|
|
|
ok(-l $file, "$file turned into a symlink");
|
|
|
|
is(
|
|
|
|
readlink $file,
|
|
|
|
(index($file, '/') == -1 ? '' : '../' )
|
|
|
|
. "../stow/pkg4c/$file" => "$file points to right place"
|
|
|
|
);
|
|
|
|
is(cat_file($file), "$file - version originally in target\n" => "$file has right contents");
|
|
|
|
}
|
|
|
|
|
2014-09-21 19:40:25 -04:00
|
|
|
|
2011-11-16 09:04:03 -05:00
|
|
|
#
|
|
|
|
# Target already exists but is not owned by stow
|
|
|
|
#
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow = new_Stow();
|
2011-11-16 09:04:03 -05:00
|
|
|
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('bin5');
|
2012-02-18 15:19:05 -05:00
|
|
|
make_invalid_link('bin5/file5','../../empty');
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('../stow/pkg5/bin5/file5');
|
2012-01-09 16:25:35 -05:00
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow->plan_stow('pkg5');
|
2011-11-24 17:49:22 -05:00
|
|
|
%conflicts = $stow->get_conflicts();
|
2014-09-21 19:40:25 -04:00
|
|
|
like(
|
2011-11-24 17:49:22 -05:00
|
|
|
$conflicts{stow}{pkg5}[-1],
|
2012-01-09 16:25:35 -05:00
|
|
|
qr/not owned by stow/
|
2011-11-16 09:04:03 -05:00
|
|
|
=> 'target already exists but is not owned by stow'
|
|
|
|
);
|
|
|
|
|
|
|
|
#
|
2014-09-21 19:40:25 -04:00
|
|
|
# Replace existing but invalid target
|
2011-11-16 09:04:03 -05:00
|
|
|
#
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow = new_Stow();
|
2011-11-16 09:04:03 -05:00
|
|
|
|
2012-02-18 15:19:05 -05:00
|
|
|
make_invalid_link('file6','../stow/path-does-not-exist');
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('../stow/pkg6');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_file('../stow/pkg6/file6');
|
2012-01-09 16:25:35 -05:00
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow->plan_stow('pkg6');
|
|
|
|
$stow->process_tasks();
|
2014-09-21 19:40:25 -04:00
|
|
|
is(
|
2011-11-16 09:04:03 -05:00
|
|
|
readlink('file6'),
|
2014-09-21 19:40:25 -04:00
|
|
|
'../stow/pkg6/file6'
|
2011-11-16 09:04:03 -05:00
|
|
|
=> 'replace existing but invalid target'
|
|
|
|
);
|
|
|
|
|
|
|
|
#
|
|
|
|
# Target already exists, is owned by stow, but points to a non-directory
|
|
|
|
# (can't unfold)
|
|
|
|
#
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow = new_Stow();
|
2019-06-28 05:32:18 -04:00
|
|
|
#set_debug_level(4);
|
2011-11-16 09:04:03 -05:00
|
|
|
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('bin7');
|
|
|
|
make_path('../stow/pkg7a/bin7');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_file('../stow/pkg7a/bin7/node7');
|
|
|
|
make_link('bin7/node7','../../stow/pkg7a/bin7/node7');
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('../stow/pkg7b/bin7/node7');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_file('../stow/pkg7b/bin7/node7/file7');
|
2012-01-09 16:25:35 -05:00
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow->plan_stow('pkg7b');
|
2011-11-24 17:49:22 -05:00
|
|
|
%conflicts = $stow->get_conflicts();
|
2011-11-24 11:28:09 -05:00
|
|
|
like(
|
2011-11-24 17:49:22 -05:00
|
|
|
$conflicts{stow}{pkg7b}[-1],
|
2012-01-09 16:25:35 -05:00
|
|
|
qr/existing target is stowed to a different package/
|
2011-11-16 09:04:03 -05:00
|
|
|
=> 'link to new dir conflicts with existing stowed non-directory'
|
|
|
|
);
|
|
|
|
|
|
|
|
#
|
|
|
|
# stowing directories named 0
|
|
|
|
#
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow = new_Stow();
|
2011-11-16 09:04:03 -05:00
|
|
|
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('../stow/pkg8a/0');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_file('../stow/pkg8a/0/file8a');
|
|
|
|
make_link('0' => '../stow/pkg8a/0'); # emulate stow
|
|
|
|
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('../stow/pkg8b/0');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_file('../stow/pkg8b/0/file8b');
|
2012-01-09 16:25:35 -05:00
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow->plan_stow('pkg8b');
|
|
|
|
$stow->process_tasks();
|
2014-09-21 19:40:25 -04:00
|
|
|
ok(
|
2012-01-09 13:32:06 -05:00
|
|
|
$stow->get_conflict_count == 0 &&
|
2011-11-16 09:04:03 -05:00
|
|
|
-d '0' &&
|
|
|
|
readlink('0/file8a') eq '../../stow/pkg8a/0/file8a' &&
|
2014-09-21 19:40:25 -04:00
|
|
|
readlink('0/file8b') eq '../../stow/pkg8b/0/file8b'
|
2011-11-16 09:04:03 -05:00
|
|
|
=> 'stowing directories named 0'
|
|
|
|
);
|
|
|
|
|
|
|
|
#
|
|
|
|
# overriding already stowed documentation
|
|
|
|
#
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow = new_Stow(override => ['man9', 'info9']);
|
2011-11-16 09:04:03 -05:00
|
|
|
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('../stow/pkg9a/man9/man1');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_file('../stow/pkg9a/man9/man1/file9.1');
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('man9/man1');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_link('man9/man1/file9.1' => '../../../stow/pkg9a/man9/man1/file9.1'); # emulate stow
|
|
|
|
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('../stow/pkg9b/man9/man1');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_file('../stow/pkg9b/man9/man1/file9.1');
|
2012-01-09 16:25:35 -05:00
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow->plan_stow('pkg9b');
|
|
|
|
$stow->process_tasks();
|
2014-09-21 19:40:25 -04:00
|
|
|
ok(
|
2012-01-09 13:32:06 -05:00
|
|
|
$stow->get_conflict_count == 0 &&
|
2014-09-21 19:40:25 -04:00
|
|
|
readlink('man9/man1/file9.1') eq '../../../stow/pkg9b/man9/man1/file9.1'
|
2011-11-16 09:04:03 -05:00
|
|
|
=> 'overriding existing documentation files'
|
|
|
|
);
|
|
|
|
|
|
|
|
#
|
|
|
|
# deferring to already stowed documentation
|
|
|
|
#
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow = new_Stow(defer => ['man10', 'info10']);
|
2011-11-16 09:04:03 -05:00
|
|
|
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('../stow/pkg10a/man10/man1');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_file('../stow/pkg10a/man10/man1/file10.1');
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('man10/man1');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_link('man10/man1/file10.1' => '../../../stow/pkg10a/man10/man1/file10.1'); # emulate stow
|
|
|
|
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('../stow/pkg10b/man10/man1');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_file('../stow/pkg10b/man10/man1/file10.1');
|
2011-11-24 11:28:09 -05:00
|
|
|
|
2012-01-09 16:25:35 -05:00
|
|
|
$stow->plan_stow('pkg10b');
|
2012-01-11 09:01:40 -05:00
|
|
|
is($stow->get_tasks, 0, 'no tasks to process');
|
2014-09-21 19:40:25 -04:00
|
|
|
ok(
|
2012-01-09 13:32:06 -05:00
|
|
|
$stow->get_conflict_count == 0 &&
|
2014-09-21 19:40:25 -04:00
|
|
|
readlink('man10/man1/file10.1') eq '../../../stow/pkg10a/man10/man1/file10.1'
|
2011-11-16 09:04:03 -05:00
|
|
|
=> 'defer to existing documentation files'
|
|
|
|
);
|
|
|
|
|
|
|
|
#
|
|
|
|
# Ignore temp files
|
|
|
|
#
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow = new_Stow(ignore => ['~', '\.#.*']);
|
2011-11-16 09:04:03 -05:00
|
|
|
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('../stow/pkg11/man11/man1');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_file('../stow/pkg11/man11/man1/file11.1');
|
|
|
|
make_file('../stow/pkg11/man11/man1/file11.1~');
|
|
|
|
make_file('../stow/pkg11/man11/man1/.#file11.1');
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('man11/man1');
|
2011-11-16 09:04:03 -05:00
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow->plan_stow('pkg11');
|
|
|
|
$stow->process_tasks();
|
2014-09-21 19:40:25 -04:00
|
|
|
ok(
|
2012-01-09 13:32:06 -05:00
|
|
|
$stow->get_conflict_count == 0 &&
|
2011-11-16 09:04:03 -05:00
|
|
|
readlink('man11/man1/file11.1') eq '../../../stow/pkg11/man11/man1/file11.1' &&
|
2014-09-21 19:40:25 -04:00
|
|
|
!-e 'man11/man1/file11.1~' &&
|
2011-11-16 09:04:03 -05:00
|
|
|
!-e 'man11/man1/.#file11.1'
|
|
|
|
=> 'ignore temp files'
|
|
|
|
);
|
|
|
|
|
|
|
|
#
|
|
|
|
# stowing links library files
|
|
|
|
#
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow = new_Stow();
|
2011-11-16 09:04:03 -05:00
|
|
|
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('../stow/pkg12/lib12/');
|
2012-02-18 07:28:00 -05:00
|
|
|
make_file('../stow/pkg12/lib12/lib.so.1');
|
|
|
|
make_link('../stow/pkg12/lib12/lib.so', 'lib.so.1');
|
2011-11-16 09:04:03 -05:00
|
|
|
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('lib12/');
|
2012-01-09 16:25:35 -05:00
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow->plan_stow('pkg12');
|
|
|
|
$stow->process_tasks();
|
2014-09-21 19:40:25 -04:00
|
|
|
ok(
|
2012-01-09 13:32:06 -05:00
|
|
|
$stow->get_conflict_count == 0 &&
|
2012-02-18 07:28:00 -05:00
|
|
|
readlink('lib12/lib.so.1') eq '../../stow/pkg12/lib12/lib.so.1' &&
|
|
|
|
readlink('lib12/lib.so' ) eq '../../stow/pkg12/lib12/lib.so'
|
2011-11-16 09:04:03 -05:00
|
|
|
=> 'stow links to libraries'
|
|
|
|
);
|
|
|
|
|
|
|
|
#
|
|
|
|
# unfolding to stow links to library files
|
|
|
|
#
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow = new_Stow();
|
2011-11-16 09:04:03 -05:00
|
|
|
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('../stow/pkg13a/lib13/');
|
2012-02-18 07:28:00 -05:00
|
|
|
make_file('../stow/pkg13a/lib13/liba.so.1');
|
|
|
|
make_link('../stow/pkg13a/lib13/liba.so', 'liba.so.1');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_link('lib13','../stow/pkg13a/lib13');
|
|
|
|
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('../stow/pkg13b/lib13/');
|
2012-02-18 07:28:00 -05:00
|
|
|
make_file('../stow/pkg13b/lib13/libb.so.1');
|
|
|
|
make_link('../stow/pkg13b/lib13/libb.so', 'libb.so.1');
|
2011-11-16 09:04:03 -05:00
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow->plan_stow('pkg13b');
|
|
|
|
$stow->process_tasks();
|
2014-09-21 19:40:25 -04:00
|
|
|
ok(
|
2012-01-09 13:32:06 -05:00
|
|
|
$stow->get_conflict_count == 0 &&
|
2011-11-16 09:04:03 -05:00
|
|
|
readlink('lib13/liba.so.1') eq '../../stow/pkg13a/lib13/liba.so.1' &&
|
2012-02-18 07:28:00 -05:00
|
|
|
readlink('lib13/liba.so' ) eq '../../stow/pkg13a/lib13/liba.so' &&
|
2014-09-21 19:40:25 -04:00
|
|
|
readlink('lib13/libb.so.1') eq '../../stow/pkg13b/lib13/libb.so.1' &&
|
|
|
|
readlink('lib13/libb.so' ) eq '../../stow/pkg13b/lib13/libb.so'
|
2011-11-16 09:04:03 -05:00
|
|
|
=> 'unfolding to stow links to libraries'
|
|
|
|
);
|
2011-11-18 05:48:48 -05:00
|
|
|
|
|
|
|
#
|
|
|
|
# stowing to stow dir should fail
|
|
|
|
#
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('stow');
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow = new_Stow(dir => 'stow');
|
2011-11-18 05:48:48 -05:00
|
|
|
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('stow/pkg14/stow/pkg15');
|
2011-11-18 05:48:48 -05:00
|
|
|
make_file('stow/pkg14/stow/pkg15/node15');
|
|
|
|
|
2014-09-21 19:36:25 -04:00
|
|
|
capture_stderr();
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow->plan_stow('pkg14');
|
2012-01-11 09:01:40 -05:00
|
|
|
is($stow->get_tasks, 0, 'no tasks to process');
|
2011-11-18 05:48:48 -05:00
|
|
|
ok(
|
2012-01-09 13:32:06 -05:00
|
|
|
$stow->get_conflict_count == 0 &&
|
2011-11-18 05:48:48 -05:00
|
|
|
! -l 'stow/pkg15'
|
|
|
|
=> "stowing to stow dir should fail"
|
|
|
|
);
|
2014-09-21 19:36:25 -04:00
|
|
|
like($stderr,
|
|
|
|
qr/WARNING: skipping target which was current stow directory stow/
|
|
|
|
=> "stowing to stow dir should give warning");
|
|
|
|
uncapture_stderr();
|
2011-11-24 11:28:09 -05:00
|
|
|
|
|
|
|
#
|
|
|
|
# stow a simple tree minimally when cwd isn't target
|
|
|
|
#
|
|
|
|
cd('../..');
|
2019-06-27 19:53:12 -04:00
|
|
|
$stow = new_Stow(dir => "$TEST_DIR/stow", target => "$TEST_DIR/target");
|
2011-11-24 11:28:09 -05:00
|
|
|
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path("$TEST_DIR/stow/pkg16/bin16");
|
2019-06-27 19:53:12 -04:00
|
|
|
make_file("$TEST_DIR/stow/pkg16/bin16/file16");
|
2011-11-24 11:28:09 -05:00
|
|
|
|
|
|
|
$stow->plan_stow('pkg16');
|
|
|
|
$stow->process_tasks();
|
2012-02-18 15:13:32 -05:00
|
|
|
is_deeply([ $stow->get_conflicts ], [], 'no conflicts with minimal stow');
|
2011-11-24 11:28:09 -05:00
|
|
|
is(
|
2019-06-27 19:53:12 -04:00
|
|
|
readlink("$TEST_DIR/target/bin16"),
|
2011-11-24 11:28:09 -05:00
|
|
|
'../stow/pkg16/bin16',
|
2011-11-21 18:23:43 -05:00
|
|
|
=> "minimal stow of a simple tree when cwd isn't target"
|
|
|
|
);
|
|
|
|
|
|
|
|
#
|
|
|
|
# stow a simple tree minimally to absolute stow dir when cwd isn't
|
|
|
|
# target
|
|
|
|
#
|
2019-06-27 19:53:12 -04:00
|
|
|
$stow = new_Stow(dir => canon_path("$TEST_DIR/stow"),
|
|
|
|
target => "$TEST_DIR/target");
|
2011-11-21 18:23:43 -05:00
|
|
|
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path("$TEST_DIR/stow/pkg17/bin17");
|
2019-06-27 19:53:12 -04:00
|
|
|
make_file("$TEST_DIR/stow/pkg17/bin17/file17");
|
2011-11-21 18:23:43 -05:00
|
|
|
|
|
|
|
$stow->plan_stow('pkg17');
|
|
|
|
$stow->process_tasks();
|
2012-02-18 15:13:32 -05:00
|
|
|
is_deeply([ $stow->get_conflicts ], [], 'no conflicts with minimal stow');
|
2011-11-21 18:23:43 -05:00
|
|
|
is(
|
2019-06-27 19:53:12 -04:00
|
|
|
readlink("$TEST_DIR/target/bin17"),
|
2011-11-21 18:23:43 -05:00
|
|
|
'../stow/pkg17/bin17',
|
|
|
|
=> "minimal stow of a simple tree with absolute stow dir"
|
|
|
|
);
|
|
|
|
|
|
|
|
#
|
|
|
|
# stow a simple tree minimally with absolute stow AND target dirs when
|
|
|
|
# cwd isn't target
|
|
|
|
#
|
2019-06-27 19:53:12 -04:00
|
|
|
$stow = new_Stow(dir => canon_path("$TEST_DIR/stow"),
|
|
|
|
target => canon_path("$TEST_DIR/target"));
|
2011-11-21 18:23:43 -05:00
|
|
|
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path("$TEST_DIR/stow/pkg18/bin18");
|
2019-06-27 19:53:12 -04:00
|
|
|
make_file("$TEST_DIR/stow/pkg18/bin18/file18");
|
2011-11-21 18:23:43 -05:00
|
|
|
|
|
|
|
$stow->plan_stow('pkg18');
|
|
|
|
$stow->process_tasks();
|
2012-02-18 15:13:32 -05:00
|
|
|
is_deeply([ $stow->get_conflicts ], [], 'no conflicts with minimal stow');
|
2011-11-21 18:23:43 -05:00
|
|
|
is(
|
2019-06-27 19:53:12 -04:00
|
|
|
readlink("$TEST_DIR/target/bin18"),
|
2011-11-21 18:23:43 -05:00
|
|
|
'../stow/pkg18/bin18',
|
|
|
|
=> "minimal stow of a simple tree with absolute stow and target dirs"
|
2011-11-24 11:28:09 -05:00
|
|
|
);
|
2012-01-09 16:25:35 -05:00
|
|
|
|
2012-02-18 15:13:32 -05:00
|
|
|
#
|
|
|
|
# stow a tree with no-folding enabled -
|
|
|
|
# no new folded directories should be created, and existing
|
|
|
|
# folded directories should be split open (unfolded) where
|
|
|
|
# (and only where) necessary
|
|
|
|
#
|
2019-06-27 19:53:12 -04:00
|
|
|
cd("$TEST_DIR/target");
|
2012-02-18 15:13:32 -05:00
|
|
|
|
|
|
|
sub create_pkg {
|
|
|
|
my ($id, $pkg) = @_;
|
|
|
|
|
|
|
|
my $stow_pkg = "../stow/$id-$pkg";
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path ($stow_pkg);
|
2012-02-18 15:13:32 -05:00
|
|
|
make_file("$stow_pkg/$id-file-$pkg");
|
|
|
|
|
|
|
|
# create a shallow hierarchy specific to this package which isn't
|
|
|
|
# yet stowed
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path ("$stow_pkg/$id-$pkg-only-new");
|
2012-02-18 15:13:32 -05:00
|
|
|
make_file("$stow_pkg/$id-$pkg-only-new/$id-file-$pkg");
|
|
|
|
|
|
|
|
# create a deeper hierarchy specific to this package which isn't
|
|
|
|
# yet stowed
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path ("$stow_pkg/$id-$pkg-only-new2/subdir");
|
2012-02-18 15:13:32 -05:00
|
|
|
make_file("$stow_pkg/$id-$pkg-only-new2/subdir/$id-file-$pkg");
|
2015-01-01 14:02:46 -05:00
|
|
|
make_link("$stow_pkg/$id-$pkg-only-new2/current", "subdir");
|
2012-02-18 15:13:32 -05:00
|
|
|
|
|
|
|
# create a hierarchy specific to this package which is already
|
|
|
|
# stowed via a folded tree
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path ("$stow_pkg/$id-$pkg-only-old");
|
2012-02-18 15:13:32 -05:00
|
|
|
make_link("$id-$pkg-only-old", "$stow_pkg/$id-$pkg-only-old");
|
|
|
|
make_file("$stow_pkg/$id-$pkg-only-old/$id-file-$pkg");
|
|
|
|
|
|
|
|
# create a shared hierarchy which this package uses
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path ("$stow_pkg/$id-shared");
|
2012-02-18 15:13:32 -05:00
|
|
|
make_file("$stow_pkg/$id-shared/$id-file-$pkg");
|
|
|
|
|
|
|
|
# create a partially shared hierarchy which this package uses
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path ("$stow_pkg/$id-shared2/subdir-$pkg");
|
2012-02-18 15:13:32 -05:00
|
|
|
make_file("$stow_pkg/$id-shared2/$id-file-$pkg");
|
|
|
|
make_file("$stow_pkg/$id-shared2/subdir-$pkg/$id-file-$pkg");
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach my $pkg (qw{a b}) {
|
|
|
|
create_pkg('no-folding', $pkg);
|
|
|
|
}
|
|
|
|
|
|
|
|
$stow = new_Stow('no-folding' => 1);
|
|
|
|
$stow->plan_stow('no-folding-a');
|
|
|
|
is_deeply([ $stow->get_conflicts ], [] => 'no conflicts with --no-folding');
|
|
|
|
my @tasks = $stow->get_tasks;
|
|
|
|
use Data::Dumper;
|
2015-01-01 14:02:46 -05:00
|
|
|
is(scalar(@tasks), 13 => "6 dirs, 7 links") || warn Dumper(\@tasks);
|
2012-02-18 15:13:32 -05:00
|
|
|
$stow->process_tasks();
|
|
|
|
|
|
|
|
sub check_no_folding {
|
|
|
|
my ($pkg) = @_;
|
|
|
|
my $stow_pkg = "../stow/no-folding-$pkg";
|
|
|
|
is_link("no-folding-file-$pkg", "$stow_pkg/no-folding-file-$pkg");
|
|
|
|
|
|
|
|
# check existing folded tree is untouched
|
|
|
|
is_link("no-folding-$pkg-only-old", "$stow_pkg/no-folding-$pkg-only-old");
|
|
|
|
|
|
|
|
# check newly stowed shallow tree is not folded
|
|
|
|
is_dir_not_symlink("no-folding-$pkg-only-new");
|
|
|
|
is_link("no-folding-$pkg-only-new/no-folding-file-$pkg",
|
|
|
|
"../$stow_pkg/no-folding-$pkg-only-new/no-folding-file-$pkg");
|
|
|
|
|
|
|
|
# check newly stowed deeper tree is not folded
|
|
|
|
is_dir_not_symlink("no-folding-$pkg-only-new2");
|
|
|
|
is_dir_not_symlink("no-folding-$pkg-only-new2/subdir");
|
|
|
|
is_link("no-folding-$pkg-only-new2/subdir/no-folding-file-$pkg",
|
|
|
|
"../../$stow_pkg/no-folding-$pkg-only-new2/subdir/no-folding-file-$pkg");
|
2015-01-01 14:02:46 -05:00
|
|
|
is_link("no-folding-$pkg-only-new2/current",
|
|
|
|
"../$stow_pkg/no-folding-$pkg-only-new2/current");
|
2012-02-18 15:13:32 -05:00
|
|
|
|
|
|
|
# check shared tree is not folded. first time round this will be
|
|
|
|
# newly stowed.
|
|
|
|
is_dir_not_symlink('no-folding-shared');
|
|
|
|
is_link("no-folding-shared/no-folding-file-$pkg",
|
|
|
|
"../$stow_pkg/no-folding-shared/no-folding-file-$pkg");
|
|
|
|
|
|
|
|
# check partially shared tree is not folded. first time round this
|
|
|
|
# will be newly stowed.
|
|
|
|
is_dir_not_symlink('no-folding-shared2');
|
|
|
|
is_link("no-folding-shared2/no-folding-file-$pkg",
|
|
|
|
"../$stow_pkg/no-folding-shared2/no-folding-file-$pkg");
|
|
|
|
is_link("no-folding-shared2/no-folding-file-$pkg",
|
|
|
|
"../$stow_pkg/no-folding-shared2/no-folding-file-$pkg");
|
|
|
|
}
|
|
|
|
|
|
|
|
check_no_folding('a');
|
|
|
|
|
|
|
|
$stow = new_Stow('no-folding' => 1);
|
|
|
|
$stow->plan_stow('no-folding-b');
|
|
|
|
is_deeply([ $stow->get_conflicts ], [] => 'no conflicts with --no-folding');
|
|
|
|
@tasks = $stow->get_tasks;
|
2015-01-01 14:02:46 -05:00
|
|
|
is(scalar(@tasks), 11 => '4 dirs, 7 links') || warn Dumper(\@tasks);
|
2012-02-18 15:13:32 -05:00
|
|
|
$stow->process_tasks();
|
|
|
|
|
|
|
|
check_no_folding('a');
|
|
|
|
check_no_folding('b');
|