diff options
author | Adam Spiers <stow@adamspiers.org> | 2011-11-24 16:28:09 +0000 |
---|---|---|
committer | Adam Spiers <stow@adamspiers.org> | 2011-11-24 16:56:11 +0000 |
commit | dc61da22d4fc0ee5f6f0b6a550c8d162e7f1e3bb (patch) | |
tree | 19ed6944797f9f8fb31b08b3ae64ca6677435b8b /t/find_stowed_path.t | |
parent | 1365c4c4f110b732bcc924a3d59d62b3fe054b9a (diff) | |
download | stow-dc61da22d4fc0ee5f6f0b6a550c8d162e7f1e3bb.tar.gz |
Major refactoring of code into separate Stow and Stow::Util Perl modules
Diffstat (limited to 't/find_stowed_path.t')
-rwxr-xr-x[-rw-r--r--] | t/find_stowed_path.t | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/t/find_stowed_path.t b/t/find_stowed_path.t index 03a7c73..199a534 100644..100755 --- a/t/find_stowed_path.t +++ b/t/find_stowed_path.t @@ -4,39 +4,43 @@ # Testing find_stowed_path() # -BEGIN { require "t/util.pm"; require "stow"; } +use strict; +use warnings; -use Test::More tests => 5; +use testutil; -eval { remove_dir('t/target'); }; -eval { remove_dir('t/stow'); }; -make_dir('t/target'); -make_dir('t/stow'); +use Test::More tests => 6; + +make_fresh_stow_and_target_dirs(); + +my $stow = new_Stow(dir => 't/stow'); -$Stow_Path = 't/stow'; is( - find_stowed_path('t/target/a/b/c', '../../../stow/a/b/c'), + $stow->find_stowed_path('t/target/a/b/c', '../../../stow/a/b/c'), 't/stow/a/b/c', => 'from root' ); -$Stow_Path = '../stow'; +cd('t/target'); +$stow->set_stow_dir('../stow'); is( - find_stowed_path('a/b/c','../../../stow/a/b/c'), + $stow->find_stowed_path('a/b/c','../../../stow/a/b/c'), '../stow/a/b/c', => 'from target directory' ); -$Stow_Path = 't/target/stow'; +make_dir('stow'); +cd('../..'); +$stow->set_stow_dir('t/target/stow'); is( - find_stowed_path('t/target/a/b/c', '../../stow/a/b/c'), + $stow->find_stowed_path('t/target/a/b/c', '../../stow/a/b/c'), 't/target/stow/a/b/c', => 'stow is subdir of target directory' ); is( - find_stowed_path('t/target/a/b/c','../../empty'), + $stow->find_stowed_path('t/target/a/b/c','../../empty'), '', => 'target is not stowed' ); @@ -45,7 +49,15 @@ make_dir('t/target/stow2'); make_file('t/target/stow2/.stow'); is( - find_stowed_path('t/target/a/b/c','../../stow2/a/b/c'), + $stow->find_stowed_path('t/target/a/b/c','../../stow2/a/b/c'), 't/target/stow2/a/b/c' => q(detect alternate stow directory) ); + +# Possible corner case with rogue symlink pointing to ancestor of +# stow dir. +is( + $stow->find_stowed_path('t/target/a/b/c','../../..'), + '' + => q(corner case - link points to ancestor of stow dir) +); |