Split up is_deeply() assertions in find_stowed_path.t

This makes the tests and any failures more readable.
This commit is contained in:
Adam Spiers 2019-06-28 15:23:52 +01:00
parent 40a0807185
commit ac74d75a98

View file

@ -22,7 +22,7 @@
use strict;
use warnings;
use Test::More tests => 6;
use Test::More tests => 18;
use testutil;
use Stow::Util qw(set_debug_level);
@ -32,49 +32,49 @@ init_test_dirs();
my $stow = new_Stow(dir => "$TEST_DIR/stow");
#set_debug_level(4);
is_deeply(
[ $stow->find_stowed_path("$TEST_DIR/target/a/b/c", '../../../stow/a/b/c') ],
[ "$TEST_DIR/stow/a/b/c", "$TEST_DIR/stow", 'a' ]
=> 'from root'
);
my ($path, $stow_path, $package) =
$stow->find_stowed_path("$TEST_DIR/target/a/b/c", "../../../stow/a/b/c");
is($path, "$TEST_DIR/stow/a/b/c", "path");
is($stow_path, "$TEST_DIR/stow", "stow path");
is($package, "a", "package");
cd("$TEST_DIR/target");
$stow->set_stow_dir('../stow');
is_deeply(
[ $stow->find_stowed_path('a/b/c','../../../stow/a/b/c') ],
[ '../stow/a/b/c', '../stow', 'a' ]
=> 'from target directory'
);
$stow->set_stow_dir("../stow");
($path, $stow_path, $package) =
$stow->find_stowed_path("a/b/c", "../../../stow/a/b/c");
is($path, "../stow/a/b/c", "path from target directory");
is($stow_path, "../stow", "stow path from target directory");
is($package, "a", "from target directory");
make_path('stow');
cd('../..');
make_path("stow");
cd("../..");
$stow->set_stow_dir("$TEST_DIR/target/stow");
is_deeply(
[ $stow->find_stowed_path("$TEST_DIR/target/a/b/c", '../../stow/a/b/c') ],
[ "$TEST_DIR/target/stow/a/b/c", "$TEST_DIR/target/stow", 'a' ]
=> 'stow is subdir of target directory'
);
($path, $stow_path, $package) =
$stow->find_stowed_path("$TEST_DIR/target/a/b/c", "../../stow/a/b/c");
is($path, "$TEST_DIR/target/stow/a/b/c", "path");
is($stow_path, "$TEST_DIR/target/stow", "stow path");
is($package, "a", "stow is subdir of target directory");
is_deeply(
[ $stow->find_stowed_path("$TEST_DIR/target/a/b/c",'../../empty') ],
[ '', '', '' ]
=> 'target is not stowed'
);
($path, $stow_path, $package) =
$stow->find_stowed_path("$TEST_DIR/target/a/b/c", "../../empty");
is($path, "", "empty path");
is($stow_path, "", "empty stow path");
is($package, "", "target is not stowed");
make_path("$TEST_DIR/target/stow2");
make_file("$TEST_DIR/target/stow2/.stow");
is_deeply(
[ $stow->find_stowed_path("$TEST_DIR/target/a/b/c",'../../stow2/a/b/c') ],
[ "$TEST_DIR/target/stow2/a/b/c", "$TEST_DIR/target/stow2", 'a' ]
=> q(detect alternate stow directory)
);
($path, $stow_path, $package) =
$stow->find_stowed_path("$TEST_DIR/target/a/b/c","../../stow2/a/b/c");
is($path, "$TEST_DIR/target/stow2/a/b/c", "path");
is($stow_path, "$TEST_DIR/target/stow2", "stow path");
is($package, "a", "detect alternate stow directory");
# Possible corner case with rogue symlink pointing to ancestor of
# stow dir.
is_deeply(
[ $stow->find_stowed_path("$TEST_DIR/target/a/b/c",'../../..') ],
[ '', '', '' ]
=> q(corner case - link points to ancestor of stow dir)
);
($path, $stow_path, $package) =
$stow->find_stowed_path("$TEST_DIR/target/a/b/c","../../..");
is($path, "", "path");
is($stow_path, "", "stow path");
is($package, "", "corner case - link points to ancestor of stow dir");