2011-11-16 09:04:03 -05:00
|
|
|
#!/usr/local/bin/perl
|
|
|
|
|
|
|
|
#
|
2011-11-24 11:28:09 -05:00
|
|
|
# Testing stow_contents()
|
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
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
use Test::More tests => 19;
|
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);
|
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
use testutil;
|
2011-11-16 09:04:03 -05:00
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
make_fresh_stow_and_target_dirs();
|
|
|
|
cd('t/target');
|
|
|
|
|
|
|
|
my $stow;
|
|
|
|
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
|
|
|
|
#
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow = new_Stow(dir => '../stow');
|
2011-11-16 09:04:03 -05:00
|
|
|
|
|
|
|
make_dir('../stow/pkg1/bin1');
|
|
|
|
make_file('../stow/pkg1/bin1/file1');
|
2011-11-24 11:28:09 -05:00
|
|
|
|
|
|
|
$stow->plan_stow('pkg1');
|
|
|
|
$stow->process_tasks();
|
|
|
|
is($stow->get_conflicts(), 0, 'no conflicts with minimal stow');
|
2011-11-16 09:04:03 -05:00
|
|
|
is(
|
|
|
|
readlink('bin1'),
|
|
|
|
'../stow/pkg1/bin1',
|
|
|
|
=> 'minimal stow of a simple tree'
|
|
|
|
);
|
|
|
|
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
|
|
|
make_dir('../stow/pkg2/lib2');
|
|
|
|
make_file('../stow/pkg2/lib2/file2');
|
|
|
|
make_dir('lib2');
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow->plan_stow('pkg2');
|
|
|
|
$stow->process_tasks();
|
2011-11-16 09:04:03 -05:00
|
|
|
is(
|
|
|
|
readlink('lib2/file2'),
|
|
|
|
'../../stow/pkg2/lib2/file2',
|
|
|
|
=> 'stow simple tree to existing directory'
|
|
|
|
);
|
|
|
|
|
|
|
|
#
|
|
|
|
# unfold existing tree
|
|
|
|
#
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow = new_Stow();
|
2011-11-16 09:04:03 -05:00
|
|
|
|
|
|
|
make_dir('../stow/pkg3a/bin3');
|
|
|
|
make_file('../stow/pkg3a/bin3/file3a');
|
|
|
|
make_link('bin3' => '../stow/pkg3a/bin3'); # emulate stow
|
|
|
|
|
|
|
|
make_dir('../stow/pkg3b/bin3');
|
|
|
|
make_file('../stow/pkg3b/bin3/file3b');
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow->plan_stow('pkg3b');
|
|
|
|
$stow->process_tasks();
|
2011-11-16 09:04:03 -05:00
|
|
|
ok(
|
|
|
|
-d 'bin3' &&
|
|
|
|
readlink('bin3/file3a') eq '../../stow/pkg3a/bin3/file3a' &&
|
|
|
|
readlink('bin3/file3b') eq '../../stow/pkg3b/bin3/file3b'
|
|
|
|
=> 'target already has 1 stowed package'
|
|
|
|
);
|
|
|
|
|
|
|
|
#
|
2011-11-24 11:28:09 -05:00
|
|
|
# Link to a new dir conflicts with existing non-dir (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
|
|
|
|
make_dir('../stow/pkg4/bin4');
|
|
|
|
make_file('../stow/pkg4/bin4/file4');
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow->plan_stow('pkg4');
|
|
|
|
@conflicts = $stow->get_conflicts();
|
|
|
|
like(
|
|
|
|
$conflicts[-1], qr(CONFLICT:.*existing target is neither a link nor a directory)
|
2011-11-16 09:04:03 -05:00
|
|
|
=> 'link to new dir conflicts with existing non-directory'
|
|
|
|
);
|
|
|
|
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
|
|
|
make_dir('bin5');
|
|
|
|
make_link('bin5/file5','../../empty');
|
|
|
|
make_dir('../stow/pkg5/bin5/file5');
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow->plan_stow('pkg5');
|
|
|
|
@conflicts = $stow->get_conflicts();
|
2011-11-16 09:04:03 -05:00
|
|
|
like(
|
2011-11-24 11:28:09 -05:00
|
|
|
$conflicts[-1], qr(CONFLICT:.*not owned by stow)
|
2011-11-16 09:04:03 -05:00
|
|
|
=> 'target already exists but is not owned by stow'
|
|
|
|
);
|
|
|
|
|
|
|
|
#
|
|
|
|
# Replace existing but invalid target
|
|
|
|
#
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow = new_Stow();
|
2011-11-16 09:04:03 -05:00
|
|
|
|
|
|
|
make_link('file6','../stow/path-does-not-exist');
|
|
|
|
make_dir('../stow/pkg6');
|
|
|
|
make_file('../stow/pkg6/file6');
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow->plan_stow('pkg6');
|
|
|
|
$stow->process_tasks();
|
2011-11-16 09:04:03 -05:00
|
|
|
is(
|
|
|
|
readlink('file6'),
|
|
|
|
'../stow/pkg6/file6'
|
|
|
|
=> '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();
|
2011-11-16 09:04:03 -05:00
|
|
|
|
|
|
|
make_dir('bin7');
|
|
|
|
make_dir('../stow/pkg7a/bin7');
|
|
|
|
make_file('../stow/pkg7a/bin7/node7');
|
|
|
|
make_link('bin7/node7','../../stow/pkg7a/bin7/node7');
|
|
|
|
make_dir('../stow/pkg7b/bin7/node7');
|
|
|
|
make_file('../stow/pkg7b/bin7/node7/file7');
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow->plan_stow('pkg7b');
|
|
|
|
@conflicts = $stow->get_conflicts();
|
|
|
|
like(
|
|
|
|
$conflicts[-1], qr(CONFLICT:.*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
|
|
|
|
|
|
|
make_dir('../stow/pkg8a/0');
|
|
|
|
make_file('../stow/pkg8a/0/file8a');
|
|
|
|
make_link('0' => '../stow/pkg8a/0'); # emulate stow
|
|
|
|
|
|
|
|
make_dir('../stow/pkg8b/0');
|
|
|
|
make_file('../stow/pkg8b/0/file8b');
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow->plan_stow('pkg8b');
|
|
|
|
$stow->process_tasks();
|
2011-11-16 09:04:03 -05:00
|
|
|
ok(
|
2011-11-24 11:28:09 -05:00
|
|
|
scalar($stow->get_conflicts) == 0 &&
|
2011-11-16 09:04:03 -05:00
|
|
|
-d '0' &&
|
|
|
|
readlink('0/file8a') eq '../../stow/pkg8a/0/file8a' &&
|
|
|
|
readlink('0/file8b') eq '../../stow/pkg8b/0/file8b'
|
|
|
|
=> '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
|
|
|
|
|
|
|
make_dir('../stow/pkg9a/man9/man1');
|
|
|
|
make_file('../stow/pkg9a/man9/man1/file9.1');
|
|
|
|
make_dir('man9/man1');
|
|
|
|
make_link('man9/man1/file9.1' => '../../../stow/pkg9a/man9/man1/file9.1'); # emulate stow
|
|
|
|
|
|
|
|
make_dir('../stow/pkg9b/man9/man1');
|
|
|
|
make_file('../stow/pkg9b/man9/man1/file9.1');
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow->plan_stow('pkg9b');
|
|
|
|
$stow->process_tasks();
|
2011-11-16 09:04:03 -05:00
|
|
|
ok(
|
2011-11-24 11:28:09 -05:00
|
|
|
scalar($stow->get_conflicts) == 0 &&
|
2011-11-16 09:04:03 -05:00
|
|
|
readlink('man9/man1/file9.1') eq '../../../stow/pkg9b/man9/man1/file9.1'
|
|
|
|
=> '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
|
|
|
|
|
|
|
make_dir('../stow/pkg10a/man10/man1');
|
|
|
|
make_file('../stow/pkg10a/man10/man1/file10.1');
|
|
|
|
make_dir('man10/man1');
|
|
|
|
make_link('man10/man1/file10.1' => '../../../stow/pkg10a/man10/man1/file10.1'); # emulate stow
|
|
|
|
|
|
|
|
make_dir('../stow/pkg10b/man10/man1');
|
|
|
|
make_file('../stow/pkg10b/man10/man1/file10.1');
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow->plan_stow('pkg10b');
|
|
|
|
|
2011-11-16 10:16:53 -05:00
|
|
|
stderr_like(
|
2011-11-24 11:28:09 -05:00
|
|
|
sub { $stow->process_tasks(); },
|
2011-11-16 10:16:53 -05:00
|
|
|
qr/There are no outstanding operations to perform/,
|
|
|
|
'no tasks to process'
|
|
|
|
);
|
2011-11-16 09:04:03 -05:00
|
|
|
ok(
|
2011-11-24 11:28:09 -05:00
|
|
|
scalar($stow->get_conflicts) == 0 &&
|
2011-11-16 09:04:03 -05:00
|
|
|
readlink('man10/man1/file10.1') eq '../../../stow/pkg10a/man10/man1/file10.1'
|
|
|
|
=> '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
|
|
|
|
|
|
|
make_dir('../stow/pkg11/man11/man1');
|
|
|
|
make_file('../stow/pkg11/man11/man1/file11.1');
|
|
|
|
make_file('../stow/pkg11/man11/man1/file11.1~');
|
|
|
|
make_file('../stow/pkg11/man11/man1/.#file11.1');
|
|
|
|
make_dir('man11/man1');
|
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow->plan_stow('pkg11');
|
|
|
|
$stow->process_tasks();
|
2011-11-16 09:04:03 -05:00
|
|
|
ok(
|
2011-11-24 11:28:09 -05:00
|
|
|
scalar($stow->get_conflicts) == 0 &&
|
2011-11-16 09:04:03 -05:00
|
|
|
readlink('man11/man1/file11.1') eq '../../../stow/pkg11/man11/man1/file11.1' &&
|
|
|
|
!-e 'man11/man1/file11.1~' &&
|
|
|
|
!-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
|
|
|
|
|
|
|
make_dir('../stow/pkg12/lib12/');
|
|
|
|
make_file('../stow/pkg12/lib12/lib.so');
|
|
|
|
make_link('../stow/pkg12/lib12/lib.so.1','lib.so');
|
|
|
|
|
|
|
|
make_dir('lib12/');
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow->plan_stow('pkg12');
|
|
|
|
$stow->process_tasks();
|
2011-11-16 09:04:03 -05:00
|
|
|
ok(
|
2011-11-24 11:28:09 -05:00
|
|
|
scalar($stow->get_conflicts) == 0 &&
|
2011-11-16 09:04:03 -05:00
|
|
|
readlink('lib12/lib.so.1') eq '../../stow/pkg12/lib12/lib.so.1'
|
|
|
|
=> '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
|
|
|
|
|
|
|
make_dir('../stow/pkg13a/lib13/');
|
|
|
|
make_file('../stow/pkg13a/lib13/liba.so');
|
|
|
|
make_link('../stow/pkg13a/lib13/liba.so.1', 'liba.so');
|
|
|
|
make_link('lib13','../stow/pkg13a/lib13');
|
|
|
|
|
|
|
|
make_dir('../stow/pkg13b/lib13/');
|
|
|
|
make_file('../stow/pkg13b/lib13/libb.so');
|
|
|
|
make_link('../stow/pkg13b/lib13/libb.so.1', 'libb.so');
|
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow->plan_stow('pkg13b');
|
|
|
|
$stow->process_tasks();
|
2011-11-16 09:04:03 -05:00
|
|
|
ok(
|
2011-11-24 11:28:09 -05:00
|
|
|
scalar($stow->get_conflicts) == 0 &&
|
2011-11-16 09:04:03 -05:00
|
|
|
readlink('lib13/liba.so.1') eq '../../stow/pkg13a/lib13/liba.so.1' &&
|
|
|
|
readlink('lib13/libb.so.1') eq '../../stow/pkg13b/lib13/libb.so.1'
|
|
|
|
=> 'unfolding to stow links to libraries'
|
|
|
|
);
|
2011-11-18 05:48:48 -05:00
|
|
|
|
|
|
|
#
|
|
|
|
# stowing to stow dir should fail
|
|
|
|
#
|
2011-11-24 11:28:09 -05:00
|
|
|
make_dir('stow');
|
|
|
|
$stow = new_Stow(dir => 'stow');
|
2011-11-18 05:48:48 -05:00
|
|
|
|
|
|
|
make_dir('stow/pkg14/stow/pkg15');
|
|
|
|
make_file('stow/pkg14/stow/pkg15/node15');
|
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
$stow->plan_stow('pkg14');
|
2011-11-18 05:48:48 -05:00
|
|
|
stderr_like(
|
2011-11-24 11:28:09 -05:00
|
|
|
sub { $stow->process_tasks(); },
|
2011-11-18 05:48:48 -05:00
|
|
|
qr/There are no outstanding operations to perform/,
|
|
|
|
'no tasks to process'
|
|
|
|
);
|
|
|
|
ok(
|
2011-11-24 11:28:09 -05:00
|
|
|
scalar($stow->get_conflicts) == 0 &&
|
2011-11-18 05:48:48 -05:00
|
|
|
! -l 'stow/pkg15'
|
|
|
|
=> "stowing to stow dir should fail"
|
|
|
|
);
|
2011-11-24 11:28:09 -05:00
|
|
|
|
|
|
|
#
|
|
|
|
# stow a simple tree minimally when cwd isn't target
|
|
|
|
#
|
|
|
|
cd('../..');
|
|
|
|
$stow = new_Stow(dir => 't/stow', target => 't/target');
|
|
|
|
|
|
|
|
make_dir('t/stow/pkg16/bin16');
|
|
|
|
make_file('t/stow/pkg16/bin16/file16');
|
|
|
|
|
|
|
|
$stow->plan_stow('pkg16');
|
|
|
|
$stow->process_tasks();
|
|
|
|
is($stow->get_conflicts(), 0, 'no conflicts with minimal stow');
|
|
|
|
is(
|
|
|
|
readlink('t/target/bin16'),
|
|
|
|
'../stow/pkg16/bin16',
|
|
|
|
=> 'minimal stow of a simple tree'
|
|
|
|
);
|