3 # This file is part of GNU Stow.
5 # GNU Stow is free software: you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # GNU Stow is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see https://www.gnu.org/licenses/.
19 # Testing Stow::link_dest_within_stow_dir()
25 use Test
::More tests
=> 6;
32 # This is a relative path, unlike $ABS_TEST_DIR below.
33 my $stow = new_Stow
(dir
=> "$TEST_DIR/stow",
34 target
=> "$TEST_DIR/target");
36 subtest
("relative stow dir, link to top-level package file" => sub {
38 my ($package, $path) =
39 $stow->link_dest_within_stow_dir("../stow/pkg/dir/file");
40 is
($package, "pkg", "package");
41 is
($path, "dir/file", "path");
44 subtest
("relative stow dir, link to second-level package file" => sub {
46 my ($package, $path) =
47 $stow->link_dest_within_stow_dir("../stow/pkg/dir/subdir/file");
48 is
($package, "pkg", "package");
49 is
($path, "dir/subdir/file", "path");
52 # This is an absolute path, unlike $TEST_DIR above.
53 $stow = new_Stow
(dir
=> "$ABS_TEST_DIR/stow",
54 target
=> "$ABS_TEST_DIR/target");
56 subtest
("relative stow dir, link to second-level package file" => sub {
58 my ($package, $path) =
59 $stow->link_dest_within_stow_dir("../stow/pkg/dir/file");
60 is
($package, "pkg", "package");
61 is
($path, "dir/file", "path");
64 subtest
("absolute stow dir, link to top-level package file" => sub {
66 my ($package, $path) =
67 $stow->link_dest_within_stow_dir("../stow/pkg/dir/subdir/file");
68 is
($package, "pkg", "package");
69 is
($path, "dir/subdir/file", "path");
72 # Links with destination in the target are not pointing within
73 # the stow dir, so they're not owned by stow.
74 subtest
("link to path in target" => sub {
76 my ($package, $path) =
77 $stow->link_dest_within_stow_dir("./alien");
78 is
($path, "", "alien is in target, so path is empty");
79 is
($package, "", "alien is in target, so package is empty");
82 subtest
("link to path outside target and stow dir" => sub {
84 my ($package, $path) =
85 $stow->link_dest_within_stow_dir("../alien");
86 is
($path, "", "alien is outside, so path is empty");
87 is
($package, "", "alien is outside, so package is empty");