2019-06-27 15:37:50 -04:00
|
|
|
#!/usr/bin/perl
|
2019-06-27 09:02:19 -04:00
|
|
|
#
|
|
|
|
# This file is part of GNU Stow.
|
|
|
|
#
|
|
|
|
# GNU Stow is free software: you can redistribute it and/or modify it
|
|
|
|
# under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# GNU Stow is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see https://www.gnu.org/licenses/.
|
2011-11-16 09:04:03 -05:00
|
|
|
|
|
|
|
#
|
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
|
|
|
|
2016-07-14 12:37:42 -04:00
|
|
|
use Test::More tests => 10;
|
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
|
|
|
|
2016-07-14 12:37:42 -04:00
|
|
|
#
|
|
|
|
# Check that expansion not applied.
|
|
|
|
#
|
|
|
|
local @ARGV = (
|
|
|
|
"--target=$OUT_DIR/".'$HOME',
|
|
|
|
'dummy'
|
|
|
|
);
|
|
|
|
make_dir("$OUT_DIR/".'$HOME');
|
|
|
|
($options, $pkgs_to_delete, $pkgs_to_stow) = process_options();
|
|
|
|
is($options->{target}, "$OUT_DIR/".'$HOME', 'no expansion');
|
|
|
|
remove_dir("$OUT_DIR/".'$HOME');
|
2011-11-16 09:04:03 -05:00
|
|
|
|
|
|
|
# vim:ft=perl
|