Add NEWS entry for 2.1.0
[gnu-stow.git] / t / chkstow.t
blobbb611d852b5fbab28624988b7408bfc83f957210
1 #!/usr/local/bin/perl
4 # Testing cleanup_invalid_links()
7 use strict;
8 use warnings;
10 use testutil;
11 require "chkstow";
13 use Test::More tests => 7;
14 use Test::Output;
15 use English qw(-no_match_vars);
17 init_test_dirs();
18 cd("$OUT_DIR/target");
20 # setup stow directory
21 make_dir('stow');
22 make_file('stow/.stow');
23 # perl
24 make_dir('stow/perl/bin');
25 make_file('stow/perl/bin/perl');
26 make_file('stow/perl/bin/a2p');
27 make_dir('stow/perl/info');
28 make_file('stow/perl/info/perl');
29 make_dir('stow/perl/lib/perl');
30 make_dir('stow/perl/man/man1');
31 make_file('stow/perl/man/man1/perl.1');
32 # emacs
33 make_dir('stow/emacs/bin');
34 make_file('stow/emacs/bin/emacs');
35 make_file('stow/emacs/bin/etags');
36 make_dir('stow/emacs/info');
37 make_file('stow/emacs/info/emacs');
38 make_dir('stow/emacs/libexec/emacs');
39 make_dir('stow/emacs/man/man1');
40 make_file('stow/emacs/man/man1/emacs.1');
42 #setup target directory
43 make_dir('bin');
44 make_link('bin/a2p', '../stow/perl/bin/a2p');
45 make_link('bin/emacs', '../stow/emacs/bin/emacs');
46 make_link('bin/etags', '../stow/emacs/bin/etags');
47 make_link('bin/perl', '../stow/perl/bin/perl');
49 make_dir('info');
50 make_link('info/emacs', '../stow/emacs/info/emacs');
51 make_link('info/perl', '../stow/perl/info/perl');
53 make_link('lib', 'stow/perl/lib');
54 make_link('libexec', 'stow/emacs/libexec');
56 make_dir('man');
57 make_dir('man/man1');
58 make_link('man/man1/emacs', '../../stow/emacs/man/man1/emacs.1');
59 make_link('man/man1/perl', '../../stow/perl/man/man1/perl.1');
61 sub run_chkstow() {
62 process_options();
63 check_stow();
66 local @ARGV = ('-t', '.', '-b');
67 stderr_like(
68 \&run_chkstow,
69 qr{\Askipping .*stow.*\z}xms,
70 "Skip directories containing .stow");
72 # squelch warn so that check_stow doesn't carp about skipping .stow all the time
73 $SIG{__WARN__} = sub { };
75 @ARGV = ('-t', '.', '-l');
76 stdout_like(
77 \&run_chkstow,
78 qr{emacs\nperl\nstow\n}xms,
79 "List packages");
81 @ARGV = ('-t', '.', '-b');
82 stdout_like(
83 \&run_chkstow,
84 qr{\A\z}xms,
85 "No bogus links exist");
87 @ARGV = ('-t', '.', '-a');
88 stdout_like(
89 \&run_chkstow,
90 qr{\A\z}xms,
91 "No aliens exist");
93 # Create an alien
94 make_file('bin/alien');
95 @ARGV = ('-t', '.', '-a');
96 stdout_like(
97 \&run_chkstow,
98 qr{Unstowed\ file:\ ./bin/alien}xms,
99 "Aliens exist");
101 make_link('bin/link', 'ireallyhopethisfiledoesn/t.exist');
102 @ARGV = ('-t', '.', '-b');
103 stdout_like(
104 \&run_chkstow,
105 qr{Bogus\ link:\ ./bin/link}xms,
106 "Bogus links exist");
108 @ARGV = ('-b');
109 process_options();
110 our $Target;
111 ok($Target == q{/usr/local},
112 "Default target is /usr/local/");