2011-11-16 09:04:03 -05:00
|
|
|
#!/usr/local/bin/perl
|
|
|
|
|
|
|
|
#
|
2012-01-09 16:31:46 -05:00
|
|
|
# Test processing of CLI options.
|
2011-11-16 09:04:03 -05:00
|
|
|
#
|
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
2011-11-16 09:04:03 -05:00
|
|
|
|
2011-11-26 11:32:25 -05:00
|
|
|
use Test::More tests => 9;
|
2011-11-16 09:04:03 -05:00
|
|
|
|
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',
|
2015-11-12 23:57:21 -05:00
|
|
|
'-d', "$OUT_DIR/stow",
|
|
|
|
'-t', "$OUT_DIR/target",
|
2011-11-16 09:04:03 -05:00
|
|
|
'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');
|
2011-11-24 11:32:01 -05:00
|
|
|
is($options->{dir}, "$OUT_DIR/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();
|
2011-11-23 19:45:29 -05:00
|
|
|
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();
|
2011-11-23 19:45:29 -05:00
|
|
|
is_deeply($options->{override}, [qr(\Aman), qr(\Ainfo)] => 'override man and info');
|
2011-11-16 09:04:03 -05:00
|
|
|
|
|
|
|
#
|
|
|
|
# Check setting ignored paths
|
|
|
|
#
|
|
|
|
local @ARGV = (
|
2011-11-26 11:32:25 -05:00
|
|
|
'--ignore=~',
|
|
|
|
'--ignore=\.#.*',
|
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();
|
2011-11-23 19:45:29 -05:00
|
|
|
is_deeply($options->{ignore}, [ qr(~\z), qr(\.#.*\z) ] => 'ignore temp files');
|
2011-11-16 09:04:03 -05:00
|
|
|
|
|
|
|
|
|
|
|
# vim:ft=perl
|