t/unstow_orig: split into subtests
This commit is contained in:
parent
6cf41850b3
commit
2c255af187
1 changed files with 285 additions and 306 deletions
591
t/unstow_orig.t
591
t/unstow_orig.t
|
@ -23,7 +23,7 @@ use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use File::Spec qw(make_path);
|
use File::Spec qw(make_path);
|
||||||
use Test::More tests => 37;
|
use Test::More tests => 17;
|
||||||
use Test::Output;
|
use Test::Output;
|
||||||
use English qw(-no_match_vars);
|
use English qw(-no_match_vars);
|
||||||
|
|
||||||
|
@ -38,366 +38,345 @@ cd("$TEST_DIR/target");
|
||||||
my $stow;
|
my $stow;
|
||||||
my %conflicts;
|
my %conflicts;
|
||||||
|
|
||||||
#
|
subtest("unstow a simple tree minimally", sub {
|
||||||
# unstow a simple tree minimally
|
plan tests => 3;
|
||||||
#
|
my $stow = new_compat_Stow();
|
||||||
|
|
||||||
$stow = new_compat_Stow();
|
make_path('../stow/pkg1/bin1');
|
||||||
|
make_file('../stow/pkg1/bin1/file1');
|
||||||
|
make_link('bin1', '../stow/pkg1/bin1');
|
||||||
|
|
||||||
make_path('../stow/pkg1/bin1');
|
$stow->plan_unstow('pkg1');
|
||||||
make_file('../stow/pkg1/bin1/file1');
|
$stow->process_tasks();
|
||||||
make_link('bin1', '../stow/pkg1/bin1');
|
is($stow->get_conflict_count, 0);
|
||||||
|
ok(-f '../stow/pkg1/bin1/file1');
|
||||||
|
ok(! -e 'bin1' => 'unstow a simple tree');
|
||||||
|
});
|
||||||
|
|
||||||
$stow->plan_unstow('pkg1');
|
subtest("unstow a simple tree from an existing directory", sub {
|
||||||
$stow->process_tasks();
|
plan tests => 3;
|
||||||
ok(
|
my $stow = new_compat_Stow();
|
||||||
$stow->get_conflict_count == 0 &&
|
|
||||||
-f '../stow/pkg1/bin1/file1' && ! -e 'bin1'
|
|
||||||
=> 'unstow a simple tree'
|
|
||||||
);
|
|
||||||
|
|
||||||
#
|
make_path('lib2');
|
||||||
# unstow a simple tree from an existing directory
|
make_path('../stow/pkg2/lib2');
|
||||||
#
|
make_file('../stow/pkg2/lib2/file2');
|
||||||
$stow = new_compat_Stow();
|
make_link('lib2/file2', '../../stow/pkg2/lib2/file2');
|
||||||
|
$stow->plan_unstow('pkg2');
|
||||||
|
$stow->process_tasks();
|
||||||
|
is($stow->get_conflict_count, 0);
|
||||||
|
ok(-f '../stow/pkg2/lib2/file2');
|
||||||
|
ok(-d 'lib2'
|
||||||
|
=> 'unstow simple tree from a pre-existing directory'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
make_path('lib2');
|
subtest("fold tree after unstowing", sub {
|
||||||
make_path('../stow/pkg2/lib2');
|
plan tests => 3;
|
||||||
make_file('../stow/pkg2/lib2/file2');
|
my $stow = new_compat_Stow();
|
||||||
make_link('lib2/file2', '../../stow/pkg2/lib2/file2');
|
|
||||||
$stow->plan_unstow('pkg2');
|
|
||||||
$stow->process_tasks();
|
|
||||||
ok(
|
|
||||||
$stow->get_conflict_count == 0 &&
|
|
||||||
-f '../stow/pkg2/lib2/file2' && -d 'lib2'
|
|
||||||
=> 'unstow simple tree from a pre-existing directory'
|
|
||||||
);
|
|
||||||
|
|
||||||
#
|
make_path('bin3');
|
||||||
# fold tree after unstowing
|
|
||||||
#
|
|
||||||
$stow = new_compat_Stow();
|
|
||||||
|
|
||||||
make_path('bin3');
|
make_path('../stow/pkg3a/bin3');
|
||||||
|
make_file('../stow/pkg3a/bin3/file3a');
|
||||||
|
make_link('bin3/file3a' => '../../stow/pkg3a/bin3/file3a'); # emulate stow
|
||||||
|
|
||||||
make_path('../stow/pkg3a/bin3');
|
make_path('../stow/pkg3b/bin3');
|
||||||
make_file('../stow/pkg3a/bin3/file3a');
|
make_file('../stow/pkg3b/bin3/file3b');
|
||||||
make_link('bin3/file3a' => '../../stow/pkg3a/bin3/file3a'); # emulate stow
|
make_link('bin3/file3b' => '../../stow/pkg3b/bin3/file3b'); # emulate stow
|
||||||
|
$stow->plan_unstow('pkg3b');
|
||||||
|
$stow->process_tasks();
|
||||||
|
is($stow->get_conflict_count, 0);
|
||||||
|
ok(-l 'bin3');
|
||||||
|
is(readlink('bin3'), '../stow/pkg3a/bin3'
|
||||||
|
=> 'fold tree after unstowing'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
make_path('../stow/pkg3b/bin3');
|
subtest("existing link is owned by stow but is invalid so it gets removed anyway", sub {
|
||||||
make_file('../stow/pkg3b/bin3/file3b');
|
plan tests => 2;
|
||||||
make_link('bin3/file3b' => '../../stow/pkg3b/bin3/file3b'); # emulate stow
|
my $stow = new_compat_Stow();
|
||||||
$stow->plan_unstow('pkg3b');
|
|
||||||
$stow->process_tasks();
|
|
||||||
ok(
|
|
||||||
$stow->get_conflict_count == 0 &&
|
|
||||||
-l 'bin3' &&
|
|
||||||
readlink('bin3') eq '../stow/pkg3a/bin3'
|
|
||||||
=> 'fold tree after unstowing'
|
|
||||||
);
|
|
||||||
|
|
||||||
#
|
make_path('bin4');
|
||||||
# existing link is owned by stow but is invalid so it gets removed anyway
|
make_path('../stow/pkg4/bin4');
|
||||||
#
|
make_file('../stow/pkg4/bin4/file4');
|
||||||
$stow = new_compat_Stow();
|
make_invalid_link('bin4/file4', '../../stow/pkg4/bin4/does-not-exist');
|
||||||
|
|
||||||
make_path('bin4');
|
$stow->plan_unstow('pkg4');
|
||||||
make_path('../stow/pkg4/bin4');
|
$stow->process_tasks();
|
||||||
make_file('../stow/pkg4/bin4/file4');
|
is($stow->get_conflict_count, 0);
|
||||||
make_invalid_link('bin4/file4', '../../stow/pkg4/bin4/does-not-exist');
|
ok(! -e 'bin4/file4'
|
||||||
|
=> q(remove invalid link owned by stow)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
$stow->plan_unstow('pkg4');
|
subtest("Existing link is not owned by stow", sub {
|
||||||
$stow->process_tasks();
|
plan tests => 2;
|
||||||
ok(
|
my $stow = new_compat_Stow();
|
||||||
$stow->get_conflict_count == 0 &&
|
|
||||||
! -e 'bin4/file4'
|
|
||||||
=> q(remove invalid link owned by stow)
|
|
||||||
);
|
|
||||||
|
|
||||||
#
|
make_path('../stow/pkg5/bin5');
|
||||||
# Existing link is not owned by stow
|
make_invalid_link('bin5', '../not-stow');
|
||||||
#
|
|
||||||
$stow = new_compat_Stow();
|
|
||||||
|
|
||||||
make_path('../stow/pkg5/bin5');
|
$stow->plan_unstow('pkg5');
|
||||||
make_invalid_link('bin5', '../not-stow');
|
# Unlike the corresponding stow_contents.t test, this doesn't
|
||||||
|
# cause any conflicts.
|
||||||
|
#
|
||||||
|
#like(
|
||||||
|
# $Conflicts[-1], qr(can't unlink.*not owned by stow)
|
||||||
|
# => q(existing link not owned by stow)
|
||||||
|
#);
|
||||||
|
ok(-l 'bin5');
|
||||||
|
ok(readlink('bin5') eq '../not-stow'
|
||||||
|
=> q(existing link not owned by stow)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
$stow->plan_unstow('pkg5');
|
subtest("Target already exists, is owned by stow, but points to a different package", sub {
|
||||||
# Unlike the corresponding stow_contents.t test, this doesn't
|
plan tests => 3;
|
||||||
# cause any conflicts.
|
my $stow = new_compat_Stow();
|
||||||
#
|
|
||||||
#like(
|
|
||||||
# $Conflicts[-1], qr(can't unlink.*not owned by stow)
|
|
||||||
# => q(existing link not owned by stow)
|
|
||||||
#);
|
|
||||||
ok(
|
|
||||||
-l 'bin5' && readlink('bin5') eq '../not-stow'
|
|
||||||
=> q(existing link not owned by stow)
|
|
||||||
);
|
|
||||||
|
|
||||||
#
|
make_path('bin6');
|
||||||
# Target already exists, is owned by stow, but points to a different package
|
make_path('../stow/pkg6a/bin6');
|
||||||
#
|
make_file('../stow/pkg6a/bin6/file6');
|
||||||
$stow = new_compat_Stow();
|
make_link('bin6/file6', '../../stow/pkg6a/bin6/file6');
|
||||||
|
|
||||||
make_path('bin6');
|
make_path('../stow/pkg6b/bin6');
|
||||||
make_path('../stow/pkg6a/bin6');
|
make_file('../stow/pkg6b/bin6/file6');
|
||||||
make_file('../stow/pkg6a/bin6/file6');
|
|
||||||
make_link('bin6/file6', '../../stow/pkg6a/bin6/file6');
|
|
||||||
|
|
||||||
make_path('../stow/pkg6b/bin6');
|
$stow->plan_unstow('pkg6b');
|
||||||
make_file('../stow/pkg6b/bin6/file6');
|
is($stow->get_conflict_count, 0);
|
||||||
|
ok(-l 'bin6/file6');
|
||||||
|
ok(
|
||||||
|
readlink('bin6/file6') eq '../../stow/pkg6a/bin6/file6'
|
||||||
|
=> q(ignore existing link that points to a different package)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
$stow->plan_unstow('pkg6b');
|
subtest("Don't unlink anything under the stow directory", sub {
|
||||||
ok(
|
plan tests => 5;
|
||||||
$stow->get_conflict_count == 0 &&
|
make_path('stow'); # make stow dir a subdir of target
|
||||||
-l 'bin6/file6' &&
|
my $stow = new_compat_Stow(dir => 'stow');
|
||||||
readlink('bin6/file6') eq '../../stow/pkg6a/bin6/file6'
|
|
||||||
=> q(ignore existing link that points to a different package)
|
|
||||||
);
|
|
||||||
|
|
||||||
#
|
# emulate stowing into ourself (bizarre corner case or accident)
|
||||||
# Don't unlink anything under the stow directory
|
make_path('stow/pkg7a/stow/pkg7b');
|
||||||
#
|
make_file('stow/pkg7a/stow/pkg7b/file7b');
|
||||||
make_path('stow'); # make out stow dir a subdir of target
|
make_link('stow/pkg7b', '../stow/pkg7a/stow/pkg7b');
|
||||||
$stow = new_compat_Stow(dir => 'stow');
|
|
||||||
|
|
||||||
# emulate stowing into ourself (bizarre corner case or accident)
|
capture_stderr();
|
||||||
make_path('stow/pkg7a/stow/pkg7b');
|
$stow->plan_unstow('pkg7b');
|
||||||
make_file('stow/pkg7a/stow/pkg7b/file7b');
|
is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg7b');
|
||||||
make_link('stow/pkg7b', '../stow/pkg7a/stow/pkg7b');
|
is($stow->get_conflict_count, 0);
|
||||||
|
ok(-l 'stow/pkg7b');
|
||||||
|
ok(readlink('stow/pkg7b') eq '../stow/pkg7a/stow/pkg7b'
|
||||||
|
=> q(don't unlink any nodes under the stow directory)
|
||||||
|
);
|
||||||
|
like($stderr,
|
||||||
|
qr/WARNING: skipping target which was current stow directory stow/
|
||||||
|
=> "warn when unstowing from ourself");
|
||||||
|
uncapture_stderr();
|
||||||
|
});
|
||||||
|
|
||||||
capture_stderr();
|
subtest("Don't unlink any nodes under another stow directory", sub {
|
||||||
$stow->plan_unstow('pkg7b');
|
plan tests => 5;
|
||||||
is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg7b');
|
my $stow = new_compat_Stow(dir => 'stow');
|
||||||
ok(
|
|
||||||
$stow->get_conflict_count == 0 &&
|
|
||||||
-l 'stow/pkg7b' &&
|
|
||||||
readlink('stow/pkg7b') eq '../stow/pkg7a/stow/pkg7b'
|
|
||||||
=> q(don't unlink any nodes under the stow directory)
|
|
||||||
);
|
|
||||||
like($stderr,
|
|
||||||
qr/WARNING: skipping target which was current stow directory stow/
|
|
||||||
=> "warn when unstowing from ourself");
|
|
||||||
uncapture_stderr();
|
|
||||||
|
|
||||||
#
|
make_path('stow2'); # make our alternate stow dir a subdir of target
|
||||||
# Don't unlink any nodes under another stow directory
|
make_file('stow2/.stow');
|
||||||
#
|
|
||||||
$stow = new_compat_Stow(dir => 'stow');
|
|
||||||
|
|
||||||
make_path('stow2'); # make our alternate stow dir a subdir of target
|
# emulate stowing into ourself (bizarre corner case or accident)
|
||||||
make_file('stow2/.stow');
|
make_path('stow/pkg8a/stow2/pkg8b');
|
||||||
|
make_file('stow/pkg8a/stow2/pkg8b/file8b');
|
||||||
|
make_link('stow2/pkg8b', '../stow/pkg8a/stow2/pkg8b');
|
||||||
|
|
||||||
# emulate stowing into ourself (bizarre corner case or accident)
|
capture_stderr();
|
||||||
make_path('stow/pkg8a/stow2/pkg8b');
|
$stow->plan_unstow('pkg8a');
|
||||||
make_file('stow/pkg8a/stow2/pkg8b/file8b');
|
is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg8a');
|
||||||
make_link('stow2/pkg8b', '../stow/pkg8a/stow2/pkg8b');
|
is($stow->get_conflict_count, 0);
|
||||||
|
ok(-l 'stow2/pkg8b');
|
||||||
|
ok(readlink('stow2/pkg8b') eq '../stow/pkg8a/stow2/pkg8b'
|
||||||
|
=> q(don't unlink any nodes under another stow directory)
|
||||||
|
);
|
||||||
|
like($stderr,
|
||||||
|
qr/WARNING: skipping target which was current stow directory stow/
|
||||||
|
=> "warn when skipping unstowing");
|
||||||
|
uncapture_stderr();
|
||||||
|
});
|
||||||
|
|
||||||
capture_stderr();
|
# This will be used by subsequent tests
|
||||||
$stow->plan_unstow('pkg8a');
|
|
||||||
is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg8a');
|
|
||||||
ok(
|
|
||||||
$stow->get_conflict_count == 0 &&
|
|
||||||
-l 'stow2/pkg8b' &&
|
|
||||||
readlink('stow2/pkg8b') eq '../stow/pkg8a/stow2/pkg8b'
|
|
||||||
=> q(don't unlink any nodes under another stow directory)
|
|
||||||
);
|
|
||||||
like($stderr,
|
|
||||||
qr/WARNING: skipping target which was current stow directory stow/
|
|
||||||
=> "warn when skipping unstowing");
|
|
||||||
uncapture_stderr();
|
|
||||||
|
|
||||||
#
|
|
||||||
# overriding already stowed documentation
|
|
||||||
#
|
|
||||||
|
|
||||||
# This will be used by this and subsequent tests
|
|
||||||
sub check_protected_dirs_skipped {
|
sub check_protected_dirs_skipped {
|
||||||
for my $dir (qw{stow stow2}) {
|
for my $dir (qw{stow stow2}) {
|
||||||
like($stderr,
|
like($stderr,
|
||||||
qr/WARNING: skipping marked Stow directory $dir/
|
qr/WARNING: skipping marked Stow directory $dir/
|
||||||
=> "warn when skipping marked directory $dir");
|
=> "warn when skipping marked directory $dir");
|
||||||
}
|
}
|
||||||
uncapture_stderr();
|
uncapture_stderr();
|
||||||
}
|
}
|
||||||
|
|
||||||
$stow = new_compat_Stow(override => ['man9', 'info9']);
|
subtest("overriding already stowed documentation", sub {
|
||||||
make_file('stow/.stow');
|
plan tests => 4;
|
||||||
|
|
||||||
make_path('../stow/pkg9a/man9/man1');
|
my $stow = new_compat_Stow(override => ['man9', 'info9']);
|
||||||
make_file('../stow/pkg9a/man9/man1/file9.1');
|
make_file('stow/.stow');
|
||||||
make_path('man9/man1');
|
|
||||||
make_link('man9/man1/file9.1' => '../../../stow/pkg9a/man9/man1/file9.1'); # emulate stow
|
|
||||||
|
|
||||||
make_path('../stow/pkg9b/man9/man1');
|
make_path('../stow/pkg9a/man9/man1');
|
||||||
make_file('../stow/pkg9b/man9/man1/file9.1');
|
make_file('../stow/pkg9a/man9/man1/file9.1');
|
||||||
capture_stderr();
|
make_path('man9/man1');
|
||||||
$stow->plan_unstow('pkg9b');
|
make_link('man9/man1/file9.1' => '../../../stow/pkg9a/man9/man1/file9.1'); # emulate stow
|
||||||
$stow->process_tasks();
|
|
||||||
ok(
|
|
||||||
$stow->get_conflict_count == 0 &&
|
|
||||||
!-l 'man9/man1/file9.1'
|
|
||||||
=> 'overriding existing documentation files'
|
|
||||||
);
|
|
||||||
check_protected_dirs_skipped();
|
|
||||||
|
|
||||||
#
|
make_path('../stow/pkg9b/man9/man1');
|
||||||
# deferring to already stowed documentation
|
make_file('../stow/pkg9b/man9/man1/file9.1');
|
||||||
#
|
capture_stderr();
|
||||||
$stow = new_compat_Stow(defer => ['man10', 'info10']);
|
$stow->plan_unstow('pkg9b');
|
||||||
|
$stow->process_tasks();
|
||||||
|
is($stow->get_conflict_count, 0);
|
||||||
|
ok(!-l 'man9/man1/file9.1'
|
||||||
|
=> 'overriding existing documentation files'
|
||||||
|
);
|
||||||
|
check_protected_dirs_skipped();
|
||||||
|
});
|
||||||
|
|
||||||
make_path('../stow/pkg10a/man10/man1');
|
subtest("deferring to already stowed documentation", sub {
|
||||||
make_file('../stow/pkg10a/man10/man1/file10a.1');
|
plan tests => 5;
|
||||||
make_path('man10/man1');
|
my $stow = new_compat_Stow(defer => ['man10', 'info10']);
|
||||||
make_link('man10/man1/file10a.1' => '../../../stow/pkg10a/man10/man1/file10a.1');
|
|
||||||
|
|
||||||
# need this to block folding
|
make_path('../stow/pkg10a/man10/man1');
|
||||||
make_path('../stow/pkg10b/man10/man1');
|
make_file('../stow/pkg10a/man10/man1/file10a.1');
|
||||||
make_file('../stow/pkg10b/man10/man1/file10b.1');
|
make_path('man10/man1');
|
||||||
make_link('man10/man1/file10b.1' => '../../../stow/pkg10b/man10/man1/file10b.1');
|
make_link('man10/man1/file10a.1' => '../../../stow/pkg10a/man10/man1/file10a.1');
|
||||||
|
|
||||||
|
# need this to block folding
|
||||||
|
make_path('../stow/pkg10b/man10/man1');
|
||||||
|
make_file('../stow/pkg10b/man10/man1/file10b.1');
|
||||||
|
make_link('man10/man1/file10b.1' => '../../../stow/pkg10b/man10/man1/file10b.1');
|
||||||
|
|
||||||
make_path('../stow/pkg10c/man10/man1');
|
make_path('../stow/pkg10c/man10/man1');
|
||||||
make_file('../stow/pkg10c/man10/man1/file10a.1');
|
make_file('../stow/pkg10c/man10/man1/file10a.1');
|
||||||
capture_stderr();
|
capture_stderr();
|
||||||
$stow->plan_unstow('pkg10c');
|
$stow->plan_unstow('pkg10c');
|
||||||
is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg10c');
|
is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg10c');
|
||||||
ok(
|
is($stow->get_conflict_count, 0);
|
||||||
$stow->get_conflict_count == 0 &&
|
ok(readlink('man10/man1/file10a.1') eq '../../../stow/pkg10a/man10/man1/file10a.1'
|
||||||
readlink('man10/man1/file10a.1') eq '../../../stow/pkg10a/man10/man1/file10a.1'
|
=> 'defer to existing documentation files'
|
||||||
=> 'defer to existing documentation files'
|
);
|
||||||
);
|
check_protected_dirs_skipped();
|
||||||
check_protected_dirs_skipped();
|
});
|
||||||
|
|
||||||
#
|
subtest("Ignore temp files", sub {
|
||||||
# Ignore temp files
|
plan tests => 4;
|
||||||
#
|
my $stow = new_compat_Stow(ignore => ['~', '\.#.*']);
|
||||||
$stow = new_compat_Stow(ignore => ['~', '\.#.*']);
|
|
||||||
|
|
||||||
make_path('../stow/pkg12/man12/man1');
|
make_path('../stow/pkg12/man12/man1');
|
||||||
make_file('../stow/pkg12/man12/man1/file12.1');
|
make_file('../stow/pkg12/man12/man1/file12.1');
|
||||||
make_file('../stow/pkg12/man12/man1/file12.1~');
|
make_file('../stow/pkg12/man12/man1/file12.1~');
|
||||||
make_file('../stow/pkg12/man12/man1/.#file12.1');
|
make_file('../stow/pkg12/man12/man1/.#file12.1');
|
||||||
make_path('man12/man1');
|
make_path('man12/man1');
|
||||||
make_link('man12/man1/file12.1' => '../../../stow/pkg12/man12/man1/file12.1');
|
make_link('man12/man1/file12.1' => '../../../stow/pkg12/man12/man1/file12.1');
|
||||||
|
|
||||||
capture_stderr();
|
capture_stderr();
|
||||||
$stow->plan_unstow('pkg12');
|
$stow->plan_unstow('pkg12');
|
||||||
$stow->process_tasks();
|
$stow->process_tasks();
|
||||||
ok(
|
is($stow->get_conflict_count, 0);
|
||||||
$stow->get_conflict_count == 0 &&
|
ok(!-e 'man12/man1/file12.1' => 'ignore temp files');
|
||||||
!-e 'man12/man1/file12.1'
|
check_protected_dirs_skipped();
|
||||||
=> 'ignore temp files'
|
});
|
||||||
);
|
|
||||||
check_protected_dirs_skipped();
|
|
||||||
|
|
||||||
#
|
subtest("Unstow an already unstowed package", sub {
|
||||||
# Unstow an already unstowed package
|
plan tests => 4;
|
||||||
#
|
my $stow = new_compat_Stow();
|
||||||
$stow = new_compat_Stow();
|
capture_stderr();
|
||||||
capture_stderr();
|
$stow->plan_unstow('pkg12');
|
||||||
$stow->plan_unstow('pkg12');
|
is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12');
|
||||||
is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12');
|
ok(
|
||||||
ok(
|
$stow->get_conflict_count == 0
|
||||||
$stow->get_conflict_count == 0
|
=> 'unstow already unstowed package pkg12'
|
||||||
=> 'unstow already unstowed package pkg12'
|
);
|
||||||
);
|
check_protected_dirs_skipped();
|
||||||
check_protected_dirs_skipped();
|
});
|
||||||
|
|
||||||
#
|
subtest("Unstow a never stowed package", sub {
|
||||||
# Unstow a never stowed package
|
plan tests => 4;
|
||||||
#
|
|
||||||
|
|
||||||
eval { remove_dir("$TEST_DIR/target"); };
|
eval { remove_dir("$TEST_DIR/target"); };
|
||||||
mkdir("$TEST_DIR/target");
|
mkdir("$TEST_DIR/target");
|
||||||
|
|
||||||
$stow = new_compat_Stow();
|
my $stow = new_compat_Stow();
|
||||||
capture_stderr();
|
capture_stderr();
|
||||||
$stow->plan_unstow('pkg12');
|
$stow->plan_unstow('pkg12');
|
||||||
is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12 which was never stowed');
|
is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12 which was never stowed');
|
||||||
ok(
|
ok(
|
||||||
$stow->get_conflict_count == 0
|
$stow->get_conflict_count == 0
|
||||||
=> 'unstow never stowed package pkg12'
|
=> 'unstow never stowed package pkg12'
|
||||||
);
|
);
|
||||||
check_protected_dirs_skipped();
|
check_protected_dirs_skipped();
|
||||||
|
});
|
||||||
|
|
||||||
#
|
subtest("Unstowing when target contains a real file shouldn't be an issue", sub {
|
||||||
# Unstowing when target contains a real file shouldn't be an issue.
|
plan tests => 5;
|
||||||
#
|
make_file('man12/man1/file12.1');
|
||||||
make_file('man12/man1/file12.1');
|
|
||||||
|
|
||||||
$stow = new_compat_Stow();
|
my $stow = new_compat_Stow();
|
||||||
capture_stderr();
|
capture_stderr();
|
||||||
$stow->plan_unstow('pkg12');
|
$stow->plan_unstow('pkg12');
|
||||||
is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12 for third time');
|
is($stow->get_tasks, 0, 'no tasks to process when unstowing pkg12 for third time');
|
||||||
%conflicts = $stow->get_conflicts;
|
%conflicts = $stow->get_conflicts;
|
||||||
ok(
|
ok($stow->get_conflict_count == 1);
|
||||||
$stow->get_conflict_count == 1 &&
|
ok($conflicts{unstow}{pkg12}[0]
|
||||||
$conflicts{unstow}{pkg12}[0]
|
=~ m!existing target is neither a link nor a directory: man12/man1/file12\.1!
|
||||||
=~ m!existing target is neither a link nor a directory: man12/man1/file12\.1!
|
=> 'unstow pkg12 for third time'
|
||||||
=> 'unstow pkg12 for third time'
|
);
|
||||||
);
|
check_protected_dirs_skipped();
|
||||||
check_protected_dirs_skipped();
|
});
|
||||||
|
|
||||||
#
|
subtest("unstow a simple tree minimally when cwd isn't target", sub {
|
||||||
# unstow a simple tree minimally when cwd isn't target
|
plan tests => 3;
|
||||||
#
|
cd('../..');
|
||||||
cd('../..');
|
my $stow = new_Stow(dir => "$TEST_DIR/stow", target => "$TEST_DIR/target");
|
||||||
$stow = new_Stow(dir => "$TEST_DIR/stow", target => "$TEST_DIR/target");
|
|
||||||
|
|
||||||
make_path("$TEST_DIR/stow/pkg13/bin13");
|
make_path("$TEST_DIR/stow/pkg13/bin13");
|
||||||
make_file("$TEST_DIR/stow/pkg13/bin13/file13");
|
make_file("$TEST_DIR/stow/pkg13/bin13/file13");
|
||||||
make_link("$TEST_DIR/target/bin13", '../stow/pkg13/bin13');
|
make_link("$TEST_DIR/target/bin13", '../stow/pkg13/bin13');
|
||||||
|
|
||||||
$stow->plan_unstow('pkg13');
|
$stow->plan_unstow('pkg13');
|
||||||
$stow->process_tasks();
|
$stow->process_tasks();
|
||||||
ok(
|
is($stow->get_conflict_count, 0);
|
||||||
$stow->get_conflict_count == 0 &&
|
ok(-f "$TEST_DIR/stow/pkg13/bin13/file13");
|
||||||
-f "$TEST_DIR/stow/pkg13/bin13/file13" && ! -e "$TEST_DIR/target/bin13"
|
ok(! -e "$TEST_DIR/target/bin13" => 'unstow a simple tree');
|
||||||
=> 'unstow a simple tree'
|
});
|
||||||
);
|
|
||||||
|
|
||||||
#
|
subtest("unstow a simple tree minimally with absolute stow dir when cwd isn't target", sub {
|
||||||
# unstow a simple tree minimally with absolute stow dir when cwd isn't
|
plan tests => 3;
|
||||||
# target
|
my $stow = new_Stow(dir => canon_path("$TEST_DIR/stow"),
|
||||||
#
|
target => "$TEST_DIR/target");
|
||||||
$stow = new_Stow(dir => canon_path("$TEST_DIR/stow"),
|
|
||||||
target => "$TEST_DIR/target");
|
|
||||||
|
|
||||||
make_path("$TEST_DIR/stow/pkg14/bin14");
|
make_path("$TEST_DIR/stow/pkg14/bin14");
|
||||||
make_file("$TEST_DIR/stow/pkg14/bin14/file14");
|
make_file("$TEST_DIR/stow/pkg14/bin14/file14");
|
||||||
make_link("$TEST_DIR/target/bin14", '../stow/pkg14/bin14');
|
make_link("$TEST_DIR/target/bin14", '../stow/pkg14/bin14');
|
||||||
|
|
||||||
$stow->plan_unstow('pkg14');
|
$stow->plan_unstow('pkg14');
|
||||||
$stow->process_tasks();
|
$stow->process_tasks();
|
||||||
ok(
|
is($stow->get_conflict_count, 0);
|
||||||
$stow->get_conflict_count == 0 &&
|
ok(-f "$TEST_DIR/stow/pkg14/bin14/file14");
|
||||||
-f "$TEST_DIR/stow/pkg14/bin14/file14" && ! -e "$TEST_DIR/target/bin14"
|
ok(! -e "$TEST_DIR/target/bin14"
|
||||||
=> 'unstow a simple tree with absolute stow dir'
|
=> 'unstow a simple tree with absolute stow dir'
|
||||||
);
|
);
|
||||||
|
});
|
||||||
|
|
||||||
#
|
subtest("unstow a simple tree minimally with absolute stow AND target dirs when cwd isn't target", sub {
|
||||||
# unstow a simple tree minimally with absolute stow AND target dirs
|
plan tests => 3;
|
||||||
# when cwd isn't target
|
my $stow = new_Stow(dir => canon_path("$TEST_DIR/stow"),
|
||||||
#
|
target => canon_path("$TEST_DIR/target"));
|
||||||
$stow = new_Stow(dir => canon_path("$TEST_DIR/stow"),
|
make_path("$TEST_DIR/stow/pkg15/bin15");
|
||||||
target => canon_path("$TEST_DIR/target"));
|
make_file("$TEST_DIR/stow/pkg15/bin15/file15");
|
||||||
|
make_link("$TEST_DIR/target/bin15", '../stow/pkg15/bin15');
|
||||||
|
|
||||||
make_path("$TEST_DIR/stow/pkg15/bin15");
|
$stow->plan_unstow('pkg15');
|
||||||
make_file("$TEST_DIR/stow/pkg15/bin15/file15");
|
$stow->process_tasks();
|
||||||
make_link("$TEST_DIR/target/bin15", '../stow/pkg15/bin15');
|
is($stow->get_conflict_count, 0);
|
||||||
|
ok(-f "$TEST_DIR/stow/pkg15/bin15/file15");
|
||||||
$stow->plan_unstow('pkg15');
|
ok(! -e "$TEST_DIR/target/bin15"
|
||||||
$stow->process_tasks();
|
=> 'unstow a simple tree with absolute stow and target dirs'
|
||||||
ok(
|
);
|
||||||
$stow->get_conflict_count == 0 &&
|
});
|
||||||
-f "$TEST_DIR/stow/pkg15/bin15/file15" && ! -e "$TEST_DIR/target/bin15"
|
|
||||||
=> 'unstow a simple tree with absolute stow and target dirs'
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
# Todo
|
|
||||||
#
|
|
||||||
# Test cleaning up subdirs with --paranoid option
|
|
||||||
|
|
||||||
|
# subtest("Test cleaning up subdirs with --paranoid option", sub {
|
||||||
|
# TODO
|
||||||
|
# });
|
||||||
|
|
Loading…
Reference in a new issue