summaryrefslogtreecommitdiff
path: root/t/find_stowed_path.t
diff options
context:
space:
mode:
authorAdam Spiers <stow@adamspiers.org>2011-11-16 14:04:03 +0000
committerAdam Spiers <stow@adamspiers.org>2011-11-16 14:04:03 +0000
commit0473d3f8ba40ba2a445cbffb2d0b6fa84f774567 (patch)
treea50c7d63ede4d66795f7f5d047da7d41b5f56a67 /t/find_stowed_path.t
parent0ffef1809a8a0b1c82ed4fd339ac32624c2a3c4e (diff)
downloadstow-0473d3f8ba40ba2a445cbffb2d0b6fa84f774567.tar.gz
Grafted root commit from savannah git master:v2.0.2
38dcdcb08c60f4cc661395beb22641c46add9e6c Initial Import
Diffstat (limited to 't/find_stowed_path.t')
-rw-r--r--t/find_stowed_path.t51
1 files changed, 51 insertions, 0 deletions
diff --git a/t/find_stowed_path.t b/t/find_stowed_path.t
new file mode 100644
index 0000000..03a7c73
--- /dev/null
+++ b/t/find_stowed_path.t
@@ -0,0 +1,51 @@
+#!/usr/local/bin/perl
+
+#
+# Testing find_stowed_path()
+#
+
+BEGIN { require "t/util.pm"; require "stow"; }
+
+use Test::More tests => 5;
+
+eval { remove_dir('t/target'); };
+eval { remove_dir('t/stow'); };
+make_dir('t/target');
+make_dir('t/stow');
+
+$Stow_Path = 't/stow';
+is(
+ find_stowed_path('t/target/a/b/c', '../../../stow/a/b/c'),
+ 't/stow/a/b/c',
+ => 'from root'
+);
+
+$Stow_Path = '../stow';
+is(
+ find_stowed_path('a/b/c','../../../stow/a/b/c'),
+ '../stow/a/b/c',
+ => 'from target directory'
+);
+
+$Stow_Path = 't/target/stow';
+
+is(
+ 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'),
+ '',
+ => 'target is not stowed'
+);
+
+make_dir('t/target/stow2');
+make_file('t/target/stow2/.stow');
+
+is(
+ find_stowed_path('t/target/a/b/c','../../stow2/a/b/c'),
+ 't/target/stow2/a/b/c'
+ => q(detect alternate stow directory)
+);