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
|
|
|
|
|
|
|
#
|
|
|
|
# Testing cleanup_invalid_links()
|
|
|
|
#
|
|
|
|
|
2011-11-24 11:28:09 -05:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use testutil;
|
|
|
|
require "chkstow";
|
2011-11-16 09:04:03 -05:00
|
|
|
|
|
|
|
use Test::More tests => 7;
|
|
|
|
use Test::Output;
|
|
|
|
use English qw(-no_match_vars);
|
|
|
|
|
2011-11-23 18:45:48 -05:00
|
|
|
init_test_dirs();
|
2019-06-27 19:53:12 -04:00
|
|
|
cd("$TEST_DIR/target");
|
2011-11-16 09:04:03 -05:00
|
|
|
|
|
|
|
# setup stow directory
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('stow');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_file('stow/.stow');
|
|
|
|
# perl
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('stow/perl/bin');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_file('stow/perl/bin/perl');
|
|
|
|
make_file('stow/perl/bin/a2p');
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('stow/perl/info');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_file('stow/perl/info/perl');
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('stow/perl/lib/perl');
|
|
|
|
make_path('stow/perl/man/man1');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_file('stow/perl/man/man1/perl.1');
|
|
|
|
# emacs
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('stow/emacs/bin');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_file('stow/emacs/bin/emacs');
|
|
|
|
make_file('stow/emacs/bin/etags');
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('stow/emacs/info');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_file('stow/emacs/info/emacs');
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('stow/emacs/libexec/emacs');
|
|
|
|
make_path('stow/emacs/man/man1');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_file('stow/emacs/man/man1/emacs.1');
|
|
|
|
|
|
|
|
#setup target directory
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('bin');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_link('bin/a2p', '../stow/perl/bin/a2p');
|
|
|
|
make_link('bin/emacs', '../stow/emacs/bin/emacs');
|
|
|
|
make_link('bin/etags', '../stow/emacs/bin/etags');
|
|
|
|
make_link('bin/perl', '../stow/perl/bin/perl');
|
|
|
|
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('info');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_link('info/emacs', '../stow/emacs/info/emacs');
|
|
|
|
make_link('info/perl', '../stow/perl/info/perl');
|
|
|
|
|
|
|
|
make_link('lib', 'stow/perl/lib');
|
|
|
|
make_link('libexec', 'stow/emacs/libexec');
|
|
|
|
|
2019-06-27 20:02:48 -04:00
|
|
|
make_path('man');
|
|
|
|
make_path('man/man1');
|
2011-11-16 09:04:03 -05:00
|
|
|
make_link('man/man1/emacs', '../../stow/emacs/man/man1/emacs.1');
|
|
|
|
make_link('man/man1/perl', '../../stow/perl/man/man1/perl.1');
|
|
|
|
|
|
|
|
sub run_chkstow() {
|
|
|
|
process_options();
|
|
|
|
check_stow();
|
|
|
|
}
|
|
|
|
|
2011-11-22 09:29:42 -05:00
|
|
|
local @ARGV = ('-t', '.', '-b');
|
2011-11-16 09:04:03 -05:00
|
|
|
stderr_like(
|
|
|
|
\&run_chkstow,
|
|
|
|
qr{\Askipping .*stow.*\z}xms,
|
|
|
|
"Skip directories containing .stow");
|
|
|
|
|
|
|
|
# squelch warn so that check_stow doesn't carp about skipping .stow all the time
|
2011-11-23 19:45:29 -05:00
|
|
|
$SIG{__WARN__} = sub { };
|
2011-11-16 09:04:03 -05:00
|
|
|
|
2011-11-22 09:29:42 -05:00
|
|
|
@ARGV = ('-t', '.', '-l');
|
2011-11-16 09:04:03 -05:00
|
|
|
stdout_like(
|
|
|
|
\&run_chkstow,
|
2011-11-16 09:51:38 -05:00
|
|
|
qr{emacs\nperl\nstow\n}xms,
|
2011-11-16 09:04:03 -05:00
|
|
|
"List packages");
|
|
|
|
|
2011-11-22 09:29:42 -05:00
|
|
|
@ARGV = ('-t', '.', '-b');
|
2011-11-16 09:04:03 -05:00
|
|
|
stdout_like(
|
|
|
|
\&run_chkstow,
|
|
|
|
qr{\A\z}xms,
|
|
|
|
"No bogus links exist");
|
|
|
|
|
2011-11-22 09:29:42 -05:00
|
|
|
@ARGV = ('-t', '.', '-a');
|
2011-11-16 09:04:03 -05:00
|
|
|
stdout_like(
|
|
|
|
\&run_chkstow,
|
|
|
|
qr{\A\z}xms,
|
|
|
|
"No aliens exist");
|
|
|
|
|
|
|
|
# Create an alien
|
|
|
|
make_file('bin/alien');
|
2011-11-22 09:29:42 -05:00
|
|
|
@ARGV = ('-t', '.', '-a');
|
2011-11-16 09:04:03 -05:00
|
|
|
stdout_like(
|
|
|
|
\&run_chkstow,
|
|
|
|
qr{Unstowed\ file:\ ./bin/alien}xms,
|
|
|
|
"Aliens exist");
|
|
|
|
|
2012-02-18 15:19:05 -05:00
|
|
|
make_invalid_link('bin/link', 'ireallyhopethisfiledoesn/t.exist');
|
2011-11-22 09:29:42 -05:00
|
|
|
@ARGV = ('-t', '.', '-b');
|
2011-11-16 09:04:03 -05:00
|
|
|
stdout_like(
|
|
|
|
\&run_chkstow,
|
|
|
|
qr{Bogus\ link:\ ./bin/link}xms,
|
|
|
|
"Bogus links exist");
|
|
|
|
|
2011-11-22 09:29:42 -05:00
|
|
|
@ARGV = ('-b');
|
2011-11-16 09:04:03 -05:00
|
|
|
process_options();
|
2011-11-24 11:28:09 -05:00
|
|
|
our $Target;
|
|
|
|
ok($Target == q{/usr/local},
|
2011-11-16 09:04:03 -05:00
|
|
|
"Default target is /usr/local/");
|