t/dotfiles.t: switch to subtests
This commit is contained in:
parent
a328c2cd4b
commit
86f03d115d
1 changed files with 128 additions and 148 deletions
228
t/dotfiles.t
228
t/dotfiles.t
|
@ -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,177 +53,157 @@ 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);
|
||||||
|
make_path('../stow/dotfiles');
|
||||||
|
make_file('../stow/dotfiles/dot-foo');
|
||||||
|
|
||||||
$stow = new_Stow(dir => '../stow', dotfiles => 1);
|
$stow->plan_stow('dotfiles');
|
||||||
|
$stow->process_tasks();
|
||||||
make_path('../stow/dotfiles');
|
is(
|
||||||
make_file('../stow/dotfiles/dot-foo');
|
|
||||||
|
|
||||||
$stow->plan_stow('dotfiles');
|
|
||||||
$stow->process_tasks();
|
|
||||||
is(
|
|
||||||
readlink('.foo'),
|
readlink('.foo'),
|
||||||
'../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);
|
||||||
|
make_path('../stow/dotfiles');
|
||||||
|
make_file('../stow/dotfiles/dot-foo');
|
||||||
|
|
||||||
$stow = new_Stow(dir => '../stow', dotfiles => 0);
|
$stow->plan_stow('dotfiles');
|
||||||
|
$stow->process_tasks();
|
||||||
make_path('../stow/dotfiles');
|
is(
|
||||||
make_file('../stow/dotfiles/dot-foo');
|
|
||||||
|
|
||||||
$stow->plan_stow('dotfiles');
|
|
||||||
$stow->process_tasks();
|
|
||||||
is(
|
|
||||||
readlink('dot-foo'),
|
readlink('dot-foo'),
|
||||||
'../stow/dotfiles/dot-foo',
|
'../stow/dotfiles/dot-foo',
|
||||||
=> '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_file('../stow/dotfiles/dot-emacs/init.el');
|
||||||
|
|
||||||
make_path('../stow/dotfiles/dot-emacs');
|
$stow->plan_stow('dotfiles');
|
||||||
make_file('../stow/dotfiles/dot-emacs/init.el');
|
$stow->process_tasks();
|
||||||
|
is(
|
||||||
$stow->plan_stow('dotfiles');
|
|
||||||
$stow->process_tasks();
|
|
||||||
is(
|
|
||||||
readlink('.emacs'),
|
readlink('.emacs'),
|
||||||
'../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_file('../stow/dotfiles/dot-emacs.d/init.el');
|
||||||
|
make_path('.emacs.d');
|
||||||
|
|
||||||
make_path('../stow/dotfiles/dot-emacs.d');
|
$stow->plan_stow('dotfiles');
|
||||||
make_file('../stow/dotfiles/dot-emacs.d/init.el');
|
$stow->process_tasks();
|
||||||
make_path('.emacs.d');
|
is(
|
||||||
|
|
||||||
$stow->plan_stow('dotfiles');
|
|
||||||
$stow->process_tasks();
|
|
||||||
is(
|
|
||||||
readlink('.emacs.d/init.el'),
|
readlink('.emacs.d/init.el'),
|
||||||
'../../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_file('../stow/dotfiles/dot-emacs.d/dot-emacs.d/init.el');
|
||||||
|
make_path('.emacs.d');
|
||||||
|
|
||||||
make_path('../stow/dotfiles/dot-emacs.d/dot-emacs.d');
|
$stow->plan_stow('dotfiles');
|
||||||
make_file('../stow/dotfiles/dot-emacs.d/dot-emacs.d/init.el');
|
$stow->process_tasks();
|
||||||
make_path('.emacs.d');
|
is(
|
||||||
|
|
||||||
$stow->plan_stow('dotfiles');
|
|
||||||
$stow->process_tasks();
|
|
||||||
is(
|
|
||||||
readlink('.emacs.d/.emacs.d'),
|
readlink('.emacs.d/.emacs.d'),
|
||||||
'../../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_file('../stow/dotfiles/dot-one/dot-two/three');
|
||||||
|
make_path('.one/.two');
|
||||||
|
|
||||||
make_path('../stow/dotfiles/dot-one/dot-two');
|
$stow->plan_stow('dotfiles');
|
||||||
make_file('../stow/dotfiles/dot-one/dot-two/three');
|
$stow->process_tasks();
|
||||||
make_path('.one/.two');
|
is(
|
||||||
|
|
||||||
$stow->plan_stow('dotfiles');
|
|
||||||
$stow->process_tasks();
|
|
||||||
is(
|
|
||||||
readlink('./.one/.two/three'),
|
readlink('./.one/.two/three'),
|
||||||
'../../../stow/dotfiles/dot-one/dot-two/three',
|
'../../../stow/dotfiles/dot-one/dot-two/three',
|
||||||
=> '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_file('../stow/dotfiles/dot-');
|
||||||
|
|
||||||
make_path('../stow/dotfiles');
|
make_path('../stow/dotfiles/dot-.');
|
||||||
make_file('../stow/dotfiles/dot-');
|
make_file('../stow/dotfiles/dot-./foo');
|
||||||
|
|
||||||
make_path('../stow/dotfiles/dot-.');
|
$stow->plan_stow('dotfiles');
|
||||||
make_file('../stow/dotfiles/dot-./foo');
|
$stow->process_tasks();
|
||||||
|
is(
|
||||||
$stow->plan_stow('dotfiles');
|
|
||||||
$stow->process_tasks();
|
|
||||||
is(
|
|
||||||
readlink('dot-'),
|
readlink('dot-'),
|
||||||
'../stow/dotfiles/dot-',
|
'../stow/dotfiles/dot-',
|
||||||
=> 'processed dotfile'
|
=> 'processed dotfile'
|
||||||
);
|
);
|
||||||
is(
|
is(
|
||||||
readlink('dot-.'),
|
readlink('dot-.'),
|
||||||
'../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_file('../stow/dotfiles/dot-bar');
|
||||||
|
make_link('.bar', '../stow/dotfiles/dot-bar');
|
||||||
|
|
||||||
make_path('../stow/dotfiles');
|
$stow->plan_unstow('dotfiles');
|
||||||
make_file('../stow/dotfiles/dot-bar');
|
$stow->process_tasks();
|
||||||
make_link('.bar', '../stow/dotfiles/dot-bar');
|
is($stow->get_conflict_count, 0);
|
||||||
|
ok(-f '../stow/dotfiles/dot-bar');
|
||||||
|
ok(! -e '.bar' => 'unstow a simple dotfile');
|
||||||
|
});
|
||||||
|
|
||||||
$stow->plan_unstow('dotfiles');
|
subtest("unstow process folder marked with 'dot' prefix when directory exists is target", sub {
|
||||||
$stow->process_tasks();
|
plan tests => 4;
|
||||||
ok(
|
$stow = new_Stow(dir => '../stow', dotfiles => 1);
|
||||||
$stow->get_conflict_count == 0 &&
|
|
||||||
-f '../stow/dotfiles/dot-bar' && ! -e '.bar'
|
|
||||||
=> 'unstow a simple dotfile'
|
|
||||||
);
|
|
||||||
|
|
||||||
#
|
make_path('../stow/dotfiles/dot-emacs.d');
|
||||||
# unstow process folder marked with 'dot' prefix
|
make_file('../stow/dotfiles/dot-emacs.d/init.el');
|
||||||
# when directory exists is target
|
make_path('.emacs.d');
|
||||||
#
|
make_link('.emacs.d/init.el', '../../stow/dotfiles/dot-emacs.d/init.el');
|
||||||
|
|
||||||
$stow = new_Stow(dir => '../stow', dotfiles => 1);
|
$stow->plan_unstow('dotfiles');
|
||||||
|
$stow->process_tasks();
|
||||||
make_path('../stow/dotfiles/dot-emacs.d');
|
is($stow->get_conflict_count, 0);
|
||||||
make_file('../stow/dotfiles/dot-emacs.d/init.el');
|
ok(-f '../stow/dotfiles/dot-emacs.d/init.el');
|
||||||
make_path('.emacs.d');
|
ok(! -e '.emacs.d/init.el');
|
||||||
make_link('.emacs.d/init.el', '../../stow/dotfiles/dot-emacs.d/init.el');
|
ok(-d '.emacs.d/' => 'unstow dotfile folder when folder already exists');
|
||||||
|
});
|
||||||
$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'
|
|
||||||
);
|
|
||||||
|
|
Loading…
Reference in a new issue