Use File::Spec->abs2rel() instead of home-grown relative_path
[gnu-stow.git] / t / stow.t
blob49d671ada1c2d3b94e5d6a5290fb298e39dc78f6
1 #!/usr/local/bin/perl
4 # Testing core application
7 # load as a library
8 BEGIN { use lib qw(.); require "t/util.pm"; require "stow"; }
10 use Test::More tests => 10;
12 local @ARGV = (
13 '-v',
14 '-d t/stow',
15 '-t t/target',
16 'dummy'
19 ### setup
20 eval { remove_dir('t/target'); };
21 eval { remove_dir('t/stow'); };
22 make_dir('t/target');
23 make_dir('t/stow');
25 ok eval {process_options(); 1} => 'process options';
26 ok eval {set_stow_path(); 1} => 'set stow path';
28 is($Stow_Path,"../stow" => 'stow dir');
29 is_deeply(\@Pkgs_To_Stow, [ 'dummy' ] => 'default to stow');
33 # Check mixed up package options
35 %Option=();
36 local @ARGV = (
37 '-v',
38 '-D', 'd1', 'd2',
39 '-S', 's1',
40 '-R', 'r1',
41 '-D', 'd3',
42 '-S', 's2', 's3',
43 '-R', 'r2',
46 @Pkgs_To_Stow = ();
47 @Pkgs_To_Delete = ();
48 process_options();
49 is_deeply(\@Pkgs_To_Delete, [ 'd1', 'd2', 'r1', 'd3', 'r2' ] => 'mixed deletes');
50 is_deeply(\@Pkgs_To_Stow, [ 's1', 'r1', 's2', 's3', 'r2' ] => 'mixed stows');
53 # Check setting defered paths
55 %Option=();
56 local @ARGV = (
57 '--defer=man',
58 '--defer=info'
60 process_options();
61 is_deeply($Option{'defer'}, [ qr(\Aman), qr(\Ainfo) ] => 'defer man and info');
64 # Check setting override paths
66 %Option=();
67 local @ARGV = (
68 '--override=man',
69 '--override=info'
71 process_options();
72 is_deeply($Option{'override'}, [qr(\Aman), qr(\Ainfo)] => 'override man and info');
75 # Check stripping any matched quotes
77 %Option=();
78 local @ARGV = (
79 "--override='man'",
80 '--override="info"',
82 process_options();
83 is_deeply($Option{'override'}, [qr(\Aman), qr(\Ainfo)] => 'strip shell quoting');
86 # Check setting ignored paths
88 %Option=();
89 local @ARGV = (
90 '--ignore="~"',
91 '--ignore="\.#.*"'
93 process_options();
94 is_deeply($Option{'ignore'}, [ qr(~\z), qr(\.#.*\z) ] => 'ignore temp files');
97 # vim:ft=perl