Grafted root commit from savannah git master:
[gnu-stow.git] / t / find_stowed_path.t
blob03a7c739a2eea55954c1c304bba499f4fc06ca87
1 #!/usr/local/bin/perl
4 # Testing find_stowed_path()
7 BEGIN { require "t/util.pm"; require "stow"; }
9 use Test::More tests => 5;
11 eval { remove_dir('t/target'); };
12 eval { remove_dir('t/stow'); };
13 make_dir('t/target');
14 make_dir('t/stow');
16 $Stow_Path = 't/stow';
17 is(
18 find_stowed_path('t/target/a/b/c', '../../../stow/a/b/c'),
19 't/stow/a/b/c',
20 => 'from root'
23 $Stow_Path = '../stow';
24 is(
25 find_stowed_path('a/b/c','../../../stow/a/b/c'),
26 '../stow/a/b/c',
27 => 'from target directory'
30 $Stow_Path = 't/target/stow';
32 is(
33 find_stowed_path('t/target/a/b/c', '../../stow/a/b/c'),
34 't/target/stow/a/b/c',
35 => 'stow is subdir of target directory'
38 is(
39 find_stowed_path('t/target/a/b/c','../../empty'),
40 '',
41 => 'target is not stowed'
44 make_dir('t/target/stow2');
45 make_file('t/target/stow2/.stow');
47 is(
48 find_stowed_path('t/target/a/b/c','../../stow2/a/b/c'),
49 't/target/stow2/a/b/c'
50 => q(detect alternate stow directory)