t/stow: convert to subtests()
This commit is contained in:
parent
0871a483cf
commit
a328c2cd4b
1 changed files with 434 additions and 450 deletions
242
t/stow.t
242
t/stow.t
|
@ -22,7 +22,7 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Test::More tests => 118;
|
||||
use Test::More tests => 21;
|
||||
use Test::Output;
|
||||
use English qw(-no_match_vars);
|
||||
|
||||
|
@ -37,10 +37,9 @@ my %conflicts;
|
|||
|
||||
# Note that each of the following tests use a distinct set of files
|
||||
|
||||
#
|
||||
# stow a simple tree minimally
|
||||
#
|
||||
$stow = new_Stow(dir => '../stow');
|
||||
subtest('stow a simple tree minimally', sub {
|
||||
plan tests => 2;
|
||||
my $stow = new_Stow(dir => '../stow');
|
||||
|
||||
make_path('../stow/pkg1/bin1');
|
||||
make_file('../stow/pkg1/bin1/file1');
|
||||
|
@ -53,11 +52,11 @@ is(
|
|||
'../stow/pkg1/bin1',
|
||||
=> 'minimal stow of a simple tree'
|
||||
);
|
||||
});
|
||||
|
||||
#
|
||||
# stow a simple tree into an existing directory
|
||||
#
|
||||
$stow = new_Stow();
|
||||
subtest('stow a simple tree into an existing directory', sub {
|
||||
plan tests => 1;
|
||||
my $stow = new_Stow();
|
||||
|
||||
make_path('../stow/pkg2/lib2');
|
||||
make_file('../stow/pkg2/lib2/file2');
|
||||
|
@ -70,11 +69,11 @@ is(
|
|||
'../../stow/pkg2/lib2/file2',
|
||||
=> 'stow simple tree to existing directory'
|
||||
);
|
||||
});
|
||||
|
||||
#
|
||||
# unfold existing tree
|
||||
#
|
||||
$stow = new_Stow();
|
||||
subtest('unfold existing tree', sub {
|
||||
plan tests => 3;
|
||||
my $stow = new_Stow();
|
||||
|
||||
make_path('../stow/pkg3a/bin3');
|
||||
make_file('../stow/pkg3a/bin3/file3a');
|
||||
|
@ -85,18 +84,15 @@ make_file('../stow/pkg3b/bin3/file3b');
|
|||
|
||||
$stow->plan_stow('pkg3b');
|
||||
$stow->process_tasks();
|
||||
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'
|
||||
);
|
||||
ok(-d 'bin3');
|
||||
is(readlink('bin3/file3a'), '../../stow/pkg3a/bin3/file3a');
|
||||
is(readlink('bin3/file3b'), '../../stow/pkg3b/bin3/file3b'
|
||||
=> 'target already has 1 stowed package');
|
||||
});
|
||||
|
||||
#
|
||||
# Link to a new dir 'bin4' conflicts with existing non-dir so can't
|
||||
# unfold
|
||||
#
|
||||
$stow = new_Stow();
|
||||
subtest("Link to a new dir 'bin4' conflicts with existing non-dir so can't unfold", sub {
|
||||
plan tests => 2;
|
||||
my $stow = new_Stow();
|
||||
|
||||
make_file('bin4'); # this is a file but named like a directory
|
||||
make_path('../stow/pkg4/bin4');
|
||||
|
@ -104,19 +100,18 @@ make_file('../stow/pkg4/bin4/file4');
|
|||
|
||||
$stow->plan_stow('pkg4');
|
||||
%conflicts = $stow->get_conflicts();
|
||||
ok(
|
||||
$stow->get_conflict_count == 1 &&
|
||||
$conflicts{stow}{pkg4}[0] =~
|
||||
is($stow->get_conflict_count, 1);
|
||||
ok($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();
|
||||
subtest("Link to a new dir 'bin4a' conflicts with existing non-dir " .
|
||||
"so can't unfold even with --adopt", sub {
|
||||
plan tests => 2;
|
||||
#my $stow = new_Stow(adopt => 1);
|
||||
my $stow = new_Stow();
|
||||
|
||||
make_file('bin4a'); # this is a file but named like a directory
|
||||
make_path('../stow/pkg4a/bin4a');
|
||||
|
@ -124,18 +119,16 @@ make_file('../stow/pkg4a/bin4a/file4a');
|
|||
|
||||
$stow->plan_stow('pkg4a');
|
||||
%conflicts = $stow->get_conflicts();
|
||||
ok(
|
||||
$stow->get_conflict_count == 1 &&
|
||||
$conflicts{stow}{pkg4a}[0] =~
|
||||
is($stow->get_conflict_count, 1);
|
||||
like($conflicts{stow}{pkg4a}[0],
|
||||
qr/existing target is neither a link nor a directory/
|
||||
=> 'link to new dir bin4a conflicts with existing non-directory'
|
||||
);
|
||||
});
|
||||
|
||||
#
|
||||
# Link to files 'file4b' and 'bin4b' conflict with existing files
|
||||
# without --adopt
|
||||
#
|
||||
$stow = new_Stow();
|
||||
subtest("Link to files 'file4b' and 'bin4b' conflict with existing files", sub {
|
||||
plan tests => 3;
|
||||
my $stow = new_Stow();
|
||||
|
||||
# Populate target
|
||||
make_file('file4b', 'file4b - version originally in target');
|
||||
|
@ -157,12 +150,11 @@ for my $i (0, 1) {
|
|||
=> '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);
|
||||
subtest("Link to files 'file4b' and 'bin4b' do not conflict with existing", sub {
|
||||
plan tests => 8;
|
||||
my $stow = new_Stow(adopt => 1);
|
||||
|
||||
# Populate target
|
||||
make_file('file4c', "file4c - version originally in target\n");
|
||||
|
@ -188,11 +180,11 @@ for my $file ('file4c', 'bin4c/file4c') {
|
|||
is(cat_file($file), "$file - version originally in target\n" => "$file has right contents");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
#
|
||||
# Target already exists but is not owned by stow
|
||||
#
|
||||
$stow = new_Stow();
|
||||
subtest("Target already exists but is not owned by stow", sub {
|
||||
plan tests => 1;
|
||||
my $stow = new_Stow();
|
||||
|
||||
make_path('bin5');
|
||||
make_invalid_link('bin5/file5','../../empty');
|
||||
|
@ -205,11 +197,11 @@ like(
|
|||
qr/not owned by stow/
|
||||
=> 'target already exists but is not owned by stow'
|
||||
);
|
||||
});
|
||||
|
||||
#
|
||||
# Replace existing but invalid target
|
||||
#
|
||||
$stow = new_Stow();
|
||||
subtest("Replace existing but invalid target", sub {
|
||||
plan tests => 1;
|
||||
my $stow = new_Stow();
|
||||
|
||||
make_invalid_link('file6','../stow/path-does-not-exist');
|
||||
make_path('../stow/pkg6');
|
||||
|
@ -222,12 +214,11 @@ is(
|
|||
'../stow/pkg6/file6'
|
||||
=> 'replace existing but invalid target'
|
||||
);
|
||||
});
|
||||
|
||||
#
|
||||
# Target already exists, is owned by stow, but points to a non-directory
|
||||
# (can't unfold)
|
||||
#
|
||||
$stow = new_Stow();
|
||||
subtest("Target already exists, is owned by stow, but points to a non-directory", sub {
|
||||
plan tests => 1;
|
||||
my $stow = new_Stow();
|
||||
#set_debug_level(4);
|
||||
|
||||
make_path('bin7');
|
||||
|
@ -244,11 +235,11 @@ like(
|
|||
qr/existing target is stowed to a different package/
|
||||
=> 'link to new dir conflicts with existing stowed non-directory'
|
||||
);
|
||||
});
|
||||
|
||||
#
|
||||
# stowing directories named 0
|
||||
#
|
||||
$stow = new_Stow();
|
||||
subtest("stowing directories named 0", sub {
|
||||
plan tests => 4;
|
||||
my $stow = new_Stow();
|
||||
|
||||
make_path('../stow/pkg8a/0');
|
||||
make_file('../stow/pkg8a/0/file8a');
|
||||
|
@ -259,18 +250,17 @@ make_file('../stow/pkg8b/0/file8b');
|
|||
|
||||
$stow->plan_stow('pkg8b');
|
||||
$stow->process_tasks();
|
||||
ok(
|
||||
$stow->get_conflict_count == 0 &&
|
||||
-d '0' &&
|
||||
readlink('0/file8a') eq '../../stow/pkg8a/0/file8a' &&
|
||||
readlink('0/file8b') eq '../../stow/pkg8b/0/file8b'
|
||||
is($stow->get_conflict_count, 0);
|
||||
ok(-d '0');
|
||||
is(readlink('0/file8a'), '../../stow/pkg8a/0/file8a');
|
||||
is(readlink('0/file8b'), '../../stow/pkg8b/0/file8b'
|
||||
=> 'stowing directories named 0'
|
||||
);
|
||||
});
|
||||
|
||||
#
|
||||
# overriding already stowed documentation
|
||||
#
|
||||
$stow = new_Stow(override => ['man9', 'info9']);
|
||||
subtest("overriding already stowed documentation", sub {
|
||||
plan tests => 2;
|
||||
my $stow = new_Stow(override => ['man9', 'info9']);
|
||||
|
||||
make_path('../stow/pkg9a/man9/man1');
|
||||
make_file('../stow/pkg9a/man9/man1/file9.1');
|
||||
|
@ -282,16 +272,15 @@ make_file('../stow/pkg9b/man9/man1/file9.1');
|
|||
|
||||
$stow->plan_stow('pkg9b');
|
||||
$stow->process_tasks();
|
||||
ok(
|
||||
$stow->get_conflict_count == 0 &&
|
||||
readlink('man9/man1/file9.1') eq '../../../stow/pkg9b/man9/man1/file9.1'
|
||||
is($stow->get_conflict_count, 0);
|
||||
is(readlink('man9/man1/file9.1'), '../../../stow/pkg9b/man9/man1/file9.1'
|
||||
=> 'overriding existing documentation files'
|
||||
);
|
||||
});
|
||||
|
||||
#
|
||||
# deferring to already stowed documentation
|
||||
#
|
||||
$stow = new_Stow(defer => ['man10', 'info10']);
|
||||
subtest("deferring to already stowed documentation", sub {
|
||||
plan tests => 3;
|
||||
my $stow = new_Stow(defer => ['man10', 'info10']);
|
||||
|
||||
make_path('../stow/pkg10a/man10/man1');
|
||||
make_file('../stow/pkg10a/man10/man1/file10.1');
|
||||
|
@ -303,16 +292,15 @@ make_file('../stow/pkg10b/man10/man1/file10.1');
|
|||
|
||||
$stow->plan_stow('pkg10b');
|
||||
is($stow->get_tasks, 0, 'no tasks to process');
|
||||
ok(
|
||||
$stow->get_conflict_count == 0 &&
|
||||
readlink('man10/man1/file10.1') eq '../../../stow/pkg10a/man10/man1/file10.1'
|
||||
is($stow->get_conflict_count, 0);
|
||||
is(readlink('man10/man1/file10.1'), '../../../stow/pkg10a/man10/man1/file10.1'
|
||||
=> 'defer to existing documentation files'
|
||||
);
|
||||
});
|
||||
|
||||
#
|
||||
# Ignore temp files
|
||||
#
|
||||
$stow = new_Stow(ignore => ['~', '\.#.*']);
|
||||
subtest("Ignore temp files", sub {
|
||||
plan tests => 4;
|
||||
my $stow = new_Stow(ignore => ['~', '\.#.*']);
|
||||
|
||||
make_path('../stow/pkg11/man11/man1');
|
||||
make_file('../stow/pkg11/man11/man1/file11.1');
|
||||
|
@ -322,18 +310,17 @@ make_path('man11/man1');
|
|||
|
||||
$stow->plan_stow('pkg11');
|
||||
$stow->process_tasks();
|
||||
ok(
|
||||
$stow->get_conflict_count == 0 &&
|
||||
readlink('man11/man1/file11.1') eq '../../../stow/pkg11/man11/man1/file11.1' &&
|
||||
!-e 'man11/man1/file11.1~' &&
|
||||
!-e 'man11/man1/.#file11.1'
|
||||
is($stow->get_conflict_count, 0);
|
||||
is(readlink('man11/man1/file11.1'), '../../../stow/pkg11/man11/man1/file11.1');
|
||||
ok(!-e 'man11/man1/file11.1~');
|
||||
ok(!-e 'man11/man1/.#file11.1'
|
||||
=> 'ignore temp files'
|
||||
);
|
||||
});
|
||||
|
||||
#
|
||||
# stowing links library files
|
||||
#
|
||||
$stow = new_Stow();
|
||||
subtest("stowing links library files", sub {
|
||||
plan tests => 3;
|
||||
my $stow = new_Stow();
|
||||
|
||||
make_path('../stow/pkg12/lib12/');
|
||||
make_file('../stow/pkg12/lib12/lib.so.1');
|
||||
|
@ -343,17 +330,16 @@ make_path('lib12/');
|
|||
|
||||
$stow->plan_stow('pkg12');
|
||||
$stow->process_tasks();
|
||||
ok(
|
||||
$stow->get_conflict_count == 0 &&
|
||||
readlink('lib12/lib.so.1') eq '../../stow/pkg12/lib12/lib.so.1' &&
|
||||
readlink('lib12/lib.so' ) eq '../../stow/pkg12/lib12/lib.so'
|
||||
is($stow->get_conflict_count, 0);
|
||||
is(readlink('lib12/lib.so.1'), '../../stow/pkg12/lib12/lib.so.1');
|
||||
is(readlink('lib12/lib.so'), '../../stow/pkg12/lib12/lib.so'
|
||||
=> 'stow links to libraries'
|
||||
);
|
||||
});
|
||||
|
||||
#
|
||||
# unfolding to stow links to library files
|
||||
#
|
||||
$stow = new_Stow();
|
||||
subtest("unfolding to stow links to library files", sub {
|
||||
plan tests => 5;
|
||||
my $stow = new_Stow();
|
||||
|
||||
make_path('../stow/pkg13a/lib13/');
|
||||
make_file('../stow/pkg13a/lib13/liba.so.1');
|
||||
|
@ -366,18 +352,17 @@ make_link('../stow/pkg13b/lib13/libb.so', 'libb.so.1');
|
|||
|
||||
$stow->plan_stow('pkg13b');
|
||||
$stow->process_tasks();
|
||||
ok(
|
||||
$stow->get_conflict_count == 0 &&
|
||||
readlink('lib13/liba.so.1') eq '../../stow/pkg13a/lib13/liba.so.1' &&
|
||||
readlink('lib13/liba.so' ) eq '../../stow/pkg13a/lib13/liba.so' &&
|
||||
readlink('lib13/libb.so.1') eq '../../stow/pkg13b/lib13/libb.so.1' &&
|
||||
readlink('lib13/libb.so' ) eq '../../stow/pkg13b/lib13/libb.so'
|
||||
is($stow->get_conflict_count, 0);
|
||||
is(readlink('lib13/liba.so.1'), '../../stow/pkg13a/lib13/liba.so.1');
|
||||
is(readlink('lib13/liba.so' ), '../../stow/pkg13a/lib13/liba.so');
|
||||
is(readlink('lib13/libb.so.1'), '../../stow/pkg13b/lib13/libb.so.1');
|
||||
is(readlink('lib13/libb.so' ), '../../stow/pkg13b/lib13/libb.so'
|
||||
=> 'unfolding to stow links to libraries'
|
||||
);
|
||||
});
|
||||
|
||||
#
|
||||
# stowing to stow dir should fail
|
||||
#
|
||||
subtest("stowing to stow dir should fail", sub {
|
||||
plan tests => 4;
|
||||
make_path('stow');
|
||||
$stow = new_Stow(dir => 'stow');
|
||||
|
||||
|
@ -387,8 +372,8 @@ make_file('stow/pkg14/stow/pkg15/node15');
|
|||
capture_stderr();
|
||||
$stow->plan_stow('pkg14');
|
||||
is($stow->get_tasks, 0, 'no tasks to process');
|
||||
is($stow->get_conflict_count, 0);
|
||||
ok(
|
||||
$stow->get_conflict_count == 0 &&
|
||||
! -l 'stow/pkg15'
|
||||
=> "stowing to stow dir should fail"
|
||||
);
|
||||
|
@ -396,10 +381,10 @@ like($stderr,
|
|||
qr/WARNING: skipping target which was current stow directory stow/
|
||||
=> "stowing to stow dir should give warning");
|
||||
uncapture_stderr();
|
||||
});
|
||||
|
||||
#
|
||||
# stow a simple tree minimally when cwd isn't target
|
||||
#
|
||||
subtest("stow a simple tree minimally when cwd isn't target", sub {
|
||||
plan tests => 2;
|
||||
cd('../..');
|
||||
$stow = new_Stow(dir => "$TEST_DIR/stow", target => "$TEST_DIR/target");
|
||||
|
||||
|
@ -414,12 +399,11 @@ is(
|
|||
'../stow/pkg16/bin16',
|
||||
=> "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
|
||||
#
|
||||
$stow = new_Stow(dir => canon_path("$TEST_DIR/stow"),
|
||||
subtest("stow a simple tree minimally to absolute stow dir when cwd isn't", sub {
|
||||
plan tests => 2;
|
||||
my $stow = new_Stow(dir => canon_path("$TEST_DIR/stow"),
|
||||
target => "$TEST_DIR/target");
|
||||
|
||||
make_path("$TEST_DIR/stow/pkg17/bin17");
|
||||
|
@ -433,12 +417,11 @@ is(
|
|||
'../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
|
||||
#
|
||||
$stow = new_Stow(dir => canon_path("$TEST_DIR/stow"),
|
||||
subtest("stow a simple tree minimally with absolute stow AND target dirs when", sub {
|
||||
plan tests => 2;
|
||||
my $stow = new_Stow(dir => canon_path("$TEST_DIR/stow"),
|
||||
target => canon_path("$TEST_DIR/target"));
|
||||
|
||||
make_path("$TEST_DIR/stow/pkg18/bin18");
|
||||
|
@ -452,10 +435,10 @@ is(
|
|||
'../stow/pkg18/bin18',
|
||||
=> "minimal stow of a simple tree with absolute stow and target dirs"
|
||||
);
|
||||
});
|
||||
|
||||
#
|
||||
# stow a tree with no-folding enabled -
|
||||
# no new folded directories should be created, and existing
|
||||
subtest("stow a tree with no-folding enabled", sub {
|
||||
plan tests => 82;
|
||||
# folded directories should be split open (unfolded) where
|
||||
# (and only where) necessary
|
||||
#
|
||||
|
@ -554,3 +537,4 @@ $stow->process_tasks();
|
|||
|
||||
check_no_folding('a');
|
||||
check_no_folding('b');
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue