2011-11-16 09:04:03 -05:00
|
|
|
#!/usr/local/bin/perl
|
|
|
|
|
|
|
|
#
|
|
|
|
# Testing core application
|
|
|
|
#
|
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
2011-11-16 09:04:03 -05:00
|
|
|
|
|
|
|
use Test::More tests => 10;
|
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
use testutil;
|
|
|
|
|
|
|
|
require 'stow';
|
|
|
|
|
2011-11-23 18:45:48 -05:00
|
|
|
init_test_dirs();
|
2011-11-24 11:28:09 -05:00
|
|
|
|
2011-11-16 09:04:03 -05:00
|
|
|
local @ARGV = (
|
|
|
|
'-v',
|
|
|
|
'-d t/stow',
|
|
|
|
'-t t/target',
|
|
|
|
'dummy'
|
|
|
|
);
|
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
my ($options, $pkgs_to_delete, $pkgs_to_stow) = process_options();
|
2011-11-16 09:04:03 -05:00
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
is($options->{verbose}, 1, 'verbose option');
|
|
|
|
is($options->{dir}, 't/stow', 'stow dir option');
|
2011-11-16 09:04:03 -05:00
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
my $stow = new_Stow(%$options);
|
2011-11-16 09:04:03 -05:00
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
is($stow->{stow_path}, "../stow" => 'stow dir');
|
|
|
|
is_deeply($pkgs_to_stow, [ 'dummy' ] => 'default to stow');
|
2011-11-16 09:04:03 -05:00
|
|
|
|
|
|
|
#
|
|
|
|
# Check mixed up package options
|
|
|
|
#
|
|
|
|
local @ARGV = (
|
|
|
|
'-v',
|
|
|
|
'-D', 'd1', 'd2',
|
|
|
|
'-S', 's1',
|
|
|
|
'-R', 'r1',
|
|
|
|
'-D', 'd3',
|
|
|
|
'-S', 's2', 's3',
|
|
|
|
'-R', 'r2',
|
|
|
|
);
|
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
($options, $pkgs_to_delete, $pkgs_to_stow) = process_options();
|
|
|
|
is_deeply($pkgs_to_delete, [ 'd1', 'd2', 'r1', 'd3', 'r2' ] => 'mixed deletes');
|
|
|
|
is_deeply($pkgs_to_stow, [ 's1', 'r1', 's2', 's3', 'r2' ] => 'mixed stows');
|
2011-11-16 09:04:03 -05:00
|
|
|
|
|
|
|
#
|
2011-11-24 11:28:09 -05:00
|
|
|
# Check setting deferred paths
|
2011-11-16 09:04:03 -05:00
|
|
|
#
|
|
|
|
local @ARGV = (
|
|
|
|
'--defer=man',
|
2011-11-24 11:28:09 -05:00
|
|
|
'--defer=info',
|
|
|
|
'dummy'
|
2011-11-16 09:04:03 -05:00
|
|
|
);
|
2011-11-24 11:28:09 -05:00
|
|
|
($options, $pkgs_to_delete, $pkgs_to_stow) = process_options();
|
|
|
|
is_deeply($options->{'defer'}, [ qr(\Aman), qr(\Ainfo) ] => 'defer man and info');
|
2011-11-16 09:04:03 -05:00
|
|
|
|
|
|
|
#
|
|
|
|
# Check setting override paths
|
|
|
|
#
|
|
|
|
local @ARGV = (
|
|
|
|
'--override=man',
|
2011-11-24 11:28:09 -05:00
|
|
|
'--override=info',
|
|
|
|
'dummy'
|
2011-11-16 09:04:03 -05:00
|
|
|
);
|
2011-11-24 11:28:09 -05:00
|
|
|
($options, $pkgs_to_delete, $pkgs_to_stow) = process_options();
|
|
|
|
is_deeply($options->{'override'}, [qr(\Aman), qr(\Ainfo)] => 'override man and info');
|
2011-11-16 09:04:03 -05:00
|
|
|
|
|
|
|
#
|
|
|
|
# Check stripping any matched quotes
|
|
|
|
#
|
|
|
|
local @ARGV = (
|
|
|
|
"--override='man'",
|
|
|
|
'--override="info"',
|
2011-11-24 11:28:09 -05:00
|
|
|
'dummy'
|
2011-11-16 09:04:03 -05:00
|
|
|
);
|
2011-11-24 11:28:09 -05:00
|
|
|
($options, $pkgs_to_delete, $pkgs_to_stow) = process_options();
|
|
|
|
is_deeply($options->{'override'}, [qr(\Aman), qr(\Ainfo)] => 'strip shell quoting');
|
2011-11-16 09:04:03 -05:00
|
|
|
|
|
|
|
#
|
|
|
|
# Check setting ignored paths
|
|
|
|
#
|
|
|
|
local @ARGV = (
|
|
|
|
'--ignore="~"',
|
2011-11-24 11:28:09 -05:00
|
|
|
'--ignore="\.#.*"',
|
|
|
|
'dummy'
|
2011-11-16 09:04:03 -05:00
|
|
|
);
|
2011-11-24 11:28:09 -05:00
|
|
|
($options, $pkgs_to_delete, $pkgs_to_stow) = process_options();
|
|
|
|
is_deeply($options->{'ignore'}, [ qr(~\z), qr(\.#.*\z) ] => 'ignore temp files');
|
2011-11-16 09:04:03 -05:00
|
|
|
|
|
|
|
|
|
|
|
# vim:ft=perl
|