From 2244539b6b21639bce8497bacab334fd1e47b107 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 21 Nov 2011 23:23:43 +0000 Subject: [PATCH] Test stow/unstow with stow dir / target dir as absolute paths. --- t/stow_contents.t | 43 +++++++++++++++++++++++++++++++++++++++-- t/unstow_contents.t | 45 ++++++++++++++++++++++++++++++++++++++++--- t/unstow_contents_orig.t | 50 ++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 129 insertions(+), 9 deletions(-) diff --git a/t/stow_contents.t b/t/stow_contents.t index ad3b47f..b8a0eff 100755 --- a/t/stow_contents.t +++ b/t/stow_contents.t @@ -7,10 +7,11 @@ use strict; use warnings; -use Test::More tests => 19; +use Test::More tests => 23; use Test::Output; use English qw(-no_match_vars); +use Stow::Util qw(canon_path); use testutil; make_fresh_stow_and_target_dirs(); @@ -303,5 +304,43 @@ is($stow->get_conflicts(), 0, 'no conflicts with minimal stow'); is( readlink('t/target/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" ); diff --git a/t/unstow_contents.t b/t/unstow_contents.t index cd5fd3a..cb9707d 100755 --- a/t/unstow_contents.t +++ b/t/unstow_contents.t @@ -7,12 +7,13 @@ use strict; use warnings; -use testutil; - -use Test::More tests => 21; +use Test::More tests => 23; use Test::Output; use English qw(-no_match_vars); +use testutil; +use Stow::Util qw(canon_path); + make_fresh_stow_and_target_dirs(); cd('t/target'); @@ -324,6 +325,44 @@ ok( => '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 # diff --git a/t/unstow_contents_orig.t b/t/unstow_contents_orig.t index e120480..85214c5 100755 --- a/t/unstow_contents_orig.t +++ b/t/unstow_contents_orig.t @@ -7,12 +7,13 @@ use strict; use warnings; -use testutil; - -use Test::More tests => 21; +use Test::More tests => 23; use Test::Output; use English qw(-no_match_vars); +use testutil; +use Stow::Util qw(canon_path); + make_fresh_stow_and_target_dirs(); cd('t/target'); @@ -106,6 +107,9 @@ make_dir('../stow/pkg5/bin5'); make_link('bin5', '../not-stow'); $stow->plan_unstow('pkg5'); +# Unlike the corresponding stow_contents.t test, this doesn't +# cause any conflicts. +# #like( # $Conflicts[-1], qr(CONFLICT:.*can't unlink.*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 -# +# cd('../..'); $stow = new_Stow(dir => 't/stow', target => 't/target'); @@ -328,6 +332,44 @@ ok( => '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 # -- 2.11.4.GIT