Numerous fixes so that `make distcheck' succeeds.
Moves temporary test trees into a separate directory.
This commit is contained in:
parent
0db112441f
commit
10ea9c6f4b
15 changed files with 158 additions and 103 deletions
|
@ -15,7 +15,7 @@ use Test::Output;
|
|||
use English qw(-no_match_vars);
|
||||
|
||||
init_test_dirs();
|
||||
cd('t/target');
|
||||
cd("$OUT_DIR/target");
|
||||
|
||||
# setup stow directory
|
||||
make_dir('stow');
|
||||
|
|
|
@ -13,7 +13,7 @@ use English qw(-no_match_vars);
|
|||
use testutil;
|
||||
|
||||
init_test_dirs();
|
||||
cd('t/target');
|
||||
cd("$OUT_DIR/target");
|
||||
|
||||
my $stow;
|
||||
|
||||
|
|
|
@ -11,6 +11,9 @@ use testutil;
|
|||
|
||||
use Test::More tests => 4;
|
||||
|
||||
init_test_dirs();
|
||||
cd("$OUT_DIR/target");
|
||||
|
||||
my $stow;
|
||||
|
||||
$stow = new_Stow(defer => [ 'man' ]);
|
||||
|
|
|
@ -13,7 +13,7 @@ use Test::More tests => 10;
|
|||
use English qw(-no_match_vars);
|
||||
|
||||
init_test_dirs();
|
||||
cd('t/target');
|
||||
cd("$OUT_DIR/target");
|
||||
|
||||
my $stow;
|
||||
|
||||
|
|
|
@ -13,15 +13,15 @@ use Test::More tests => 6;
|
|||
|
||||
init_test_dirs();
|
||||
|
||||
my $stow = new_Stow(dir => 't/stow');
|
||||
my $stow = new_Stow(dir => "$OUT_DIR/stow");
|
||||
|
||||
is_deeply(
|
||||
[ $stow->find_stowed_path('t/target/a/b/c', '../../../stow/a/b/c') ],
|
||||
[ 't/stow/a/b/c', 't/stow', 'a' ]
|
||||
[ $stow->find_stowed_path("$OUT_DIR/target/a/b/c", '../../../stow/a/b/c') ],
|
||||
[ "$OUT_DIR/stow/a/b/c", "$OUT_DIR/stow", 'a' ]
|
||||
=> 'from root'
|
||||
);
|
||||
|
||||
cd('t/target');
|
||||
cd("$OUT_DIR/target");
|
||||
$stow->set_stow_dir('../stow');
|
||||
is_deeply(
|
||||
[ $stow->find_stowed_path('a/b/c','../../../stow/a/b/c') ],
|
||||
|
@ -31,33 +31,33 @@ is_deeply(
|
|||
|
||||
make_dir('stow');
|
||||
cd('../..');
|
||||
$stow->set_stow_dir('t/target/stow');
|
||||
$stow->set_stow_dir("$OUT_DIR/target/stow");
|
||||
|
||||
is_deeply(
|
||||
[ $stow->find_stowed_path('t/target/a/b/c', '../../stow/a/b/c') ],
|
||||
[ 't/target/stow/a/b/c', 't/target/stow', 'a' ]
|
||||
[ $stow->find_stowed_path("$OUT_DIR/target/a/b/c", '../../stow/a/b/c') ],
|
||||
[ "$OUT_DIR/target/stow/a/b/c", "$OUT_DIR/target/stow", 'a' ]
|
||||
=> 'stow is subdir of target directory'
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
[ $stow->find_stowed_path('t/target/a/b/c','../../empty') ],
|
||||
[ $stow->find_stowed_path("$OUT_DIR/target/a/b/c",'../../empty') ],
|
||||
[ '', '', '' ]
|
||||
=> 'target is not stowed'
|
||||
);
|
||||
|
||||
make_dir('t/target/stow2');
|
||||
make_file('t/target/stow2/.stow');
|
||||
make_dir("$OUT_DIR/target/stow2");
|
||||
make_file("$OUT_DIR/target/stow2/.stow");
|
||||
|
||||
is_deeply(
|
||||
[ $stow->find_stowed_path('t/target/a/b/c','../../stow2/a/b/c') ],
|
||||
[ 't/target/stow2/a/b/c', 't/target/stow2', 'a' ]
|
||||
[ $stow->find_stowed_path("$OUT_DIR/target/a/b/c",'../../stow2/a/b/c') ],
|
||||
[ "$OUT_DIR/target/stow2/a/b/c", "$OUT_DIR/target/stow2", 'a' ]
|
||||
=> q(detect alternate stow directory)
|
||||
);
|
||||
|
||||
# Possible corner case with rogue symlink pointing to ancestor of
|
||||
# stow dir.
|
||||
is_deeply(
|
||||
[ $stow->find_stowed_path('t/target/a/b/c','../../..') ],
|
||||
[ $stow->find_stowed_path("$OUT_DIR/target/a/b/c",'../../..') ],
|
||||
[ '', '', '' ]
|
||||
=> q(corner case - link points to ancestor of stow dir)
|
||||
);
|
||||
|
|
|
@ -13,7 +13,7 @@ use Test::More tests => 4;
|
|||
use English qw(-no_match_vars);
|
||||
|
||||
init_test_dirs();
|
||||
cd('t/target');
|
||||
cd("$OUT_DIR/target");
|
||||
|
||||
my $stow = new_Stow(dir => '../stow');
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ use testutil;
|
|||
use Stow::Util qw(join_paths);
|
||||
|
||||
init_test_dirs();
|
||||
cd('t/target');
|
||||
cd("$OUT_DIR/target");
|
||||
|
||||
my $stow = new_Stow();
|
||||
|
||||
|
|
6
t/stow.t
6
t/stow.t
|
@ -17,15 +17,15 @@ init_test_dirs();
|
|||
|
||||
local @ARGV = (
|
||||
'-v',
|
||||
'-d t/stow',
|
||||
'-t t/target',
|
||||
"-d $OUT_DIR/stow",
|
||||
"-t $OUT_DIR/target",
|
||||
'dummy'
|
||||
);
|
||||
|
||||
my ($options, $pkgs_to_delete, $pkgs_to_stow) = process_options();
|
||||
|
||||
is($options->{verbose}, 1, 'verbose option');
|
||||
is($options->{dir}, 't/stow', 'stow dir option');
|
||||
is($options->{dir}, "$OUT_DIR/stow", 'stow dir option');
|
||||
|
||||
my $stow = new_Stow(%$options);
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ use Stow::Util qw(canon_path);
|
|||
use testutil;
|
||||
|
||||
init_test_dirs();
|
||||
cd('t/target');
|
||||
cd("$OUT_DIR/target");
|
||||
|
||||
my $stow;
|
||||
my @conflicts;
|
||||
|
@ -293,16 +293,16 @@ ok(
|
|||
# stow a simple tree minimally when cwd isn't target
|
||||
#
|
||||
cd('../..');
|
||||
$stow = new_Stow(dir => 't/stow', target => 't/target');
|
||||
$stow = new_Stow(dir => "$OUT_DIR/stow", target => "$OUT_DIR/target");
|
||||
|
||||
make_dir('t/stow/pkg16/bin16');
|
||||
make_file('t/stow/pkg16/bin16/file16');
|
||||
make_dir("$OUT_DIR/stow/pkg16/bin16");
|
||||
make_file("$OUT_DIR/stow/pkg16/bin16/file16");
|
||||
|
||||
$stow->plan_stow('pkg16');
|
||||
$stow->process_tasks();
|
||||
is($stow->get_conflicts(), 0, 'no conflicts with minimal stow');
|
||||
is(
|
||||
readlink('t/target/bin16'),
|
||||
readlink("$OUT_DIR/target/bin16"),
|
||||
'../stow/pkg16/bin16',
|
||||
=> "minimal stow of a simple tree when cwd isn't target"
|
||||
);
|
||||
|
@ -311,17 +311,17 @@ is(
|
|||
# stow a simple tree minimally to absolute stow dir when cwd isn't
|
||||
# target
|
||||
#
|
||||
$stow = new_Stow(dir => canon_path('t/stow'),
|
||||
target => 't/target');
|
||||
$stow = new_Stow(dir => canon_path("$OUT_DIR/stow"),
|
||||
target => "$OUT_DIR/target");
|
||||
|
||||
make_dir('t/stow/pkg17/bin17');
|
||||
make_file('t/stow/pkg17/bin17/file17');
|
||||
make_dir("$OUT_DIR/stow/pkg17/bin17");
|
||||
make_file("$OUT_DIR/stow/pkg17/bin17/file17");
|
||||
|
||||
$stow->plan_stow('pkg17');
|
||||
$stow->process_tasks();
|
||||
is($stow->get_conflicts(), 0, 'no conflicts with minimal stow');
|
||||
is(
|
||||
readlink('t/target/bin17'),
|
||||
readlink("$OUT_DIR/target/bin17"),
|
||||
'../stow/pkg17/bin17',
|
||||
=> "minimal stow of a simple tree with absolute stow dir"
|
||||
);
|
||||
|
@ -330,17 +330,17 @@ is(
|
|||
# stow a simple tree minimally with absolute stow AND target dirs when
|
||||
# cwd isn't target
|
||||
#
|
||||
$stow = new_Stow(dir => canon_path('t/stow'),
|
||||
target => canon_path('t/target'));
|
||||
$stow = new_Stow(dir => canon_path("$OUT_DIR/stow"),
|
||||
target => canon_path("$OUT_DIR/target"));
|
||||
|
||||
make_dir('t/stow/pkg18/bin18');
|
||||
make_file('t/stow/pkg18/bin18/file18');
|
||||
make_dir("$OUT_DIR/stow/pkg18/bin18");
|
||||
make_file("$OUT_DIR/stow/pkg18/bin18/file18");
|
||||
|
||||
$stow->plan_stow('pkg18');
|
||||
$stow->process_tasks();
|
||||
is($stow->get_conflicts(), 0, 'no conflicts with minimal stow');
|
||||
is(
|
||||
readlink('t/target/bin18'),
|
||||
readlink("$OUT_DIR/target/bin18"),
|
||||
'../stow/pkg18/bin18',
|
||||
=> "minimal stow of a simple tree with absolute stow and target dirs"
|
||||
);
|
||||
|
|
|
@ -4,17 +4,28 @@
|
|||
# Utilities shared by test scripts
|
||||
#
|
||||
|
||||
package testutil;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Stow;
|
||||
use Stow::Util qw(parent);
|
||||
use Stow::Util qw(parent canon_path);
|
||||
|
||||
use base qw(Exporter);
|
||||
our @EXPORT = qw(
|
||||
$OUT_DIR
|
||||
init_test_dirs
|
||||
cd
|
||||
new_Stow new_compat_Stow
|
||||
make_dir make_link make_file
|
||||
remove_dir remove_link
|
||||
);
|
||||
|
||||
our $OUT_DIR = 'tmp-testing-trees';
|
||||
|
||||
sub init_test_dirs {
|
||||
die "t/ didn't exist; are you running the tests from the root of the tree?\n"
|
||||
unless -d 't';
|
||||
|
||||
for my $dir ('t/target', 't/stow') {
|
||||
for my $dir ("$OUT_DIR/target", "$OUT_DIR/stow") {
|
||||
-d $dir and remove_dir($dir);
|
||||
make_dir($dir);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ use testutil;
|
|||
use Stow::Util qw(canon_path);
|
||||
|
||||
init_test_dirs();
|
||||
cd('t/target');
|
||||
cd("$OUT_DIR/target");
|
||||
|
||||
# Note that each of the following tests use a distinct set of files
|
||||
|
||||
|
@ -273,8 +273,8 @@ ok(
|
|||
# Unstow a never stowed package
|
||||
#
|
||||
|
||||
eval { remove_dir('t/target'); };
|
||||
mkdir('t/target');
|
||||
eval { remove_dir("$OUT_DIR/target"); };
|
||||
mkdir("$OUT_DIR/target");
|
||||
|
||||
$stow = new_Stow();
|
||||
$stow->plan_unstow('pkg12');
|
||||
|
@ -311,17 +311,17 @@ ok(
|
|||
# unstow a simple tree minimally when cwd isn't target
|
||||
#
|
||||
cd('../..');
|
||||
$stow = new_Stow(dir => 't/stow', target => 't/target');
|
||||
$stow = new_Stow(dir => "$OUT_DIR/stow", target => "$OUT_DIR/target");
|
||||
|
||||
make_dir('t/stow/pkg13/bin13');
|
||||
make_file('t/stow/pkg13/bin13/file13');
|
||||
make_link('t/target/bin13', '../stow/pkg13/bin13');
|
||||
make_dir("$OUT_DIR/stow/pkg13/bin13");
|
||||
make_file("$OUT_DIR/stow/pkg13/bin13/file13");
|
||||
make_link("$OUT_DIR/target/bin13", '../stow/pkg13/bin13');
|
||||
|
||||
$stow->plan_unstow('pkg13');
|
||||
$stow->process_tasks();
|
||||
ok(
|
||||
scalar($stow->get_conflicts) == 0 &&
|
||||
-f 't/stow/pkg13/bin13/file13' && ! -e 't/target/bin13'
|
||||
-f "$OUT_DIR/stow/pkg13/bin13/file13" && ! -e "$OUT_DIR/target/bin13"
|
||||
=> 'unstow a simple tree'
|
||||
);
|
||||
|
||||
|
@ -329,18 +329,18 @@ ok(
|
|||
# unstow a simple tree minimally with absolute stow dir when cwd isn't
|
||||
# target
|
||||
#
|
||||
$stow = new_Stow(dir => canon_path('t/stow'),
|
||||
target => 't/target');
|
||||
$stow = new_Stow(dir => canon_path("$OUT_DIR/stow"),
|
||||
target => "$OUT_DIR/target");
|
||||
|
||||
make_dir('t/stow/pkg14/bin14');
|
||||
make_file('t/stow/pkg14/bin14/file14');
|
||||
make_link('t/target/bin14', '../stow/pkg14/bin14');
|
||||
make_dir("$OUT_DIR/stow/pkg14/bin14");
|
||||
make_file("$OUT_DIR/stow/pkg14/bin14/file14");
|
||||
make_link("$OUT_DIR/target/bin14", '../stow/pkg14/bin14');
|
||||
|
||||
$stow->plan_unstow('pkg14');
|
||||
$stow->process_tasks();
|
||||
ok(
|
||||
scalar($stow->get_conflicts) == 0 &&
|
||||
-f 't/stow/pkg14/bin14/file14' && ! -e 't/target/bin14'
|
||||
-f "$OUT_DIR/stow/pkg14/bin14/file14" && ! -e "$OUT_DIR/target/bin14"
|
||||
=> 'unstow a simple tree with absolute stow dir'
|
||||
);
|
||||
|
||||
|
@ -348,18 +348,18 @@ ok(
|
|||
# unstow a simple tree minimally with absolute stow AND target dirs
|
||||
# when cwd isn't target
|
||||
#
|
||||
$stow = new_Stow(dir => canon_path('t/stow'),
|
||||
target => canon_path('t/target'));
|
||||
$stow = new_Stow(dir => canon_path("$OUT_DIR/stow"),
|
||||
target => canon_path("$OUT_DIR/target"));
|
||||
|
||||
make_dir('t/stow/pkg15/bin15');
|
||||
make_file('t/stow/pkg15/bin15/file15');
|
||||
make_link('t/target/bin15', '../stow/pkg15/bin15');
|
||||
make_dir("$OUT_DIR/stow/pkg15/bin15");
|
||||
make_file("$OUT_DIR/stow/pkg15/bin15/file15");
|
||||
make_link("$OUT_DIR/target/bin15", '../stow/pkg15/bin15');
|
||||
|
||||
$stow->plan_unstow('pkg15');
|
||||
$stow->process_tasks();
|
||||
ok(
|
||||
scalar($stow->get_conflicts) == 0 &&
|
||||
-f 't/stow/pkg15/bin15/file15' && ! -e 't/target/bin15'
|
||||
-f "$OUT_DIR/stow/pkg15/bin15/file15" && ! -e "$OUT_DIR/target/bin15"
|
||||
=> 'unstow a simple tree with absolute stow and target dirs'
|
||||
);
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ use testutil;
|
|||
use Stow::Util qw(canon_path);
|
||||
|
||||
init_test_dirs();
|
||||
cd('t/target');
|
||||
cd("$OUT_DIR/target");
|
||||
|
||||
# Note that each of the following tests use a distinct set of files
|
||||
|
||||
|
@ -280,8 +280,8 @@ ok(
|
|||
# Unstow a never stowed package
|
||||
#
|
||||
|
||||
eval { remove_dir('t/target'); };
|
||||
mkdir('t/target');
|
||||
eval { remove_dir("$OUT_DIR/target"); };
|
||||
mkdir("$OUT_DIR/target");
|
||||
|
||||
$stow = new_compat_Stow();
|
||||
$stow->plan_unstow('pkg12');
|
||||
|
@ -318,17 +318,17 @@ ok(
|
|||
# unstow a simple tree minimally when cwd isn't target
|
||||
#
|
||||
cd('../..');
|
||||
$stow = new_Stow(dir => 't/stow', target => 't/target');
|
||||
$stow = new_Stow(dir => "$OUT_DIR/stow", target => "$OUT_DIR/target");
|
||||
|
||||
make_dir('t/stow/pkg13/bin13');
|
||||
make_file('t/stow/pkg13/bin13/file13');
|
||||
make_link('t/target/bin13', '../stow/pkg13/bin13');
|
||||
make_dir("$OUT_DIR/stow/pkg13/bin13");
|
||||
make_file("$OUT_DIR/stow/pkg13/bin13/file13");
|
||||
make_link("$OUT_DIR/target/bin13", '../stow/pkg13/bin13');
|
||||
|
||||
$stow->plan_unstow('pkg13');
|
||||
$stow->process_tasks();
|
||||
ok(
|
||||
scalar($stow->get_conflicts) == 0 &&
|
||||
-f 't/stow/pkg13/bin13/file13' && ! -e 't/target/bin13'
|
||||
-f "$OUT_DIR/stow/pkg13/bin13/file13" && ! -e "$OUT_DIR/target/bin13"
|
||||
=> 'unstow a simple tree'
|
||||
);
|
||||
|
||||
|
@ -336,18 +336,18 @@ ok(
|
|||
# unstow a simple tree minimally with absolute stow dir when cwd isn't
|
||||
# target
|
||||
#
|
||||
$stow = new_Stow(dir => canon_path('t/stow'),
|
||||
target => 't/target');
|
||||
$stow = new_Stow(dir => canon_path("$OUT_DIR/stow"),
|
||||
target => "$OUT_DIR/target");
|
||||
|
||||
make_dir('t/stow/pkg14/bin14');
|
||||
make_file('t/stow/pkg14/bin14/file14');
|
||||
make_link('t/target/bin14', '../stow/pkg14/bin14');
|
||||
make_dir("$OUT_DIR/stow/pkg14/bin14");
|
||||
make_file("$OUT_DIR/stow/pkg14/bin14/file14");
|
||||
make_link("$OUT_DIR/target/bin14", '../stow/pkg14/bin14');
|
||||
|
||||
$stow->plan_unstow('pkg14');
|
||||
$stow->process_tasks();
|
||||
ok(
|
||||
scalar($stow->get_conflicts) == 0 &&
|
||||
-f 't/stow/pkg14/bin14/file14' && ! -e 't/target/bin14'
|
||||
-f "$OUT_DIR/stow/pkg14/bin14/file14" && ! -e "$OUT_DIR/target/bin14"
|
||||
=> 'unstow a simple tree with absolute stow dir'
|
||||
);
|
||||
|
||||
|
@ -355,18 +355,18 @@ ok(
|
|||
# unstow a simple tree minimally with absolute stow AND target dirs
|
||||
# when cwd isn't target
|
||||
#
|
||||
$stow = new_Stow(dir => canon_path('t/stow'),
|
||||
target => canon_path('t/target'));
|
||||
$stow = new_Stow(dir => canon_path("$OUT_DIR/stow"),
|
||||
target => canon_path("$OUT_DIR/target"));
|
||||
|
||||
make_dir('t/stow/pkg15/bin15');
|
||||
make_file('t/stow/pkg15/bin15/file15');
|
||||
make_link('t/target/bin15', '../stow/pkg15/bin15');
|
||||
make_dir("$OUT_DIR/stow/pkg15/bin15");
|
||||
make_file("$OUT_DIR/stow/pkg15/bin15/file15");
|
||||
make_link("$OUT_DIR/target/bin15", '../stow/pkg15/bin15');
|
||||
|
||||
$stow->plan_unstow('pkg15');
|
||||
$stow->process_tasks();
|
||||
ok(
|
||||
scalar($stow->get_conflicts) == 0 &&
|
||||
-f 't/stow/pkg15/bin15/file15' && ! -e 't/target/bin15'
|
||||
-f "$OUT_DIR/stow/pkg15/bin15/file15" && ! -e "$OUT_DIR/target/bin15"
|
||||
=> 'unstow a simple tree with absolute stow and target dirs'
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue