8 BEGIN { use lib
qw(.); require "t/util.pm"; require "stow"; }
10 use Test
::More tests
=> 14;
12 use English
qw(-no_match_vars);
15 eval { remove_dir
('t/target'); };
16 eval { remove_dir
('t/stow'); };
21 $Stow_Path= '../stow';
23 # Note that each of the following tests use a distinct set of files
26 # stow a simple tree minimally
29 $Option{'verbose'} = 0;
31 make_dir
('../stow/pkg1/bin1');
32 make_file
('../stow/pkg1/bin1/file1');
33 stow_contents
('../stow/pkg1', './', '../stow/pkg1');
38 => 'minimal stow of a simple tree'
42 # stow a simple tree into an existing directory
45 $Option{'verbose'} = 0;
47 make_dir
('../stow/pkg2/lib2');
48 make_file
('../stow/pkg2/lib2/file2');
50 stow_contents
('../stow/pkg2', '.', '../stow/pkg2');
53 readlink('lib2/file2'),
54 '../../stow/pkg2/lib2/file2',
55 => 'stow simple tree to existing directory'
59 # unfold existing tree
62 $Option{'verbose'} = 0;
64 make_dir
('../stow/pkg3a/bin3');
65 make_file
('../stow/pkg3a/bin3/file3a');
66 make_link
('bin3' => '../stow/pkg3a/bin3'); # emulate stow
68 make_dir
('../stow/pkg3b/bin3');
69 make_file
('../stow/pkg3b/bin3/file3b');
70 stow_contents
('../stow/pkg3b', './', '../stow/pkg3b');
74 readlink('bin3/file3a') eq '../../stow/pkg3a/bin3/file3a' &&
75 readlink('bin3/file3b') eq '../../stow/pkg3b/bin3/file3b'
76 => 'target already has 1 stowed package'
80 # Link to a new dir conflicts with existing non-dir (can't unfold)
83 $Option{'verbose'} = 0;
85 make_file
('bin4'); # this is a file but named like a directory
86 make_dir
('../stow/pkg4/bin4');
87 make_file
('../stow/pkg4/bin4/file4');
88 stow_contents
('../stow/pkg4', './', '../stow/pkg4');
90 $Conflicts[-1], qr
(CONFLICT
:.*existing target is neither a
link nor a directory
)
91 => 'link to new dir conflicts with existing non-directory'
95 # Target already exists but is not owned by stow
98 $Option{'verbose'} = 0;
101 make_link
('bin5/file5','../../empty');
102 make_dir
('../stow/pkg5/bin5/file5');
103 stow_contents
('../stow/pkg5', './', '../stow/pkg5');
105 $Conflicts[-1], qr
(CONFLICT
:.*not owned by stow
)
106 => 'target already exists but is not owned by stow'
110 # Replace existing but invalid target
113 $Option{'verbose'} = 0;
115 make_link
('file6','../stow/path-does-not-exist');
116 make_dir
('../stow/pkg6');
117 make_file
('../stow/pkg6/file6');
118 eval{ stow_contents
('../stow/pkg6', './', '../stow/pkg6'); process_tasks
() };
122 => 'replace existing but invalid target'
126 # Target already exists, is owned by stow, but points to a non-directory
130 $Option{'verbose'} = 0;
133 make_dir
('../stow/pkg7a/bin7');
134 make_file
('../stow/pkg7a/bin7/node7');
135 make_link
('bin7/node7','../../stow/pkg7a/bin7/node7');
136 make_dir
('../stow/pkg7b/bin7/node7');
137 make_file
('../stow/pkg7b/bin7/node7/file7');
138 stow_contents
('../stow/pkg7b', './', '../stow/pkg7b');
140 $Conflicts[-1], qr
(CONFLICT
:.*existing target is stowed to a different
package)
141 => 'link to new dir conflicts with existing stowed non-directory'
145 # stowing directories named 0
148 $Option{'verbose'} = 0;
150 make_dir
('../stow/pkg8a/0');
151 make_file
('../stow/pkg8a/0/file8a');
152 make_link
('0' => '../stow/pkg8a/0'); # emulate stow
154 make_dir
('../stow/pkg8b/0');
155 make_file
('../stow/pkg8b/0/file8b');
156 stow_contents
('../stow/pkg8b', './', '../stow/pkg8b');
159 scalar(@Conflicts) == 0 &&
161 readlink('0/file8a') eq '../../stow/pkg8a/0/file8a' &&
162 readlink('0/file8b') eq '../../stow/pkg8b/0/file8b'
163 => 'stowing directories named 0'
167 # overriding already stowed documentation
170 $Option{'verbose'} = 0;
171 $Option{'override'} = ['man9', 'info9'];
173 make_dir
('../stow/pkg9a/man9/man1');
174 make_file
('../stow/pkg9a/man9/man1/file9.1');
175 make_dir
('man9/man1');
176 make_link
('man9/man1/file9.1' => '../../../stow/pkg9a/man9/man1/file9.1'); # emulate stow
178 make_dir
('../stow/pkg9b/man9/man1');
179 make_file
('../stow/pkg9b/man9/man1/file9.1');
180 stow_contents
('../stow/pkg9b', './', '../stow/pkg9b');
183 scalar(@Conflicts) == 0 &&
184 readlink('man9/man1/file9.1') eq '../../../stow/pkg9b/man9/man1/file9.1'
185 => 'overriding existing documentation files'
189 # deferring to already stowed documentation
192 $Option{'verbose'} = 0;
193 $Option{'defer'} = ['man10', 'info10'];
195 make_dir
('../stow/pkg10a/man10/man1');
196 make_file
('../stow/pkg10a/man10/man1/file10.1');
197 make_dir
('man10/man1');
198 make_link
('man10/man1/file10.1' => '../../../stow/pkg10a/man10/man1/file10.1'); # emulate stow
200 make_dir
('../stow/pkg10b/man10/man1');
201 make_file
('../stow/pkg10b/man10/man1/file10.1');
202 stow_contents
('../stow/pkg10b', './', '../stow/pkg10b');
204 sub { process_tasks
(); },
205 qr/There are no outstanding operations to perform/,
206 'no tasks to process'
209 scalar(@Conflicts) == 0 &&
210 readlink('man10/man1/file10.1') eq '../../../stow/pkg10a/man10/man1/file10.1'
211 => 'defer to existing documentation files'
218 $Option{'verbose'} = 0;
219 $Option{'ignore'} = ['~', '\.#.*'];
221 make_dir
('../stow/pkg11/man11/man1');
222 make_file
('../stow/pkg11/man11/man1/file11.1');
223 make_file
('../stow/pkg11/man11/man1/file11.1~');
224 make_file
('../stow/pkg11/man11/man1/.#file11.1');
225 make_dir
('man11/man1');
227 stow_contents
('../stow/pkg11', './', '../stow/pkg11');
230 scalar(@Conflicts) == 0 &&
231 readlink('man11/man1/file11.1') eq '../../../stow/pkg11/man11/man1/file11.1' &&
232 !-e
'man11/man1/file11.1~' &&
233 !-e
'man11/man1/.#file11.1'
234 => 'ignore temp files'
238 # stowing links library files
241 $Option{'verbose'} = 0;
243 make_dir
('../stow/pkg12/lib12/');
244 make_file
('../stow/pkg12/lib12/lib.so');
245 make_link
('../stow/pkg12/lib12/lib.so.1','lib.so');
248 stow_contents
('../stow/pkg12', './', '../stow/pkg12');
251 scalar(@Conflicts) == 0 &&
252 readlink('lib12/lib.so.1') eq '../../stow/pkg12/lib12/lib.so.1'
253 => 'stow links to libraries'
257 # unfolding to stow links to library files
260 $Option{'verbose'} = 0;
262 make_dir
('../stow/pkg13a/lib13/');
263 make_file
('../stow/pkg13a/lib13/liba.so');
264 make_link
('../stow/pkg13a/lib13/liba.so.1', 'liba.so');
265 make_link
('lib13','../stow/pkg13a/lib13');
267 make_dir
('../stow/pkg13b/lib13/');
268 make_file
('../stow/pkg13b/lib13/libb.so');
269 make_link
('../stow/pkg13b/lib13/libb.so.1', 'libb.so');
271 stow_contents
('../stow/pkg13b', './', '../stow/pkg13b');
274 scalar(@Conflicts) == 0 &&
275 readlink('lib13/liba.so.1') eq '../../stow/pkg13a/lib13/liba.so.1' &&
276 readlink('lib13/libb.so.1') eq '../../stow/pkg13b/lib13/libb.so.1'
277 => 'unfolding to stow links to libraries'