Test stow/unstow with stow dir / target dir as absolute paths.

This commit is contained in:
Adam Spiers 2011-11-21 23:23:43 +00:00
parent 4d45d3e0c7
commit 2244539b6b
3 changed files with 129 additions and 9 deletions

View file

@ -7,10 +7,11 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 19; use Test::More tests => 23;
use Test::Output; use Test::Output;
use English qw(-no_match_vars); use English qw(-no_match_vars);
use Stow::Util qw(canon_path);
use testutil; use testutil;
make_fresh_stow_and_target_dirs(); make_fresh_stow_and_target_dirs();
@ -303,5 +304,43 @@ is($stow->get_conflicts(), 0, 'no conflicts with minimal stow');
is( is(
readlink('t/target/bin16'), readlink('t/target/bin16'),
'../stow/pkg16/bin16', '../stow/pkg16/bin16',
=> 'minimal stow of a simple tree' => "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('t/stow'),
target => 't/target');
make_dir('t/stow/pkg17/bin17');
make_file('t/stow/pkg17/bin17/file17');
$stow->plan_stow('pkg17');
$stow->process_tasks();
is($stow->get_conflicts(), 0, 'no conflicts with minimal stow');
is(
readlink('t/target/bin17'),
'../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('t/stow'),
target => canon_path('t/target'));
make_dir('t/stow/pkg18/bin18');
make_file('t/stow/pkg18/bin18/file18');
$stow->plan_stow('pkg18');
$stow->process_tasks();
is($stow->get_conflicts(), 0, 'no conflicts with minimal stow');
is(
readlink('t/target/bin18'),
'../stow/pkg18/bin18',
=> "minimal stow of a simple tree with absolute stow and target dirs"
); );

View file

@ -7,12 +7,13 @@
use strict; use strict;
use warnings; use warnings;
use testutil; use Test::More tests => 23;
use Test::More tests => 21;
use Test::Output; use Test::Output;
use English qw(-no_match_vars); use English qw(-no_match_vars);
use testutil;
use Stow::Util qw(canon_path);
make_fresh_stow_and_target_dirs(); make_fresh_stow_and_target_dirs();
cd('t/target'); cd('t/target');
@ -324,6 +325,44 @@ ok(
=> 'unstow a simple tree' => 'unstow a simple tree'
); );
#
# unstow a simple tree minimally with absolute stow dir when cwd isn't
# target
#
$stow = new_Stow(dir => canon_path('t/stow'),
target => 't/target');
make_dir('t/stow/pkg14/bin14');
make_file('t/stow/pkg14/bin14/file14');
make_link('t/target/bin14', '../stow/pkg14/bin14');
$stow->plan_unstow('pkg14');
$stow->process_tasks();
ok(
scalar($stow->get_conflicts) == 0 &&
-f 't/stow/pkg14/bin14/file14' && ! -e 't/target/bin14'
=> 'unstow a simple tree with absolute stow dir'
);
#
# unstow a simple tree minimally with absolute stow AND target dirs
# when cwd isn't target
#
$stow = new_Stow(dir => canon_path('t/stow'),
target => canon_path('t/target'));
make_dir('t/stow/pkg15/bin15');
make_file('t/stow/pkg15/bin15/file15');
make_link('t/target/bin15', '../stow/pkg15/bin15');
$stow->plan_unstow('pkg15');
$stow->process_tasks();
ok(
scalar($stow->get_conflicts) == 0 &&
-f 't/stow/pkg15/bin15/file15' && ! -e 't/target/bin15'
=> 'unstow a simple tree with absolute stow and target dirs'
);
# Todo # Todo
# #

View file

@ -7,12 +7,13 @@
use strict; use strict;
use warnings; use warnings;
use testutil; use Test::More tests => 23;
use Test::More tests => 21;
use Test::Output; use Test::Output;
use English qw(-no_match_vars); use English qw(-no_match_vars);
use testutil;
use Stow::Util qw(canon_path);
make_fresh_stow_and_target_dirs(); make_fresh_stow_and_target_dirs();
cd('t/target'); cd('t/target');
@ -106,6 +107,9 @@ make_dir('../stow/pkg5/bin5');
make_link('bin5', '../not-stow'); make_link('bin5', '../not-stow');
$stow->plan_unstow('pkg5'); $stow->plan_unstow('pkg5');
# Unlike the corresponding stow_contents.t test, this doesn't
# cause any conflicts.
#
#like( #like(
# $Conflicts[-1], qr(CONFLICT:.*can't unlink.*not owned by stow) # $Conflicts[-1], qr(CONFLICT:.*can't unlink.*not owned by stow)
# => q(existing link not owned by stow) # => q(existing link not owned by stow)
@ -312,7 +316,7 @@ ok(
# #
# unstow a simple tree minimally when cwd isn't target # unstow a simple tree minimally when cwd isn't target
# #
cd('../..'); cd('../..');
$stow = new_Stow(dir => 't/stow', target => 't/target'); $stow = new_Stow(dir => 't/stow', target => 't/target');
@ -328,6 +332,44 @@ ok(
=> 'unstow a simple tree' => 'unstow a simple tree'
); );
#
# unstow a simple tree minimally with absolute stow dir when cwd isn't
# target
#
$stow = new_Stow(dir => canon_path('t/stow'),
target => 't/target');
make_dir('t/stow/pkg14/bin14');
make_file('t/stow/pkg14/bin14/file14');
make_link('t/target/bin14', '../stow/pkg14/bin14');
$stow->plan_unstow('pkg14');
$stow->process_tasks();
ok(
scalar($stow->get_conflicts) == 0 &&
-f 't/stow/pkg14/bin14/file14' && ! -e 't/target/bin14'
=> 'unstow a simple tree with absolute stow dir'
);
#
# unstow a simple tree minimally with absolute stow AND target dirs
# when cwd isn't target
#
$stow = new_Stow(dir => canon_path('t/stow'),
target => canon_path('t/target'));
make_dir('t/stow/pkg15/bin15');
make_file('t/stow/pkg15/bin15/file15');
make_link('t/target/bin15', '../stow/pkg15/bin15');
$stow->plan_unstow('pkg15');
$stow->process_tasks();
ok(
scalar($stow->get_conflicts) == 0 &&
-f 't/stow/pkg15/bin15/file15' && ! -e 't/target/bin15'
=> 'unstow a simple tree with absolute stow and target dirs'
);
# Todo # Todo
# #