t/dotfiles.t: switch to subtests
This commit is contained in:
parent
a328c2cd4b
commit
86f03d115d
1 changed files with 128 additions and 148 deletions
90
t/dotfiles.t
90
t/dotfiles.t
|
@ -22,7 +22,7 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Test::More tests => 11;
|
||||
use Test::More tests => 10;
|
||||
use English qw(-no_match_vars);
|
||||
|
||||
use Stow::Util qw(adjust_dotfile);
|
||||
|
@ -53,12 +53,9 @@ subtest('adjust_dotfile()', sub {
|
|||
|
||||
my $stow;
|
||||
|
||||
#
|
||||
# stow a dotfile marked with 'dot' prefix
|
||||
#
|
||||
|
||||
subtest("stow a dotfile marked with 'dot' prefix", sub {
|
||||
plan tests => 1;
|
||||
$stow = new_Stow(dir => '../stow', dotfiles => 1);
|
||||
|
||||
make_path('../stow/dotfiles');
|
||||
make_file('../stow/dotfiles/dot-foo');
|
||||
|
||||
|
@ -69,13 +66,11 @@ is(
|
|||
'../stow/dotfiles/dot-foo',
|
||||
=> 'processed dotfile'
|
||||
);
|
||||
});
|
||||
|
||||
#
|
||||
# ensure that turning off dotfile processing links files as usual
|
||||
#
|
||||
|
||||
subtest("ensure that turning off dotfile processing links files as usual", sub {
|
||||
plan tests => 1;
|
||||
$stow = new_Stow(dir => '../stow', dotfiles => 0);
|
||||
|
||||
make_path('../stow/dotfiles');
|
||||
make_file('../stow/dotfiles/dot-foo');
|
||||
|
||||
|
@ -87,11 +82,10 @@ is(
|
|||
=> 'unprocessed dotfile'
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
#
|
||||
# stow folder marked with 'dot' prefix
|
||||
#
|
||||
|
||||
subtest("stow folder marked with 'dot' prefix", sub {
|
||||
plan tests => 1;
|
||||
$stow = new_Stow(dir => '../stow', dotfiles => 1);
|
||||
|
||||
make_path('../stow/dotfiles/dot-emacs');
|
||||
|
@ -104,12 +98,10 @@ is(
|
|||
'../stow/dotfiles/dot-emacs',
|
||||
=> 'processed dotfile folder'
|
||||
);
|
||||
});
|
||||
|
||||
#
|
||||
# process folder marked with 'dot' prefix
|
||||
# when directory exists is target
|
||||
#
|
||||
|
||||
subtest("process folder marked with 'dot' prefix when directory exists is target", sub {
|
||||
plan tests => 1;
|
||||
$stow = new_Stow(dir => '../stow', dotfiles => 1);
|
||||
|
||||
make_path('../stow/dotfiles/dot-emacs.d');
|
||||
|
@ -123,12 +115,10 @@ is(
|
|||
'../../stow/dotfiles/dot-emacs.d/init.el',
|
||||
=> 'processed dotfile folder when folder exists (1 level)'
|
||||
);
|
||||
});
|
||||
|
||||
#
|
||||
# process folder marked with 'dot' prefix
|
||||
# when directory exists is target (2 levels)
|
||||
#
|
||||
|
||||
subtest("process folder marked with 'dot' prefix when directory exists is target (2 levels)", sub {
|
||||
plan tests => 1;
|
||||
$stow = new_Stow(dir => '../stow', dotfiles => 1);
|
||||
|
||||
make_path('../stow/dotfiles/dot-emacs.d/dot-emacs.d');
|
||||
|
@ -142,12 +132,10 @@ is(
|
|||
'../../stow/dotfiles/dot-emacs.d/dot-emacs.d',
|
||||
=> 'processed dotfile folder exists (2 levels)'
|
||||
);
|
||||
});
|
||||
|
||||
#
|
||||
# process folder marked with 'dot' prefix
|
||||
# when directory exists is target
|
||||
#
|
||||
|
||||
subtest("process folder marked with 'dot' prefix when directory exists is target", sub {
|
||||
plan tests => 1;
|
||||
$stow = new_Stow(dir => '../stow', dotfiles => 1);
|
||||
|
||||
make_path('../stow/dotfiles/dot-one/dot-two');
|
||||
|
@ -162,11 +150,10 @@ is(
|
|||
=> 'processed dotfile 2 folder exists (2 levels)'
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
#
|
||||
# "$DOT_PREFIX." should not have that part expanded.
|
||||
#
|
||||
|
||||
subtest("dot-. should not have that part expanded.", sub {
|
||||
plan tests => 2;
|
||||
$stow = new_Stow(dir => '../stow', dotfiles => 1);
|
||||
|
||||
make_path('../stow/dotfiles');
|
||||
|
@ -187,11 +174,10 @@ is(
|
|||
'../stow/dotfiles/dot-.',
|
||||
=> 'unprocessed dotfile'
|
||||
);
|
||||
});
|
||||
|
||||
#
|
||||
# simple unstow scenario
|
||||
#
|
||||
|
||||
subtest("simple unstow scenario", sub {
|
||||
plan tests => 3;
|
||||
$stow = new_Stow(dir => '../stow', dotfiles => 1);
|
||||
|
||||
make_path('../stow/dotfiles');
|
||||
|
@ -200,17 +186,13 @@ make_link('.bar', '../stow/dotfiles/dot-bar');
|
|||
|
||||
$stow->plan_unstow('dotfiles');
|
||||
$stow->process_tasks();
|
||||
ok(
|
||||
$stow->get_conflict_count == 0 &&
|
||||
-f '../stow/dotfiles/dot-bar' && ! -e '.bar'
|
||||
=> 'unstow a simple dotfile'
|
||||
);
|
||||
|
||||
#
|
||||
# unstow process folder marked with 'dot' prefix
|
||||
# when directory exists is target
|
||||
#
|
||||
is($stow->get_conflict_count, 0);
|
||||
ok(-f '../stow/dotfiles/dot-bar');
|
||||
ok(! -e '.bar' => 'unstow a simple dotfile');
|
||||
});
|
||||
|
||||
subtest("unstow process folder marked with 'dot' prefix when directory exists is target", sub {
|
||||
plan tests => 4;
|
||||
$stow = new_Stow(dir => '../stow', dotfiles => 1);
|
||||
|
||||
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->process_tasks();
|
||||
ok(
|
||||
$stow->get_conflict_count == 0 &&
|
||||
-f '../stow/dotfiles/dot-emacs.d/init.el' &&
|
||||
! -e '.emacs.d/init.el' &&
|
||||
-d '.emacs.d/'
|
||||
=> 'unstow dotfile folder when folder already exists'
|
||||
);
|
||||
is($stow->get_conflict_count, 0);
|
||||
ok(-f '../stow/dotfiles/dot-emacs.d/init.el');
|
||||
ok(! -e '.emacs.d/init.el');
|
||||
ok(-d '.emacs.d/' => 'unstow dotfile folder when folder already exists');
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue