diff --git a/t/cleanup_invalid_links.t b/t/cleanup_invalid_links.t index 3b54b71..1635641 100755 --- a/t/cleanup_invalid_links.t +++ b/t/cleanup_invalid_links.t @@ -22,10 +22,11 @@ use strict; use warnings; -use Test::More tests => 6; +use Test::More tests => 3; use English qw(-no_match_vars); use testutil; +use Stow::Util; init_test_dirs(); cd("$TEST_DIR/target"); @@ -34,48 +35,48 @@ my $stow; # Note that each of the following tests use a distinct set of files -# -# nothing to clean in a simple tree -# +subtest('nothing to clean in a simple tree' => sub { + plan tests => 1; + make_path('../stow/pkg1/bin1'); + make_file('../stow/pkg1/bin1/file1'); + make_link('bin1', '../stow/pkg1/bin1'); -make_path('../stow/pkg1/bin1'); -make_file('../stow/pkg1/bin1/file1'); -make_link('bin1', '../stow/pkg1/bin1'); + $stow = new_Stow(); + $stow->cleanup_invalid_links('./'); + is( + scalar($stow->get_tasks), 0 + => 'nothing to clean' + ); +}); -$stow = new_Stow(); -$stow->cleanup_invalid_links('./'); -is( - scalar($stow->get_tasks), 0 - => 'nothing to clean' -); +subtest('cleanup a bad link in a simple tree' => sub { + plan tests => 3; -# -# cleanup a bad link in a simple tree -# -make_path('bin2'); -make_path('../stow/pkg2/bin2'); -make_file('../stow/pkg2/bin2/file2a'); -make_link('bin2/file2a', '../../stow/pkg2/bin2/file2a'); -make_invalid_link('bin2/file2b', '../../stow/pkg2/bin2/file2b'); + make_path('bin2'); + make_path('../stow/pkg2/bin2'); + make_file('../stow/pkg2/bin2/file2a'); + make_link('bin2/file2a', '../../stow/pkg2/bin2/file2a'); + make_invalid_link('bin2/file2b', '../../stow/pkg2/bin2/file2b'); -$stow = new_Stow(); -$stow->cleanup_invalid_links('bin2'); -is($stow->get_conflict_count, 0, 'no conflicts cleaning up bad link'); -is(scalar($stow->get_tasks), 1, 'one task cleaning up bad link'); -is($stow->link_task_action('bin2/file2b'), 'remove', 'removal task for bad link'); + $stow = new_Stow(); + $stow->cleanup_invalid_links('bin2'); + is($stow->get_conflict_count, 0, 'no conflicts cleaning up bad link'); + is(scalar($stow->get_tasks), 1, 'one task cleaning up bad link'); + is($stow->link_task_action('bin2/file2b'), 'remove', 'removal task for bad link'); +}); -# -# dont cleanup a bad link not owned by stow -# +subtest("don't cleanup a bad link not owned by stow" => sub { + plan tests => 2; -make_path('bin3'); -make_path('../stow/pkg3/bin3'); -make_file('../stow/pkg3/bin3/file3a'); -make_link('bin3/file3a', '../../stow/pkg3/bin3/file3a'); -make_invalid_link('bin3/file3b', '../../empty'); + make_path('bin3'); + make_path('../stow/pkg3/bin3'); + make_file('../stow/pkg3/bin3/file3a'); + make_link('bin3/file3a', '../../stow/pkg3/bin3/file3a'); + make_invalid_link('bin3/file3b', '../../empty'); -$stow = new_Stow(); -$stow->cleanup_invalid_links('bin3'); -is($stow->get_conflict_count, 0, 'no conflicts cleaning up bad link not owned by stow'); -is(scalar($stow->get_tasks), 0, 'no tasks cleaning up bad link not owned by stow'); + $stow = new_Stow(); + $stow->cleanup_invalid_links('bin3'); + is($stow->get_conflict_count, 0, 'no conflicts cleaning up bad link not owned by stow'); + is(scalar($stow->get_tasks), 0, 'no tasks cleaning up bad link not owned by stow'); +});