t/cleanup_invalid_links: divide into subtests

This makes the code and test output both more legible.
This commit is contained in:
Adam Spiers 2024-03-31 11:52:45 +01:00
parent a2beb7b371
commit 08b06ccb40

View file

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