t/dotfiles.t: switch to subtests

This commit is contained in:
Adam Spiers 2024-04-01 02:30:47 +01:00
parent a328c2cd4b
commit 86f03d115d

View file

@ -22,7 +22,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 11; use Test::More tests => 10;
use English qw(-no_match_vars); use English qw(-no_match_vars);
use Stow::Util qw(adjust_dotfile); use Stow::Util qw(adjust_dotfile);
@ -53,12 +53,9 @@ subtest('adjust_dotfile()', sub {
my $stow; my $stow;
# subtest("stow a dotfile marked with 'dot' prefix", sub {
# stow a dotfile marked with 'dot' prefix plan tests => 1;
#
$stow = new_Stow(dir => '../stow', dotfiles => 1); $stow = new_Stow(dir => '../stow', dotfiles => 1);
make_path('../stow/dotfiles'); make_path('../stow/dotfiles');
make_file('../stow/dotfiles/dot-foo'); make_file('../stow/dotfiles/dot-foo');
@ -69,13 +66,11 @@ is(
'../stow/dotfiles/dot-foo', '../stow/dotfiles/dot-foo',
=> 'processed dotfile' => 'processed dotfile'
); );
});
# subtest("ensure that turning off dotfile processing links files as usual", sub {
# ensure that turning off dotfile processing links files as usual plan tests => 1;
#
$stow = new_Stow(dir => '../stow', dotfiles => 0); $stow = new_Stow(dir => '../stow', dotfiles => 0);
make_path('../stow/dotfiles'); make_path('../stow/dotfiles');
make_file('../stow/dotfiles/dot-foo'); make_file('../stow/dotfiles/dot-foo');
@ -87,11 +82,10 @@ is(
=> 'unprocessed dotfile' => 'unprocessed dotfile'
); );
});
# subtest("stow folder marked with 'dot' prefix", sub {
# stow folder marked with 'dot' prefix plan tests => 1;
#
$stow = new_Stow(dir => '../stow', dotfiles => 1); $stow = new_Stow(dir => '../stow', dotfiles => 1);
make_path('../stow/dotfiles/dot-emacs'); make_path('../stow/dotfiles/dot-emacs');
@ -104,12 +98,10 @@ is(
'../stow/dotfiles/dot-emacs', '../stow/dotfiles/dot-emacs',
=> 'processed dotfile folder' => 'processed dotfile folder'
); );
});
# subtest("process folder marked with 'dot' prefix when directory exists is target", sub {
# process folder marked with 'dot' prefix plan tests => 1;
# when directory exists is target
#
$stow = new_Stow(dir => '../stow', dotfiles => 1); $stow = new_Stow(dir => '../stow', dotfiles => 1);
make_path('../stow/dotfiles/dot-emacs.d'); make_path('../stow/dotfiles/dot-emacs.d');
@ -123,12 +115,10 @@ is(
'../../stow/dotfiles/dot-emacs.d/init.el', '../../stow/dotfiles/dot-emacs.d/init.el',
=> 'processed dotfile folder when folder exists (1 level)' => 'processed dotfile folder when folder exists (1 level)'
); );
});
# subtest("process folder marked with 'dot' prefix when directory exists is target (2 levels)", sub {
# process folder marked with 'dot' prefix plan tests => 1;
# when directory exists is target (2 levels)
#
$stow = new_Stow(dir => '../stow', dotfiles => 1); $stow = new_Stow(dir => '../stow', dotfiles => 1);
make_path('../stow/dotfiles/dot-emacs.d/dot-emacs.d'); make_path('../stow/dotfiles/dot-emacs.d/dot-emacs.d');
@ -142,12 +132,10 @@ is(
'../../stow/dotfiles/dot-emacs.d/dot-emacs.d', '../../stow/dotfiles/dot-emacs.d/dot-emacs.d',
=> 'processed dotfile folder exists (2 levels)' => 'processed dotfile folder exists (2 levels)'
); );
});
# subtest("process folder marked with 'dot' prefix when directory exists is target", sub {
# process folder marked with 'dot' prefix plan tests => 1;
# when directory exists is target
#
$stow = new_Stow(dir => '../stow', dotfiles => 1); $stow = new_Stow(dir => '../stow', dotfiles => 1);
make_path('../stow/dotfiles/dot-one/dot-two'); make_path('../stow/dotfiles/dot-one/dot-two');
@ -162,11 +150,10 @@ is(
=> 'processed dotfile 2 folder exists (2 levels)' => 'processed dotfile 2 folder exists (2 levels)'
); );
});
# subtest("dot-. should not have that part expanded.", sub {
# "$DOT_PREFIX." should not have that part expanded. plan tests => 2;
#
$stow = new_Stow(dir => '../stow', dotfiles => 1); $stow = new_Stow(dir => '../stow', dotfiles => 1);
make_path('../stow/dotfiles'); make_path('../stow/dotfiles');
@ -187,11 +174,10 @@ is(
'../stow/dotfiles/dot-.', '../stow/dotfiles/dot-.',
=> 'unprocessed dotfile' => 'unprocessed dotfile'
); );
});
# subtest("simple unstow scenario", sub {
# simple unstow scenario plan tests => 3;
#
$stow = new_Stow(dir => '../stow', dotfiles => 1); $stow = new_Stow(dir => '../stow', dotfiles => 1);
make_path('../stow/dotfiles'); make_path('../stow/dotfiles');
@ -200,17 +186,13 @@ make_link('.bar', '../stow/dotfiles/dot-bar');
$stow->plan_unstow('dotfiles'); $stow->plan_unstow('dotfiles');
$stow->process_tasks(); $stow->process_tasks();
ok( is($stow->get_conflict_count, 0);
$stow->get_conflict_count == 0 && ok(-f '../stow/dotfiles/dot-bar');
-f '../stow/dotfiles/dot-bar' && ! -e '.bar' ok(! -e '.bar' => 'unstow a simple dotfile');
=> 'unstow a simple dotfile' });
);
#
# unstow process folder marked with 'dot' prefix
# when directory exists is target
#
subtest("unstow process folder marked with 'dot' prefix when directory exists is target", sub {
plan tests => 4;
$stow = new_Stow(dir => '../stow', dotfiles => 1); $stow = new_Stow(dir => '../stow', dotfiles => 1);
make_path('../stow/dotfiles/dot-emacs.d'); make_path('../stow/dotfiles/dot-emacs.d');
@ -220,10 +202,8 @@ make_link('.emacs.d/init.el', '../../stow/dotfiles/dot-emacs.d/init.el');
$stow->plan_unstow('dotfiles'); $stow->plan_unstow('dotfiles');
$stow->process_tasks(); $stow->process_tasks();
ok( is($stow->get_conflict_count, 0);
$stow->get_conflict_count == 0 && ok(-f '../stow/dotfiles/dot-emacs.d/init.el');
-f '../stow/dotfiles/dot-emacs.d/init.el' && ok(! -e '.emacs.d/init.el');
! -e '.emacs.d/init.el' && ok(-d '.emacs.d/' => 'unstow dotfile folder when folder already exists');
-d '.emacs.d/' });
=> 'unstow dotfile folder when folder already exists'
);