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