Give up on automake's built-in rules for generating PDF and HTML and use our own.
[gnu-stow.git] / t / examples.t
blob42894ef05406d399a34a744d34fa878204aac301
1 #!/usr/local/bin/perl
4 # Testing examples from the documentation
7 use strict;
8 use warnings;
10 use testutil;
12 use Test::More tests => 10;
13 use English qw(-no_match_vars);
15 init_test_dirs();
16 cd("$OUT_DIR/target");
18 my $stow;
20 ## set up some fake packages to stow
22 # perl
23 make_dir('stow/perl/bin');
24 make_file('stow/perl/bin/perl');
25 make_file('stow/perl/bin/a2p');
26 make_dir('stow/perl/info');
27 make_file('stow/perl/info/perl');
28 make_dir('stow/perl/lib/perl');
29 make_dir('stow/perl/man/man1');
30 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');
43 # stow perl into an empty target
45 make_dir('stow/perl/bin');
46 make_file('stow/perl/bin/perl');
47 make_file('stow/perl/bin/a2p');
48 make_dir('stow/perl/info');
49 make_dir('stow/perl/lib/perl');
50 make_dir('stow/perl/man/man1');
51 make_file('stow/perl/man/man1/perl.1');
53 $stow = new_Stow(dir => 'stow');
54 $stow->plan_stow('perl');
55 $stow->process_tasks();
56 ok(
57 scalar($stow->get_conflicts) == 0 &&
58 -l 'bin' && -l 'info' && -l 'lib' && -l 'man' &&
59 readlink('bin') eq 'stow/perl/bin' &&
60 readlink('info') eq 'stow/perl/info' &&
61 readlink('lib') eq 'stow/perl/lib' &&
62 readlink('man') eq 'stow/perl/man'
63 => 'stow perl into an empty target'
67 # stow perl into a non-empty target
70 # clean up previous stow
71 remove_link('bin');
72 remove_link('info');
73 remove_link('lib');
74 remove_link('man');
76 make_dir('bin');
77 make_dir('lib');
78 make_dir('man/man1');
80 $stow = new_Stow(dir => 'stow');
81 $stow->plan_stow('perl');
82 $stow->process_tasks();
83 ok(
84 scalar($stow->get_conflicts) == 0 &&
85 -d 'bin' && -d 'lib' && -d 'man' && -d 'man/man1' &&
86 -l 'info' && -l 'bin/perl' && -l 'bin/a2p' &&
87 -l 'lib/perl' && -l 'man/man1/perl.1' &&
88 readlink('info') eq 'stow/perl/info' &&
89 readlink('bin/perl') eq '../stow/perl/bin/perl' &&
90 readlink('bin/a2p') eq '../stow/perl/bin/a2p' &&
91 readlink('lib/perl') eq '../stow/perl/lib/perl' &&
92 readlink('man/man1/perl.1') eq '../../stow/perl/man/man1/perl.1'
93 => 'stow perl into a non-empty target'
94 );
98 # Install perl into an empty target and then install emacs
101 # clean up previous stow
102 remove_link('info');
103 remove_dir('bin');
104 remove_dir('lib');
105 remove_dir('man');
107 $stow = new_Stow(dir => 'stow');
108 $stow->plan_stow('perl', 'emacs');
109 $stow->process_tasks();
110 is(scalar($stow->get_conflicts), 0, 'no conflicts');
112 -d 'bin' &&
113 -l 'bin/perl' &&
114 -l 'bin/emacs' &&
115 -l 'bin/a2p' &&
116 -l 'bin/etags' &&
117 readlink('bin/perl') eq '../stow/perl/bin/perl' &&
118 readlink('bin/a2p') eq '../stow/perl/bin/a2p' &&
119 readlink('bin/emacs') eq '../stow/emacs/bin/emacs' &&
120 readlink('bin/etags') eq '../stow/emacs/bin/etags' &&
122 -d 'info' &&
123 -l 'info/perl' &&
124 -l 'info/emacs' &&
125 readlink('info/perl') eq '../stow/perl/info/perl' &&
126 readlink('info/emacs') eq '../stow/emacs/info/emacs' &&
128 -d 'man' &&
129 -d 'man/man1' &&
130 -l 'man/man1/perl.1' &&
131 -l 'man/man1/emacs.1' &&
132 readlink('man/man1/perl.1') eq '../../stow/perl/man/man1/perl.1' &&
133 readlink('man/man1/emacs.1') eq '../../stow/emacs/man/man1/emacs.1' &&
135 -l 'lib' &&
136 -l 'libexec' &&
137 readlink('lib') eq 'stow/perl/lib' &&
138 readlink('libexec') eq 'stow/emacs/libexec' &&
140 => 'stow perl into an empty target, then stow emacs'
144 # BUG 1:
145 # 1. stowing a package with an empty directory
146 # 2. stow another package with the same directory but non empty
147 # 3. unstow the second package
148 # Q. the original empty directory should remain
149 # behaviour is the same as if the empty directory had nothing to do with stow
152 make_dir('stow/pkg1a/bin1');
153 make_dir('stow/pkg1b/bin1');
154 make_file('stow/pkg1b/bin1/file1b');
156 $stow = new_Stow(dir => 'stow');
157 $stow->plan_stow('pkg1a', 'pkg1b');
158 $stow->plan_unstow('pkg1b');
159 $stow->process_tasks();
160 is(scalar($stow->get_conflicts), 0, 'no conflicts stowing empty dirs');
161 ok(-d 'bin1' => 'bug 1: stowing empty dirs');
164 # BUG 2: split open tree-folding symlinks pointing inside different stow
165 # directories
167 make_dir('stow2a/pkg2a/bin2');
168 make_file('stow2a/pkg2a/bin2/file2a');
169 make_file('stow2a/.stow');
170 make_dir('stow2b/pkg2b/bin2');
171 make_file('stow2b/pkg2b/bin2/file2b');
172 make_file('stow2b/.stow');
174 $stow = new_Stow(dir => 'stow2a');
175 $stow->plan_stow('pkg2a');
176 $stow->set_stow_dir('stow2b');
177 $stow->plan_stow('pkg2b');
178 $stow->process_tasks();
180 is(scalar($stow->get_conflicts), 0, 'no conflicts splitting tree-folding symlinks');
181 ok(-d 'bin2' => 'tree got split by packages from multiple stow directories');
182 ok(-f 'bin2/file2a' => 'file from 1st stow dir');
183 ok(-f 'bin2/file2b' => 'file from 2nd stow dir');
185 ## Finish this test