3 # This file is part of GNU Stow.
5 # GNU Stow is free software: you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # GNU Stow is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see https://www.gnu.org/licenses/.
19 # Testing cleanup_invalid_links()
28 use Test
::More tests
=> 7;
30 use English
qw(-no_match_vars);
33 cd
("$TEST_DIR/target");
35 # setup stow directory
37 make_file
('stow/.stow');
39 make_path
('stow/perl/bin');
40 make_file
('stow/perl/bin/perl');
41 make_file
('stow/perl/bin/a2p');
42 make_path
('stow/perl/info');
43 make_file
('stow/perl/info/perl');
44 make_path
('stow/perl/lib/perl');
45 make_path
('stow/perl/man/man1');
46 make_file
('stow/perl/man/man1/perl.1');
48 make_path
('stow/emacs/bin');
49 make_file
('stow/emacs/bin/emacs');
50 make_file
('stow/emacs/bin/etags');
51 make_path
('stow/emacs/info');
52 make_file
('stow/emacs/info/emacs');
53 make_path
('stow/emacs/libexec/emacs');
54 make_path
('stow/emacs/man/man1');
55 make_file
('stow/emacs/man/man1/emacs.1');
57 #setup target directory
59 make_link
('bin/a2p', '../stow/perl/bin/a2p');
60 make_link
('bin/emacs', '../stow/emacs/bin/emacs');
61 make_link
('bin/etags', '../stow/emacs/bin/etags');
62 make_link
('bin/perl', '../stow/perl/bin/perl');
65 make_link
('info/emacs', '../stow/emacs/info/emacs');
66 make_link
('info/perl', '../stow/perl/info/perl');
68 make_link
('lib', 'stow/perl/lib');
69 make_link
('libexec', 'stow/emacs/libexec');
72 make_path
('man/man1');
73 make_link
('man/man1/emacs', '../../stow/emacs/man/man1/emacs.1');
74 make_link
('man/man1/perl', '../../stow/perl/man/man1/perl.1');
81 local @ARGV = ('-t', '.', '-b');
84 qr{\Askipping .*stow.*\z}xms,
85 "Skip directories containing .stow");
87 # squelch warn so that check_stow doesn't carp about skipping .stow all the time
88 $SIG{__WARN__
} = sub { };
90 @ARGV = ('-t', '.', '-l');
93 qr{emacs\nperl\nstow\n}xms,
96 @ARGV = ('-t', '.', '-b');
100 "No bogus links exist");
102 @ARGV = ('-t', '.', '-a');
109 make_file
('bin/alien');
110 @ARGV = ('-t', '.', '-a');
113 qr{Unstowed\ file:\ ./bin/alien}xms,
116 make_invalid_link
('bin/link', 'ireallyhopethisfiledoesn/t.exist');
117 @ARGV = ('-t', '.', '-b');
120 qr{Bogus\ link:\ ./bin/link}xms,
121 "Bogus links exist");
126 ok
($Target == q{/usr/local},
127 "Default target is /usr/local/");