From ac74d75a983fc091210131e5919fe1b9461b03b0 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 28 Jun 2019 15:23:52 +0100 Subject: [PATCH] Split up is_deeply() assertions in find_stowed_path.t This makes the tests and any failures more readable. --- t/find_stowed_path.t | 68 ++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/t/find_stowed_path.t b/t/find_stowed_path.t index 968799a..7b82520 100755 --- a/t/find_stowed_path.t +++ b/t/find_stowed_path.t @@ -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");