4 # Testing unstow_contents()
8 BEGIN { use lib
qw(.); require "t/util.pm"; require "stow"; }
10 use Test
::More tests
=> 11;
11 use English
qw(-no_match_vars);
24 eval { remove_dir
('t/target'); };
25 eval { remove_dir
('t/stow'); };
30 $Stow_Path= '../stow';
32 # Note that each of the following tests use a distinct set of files
35 # unstow a simple tree minimally
39 $Option{'verbose'} = 0;
41 make_dir
('../stow/pkg1/bin1');
42 make_file
('../stow/pkg1/bin1/file1');
43 make_link
('bin1','../stow/pkg1/bin1');
45 unstow_contents
('../stow/pkg1','./');
48 scalar(@Conflicts) == 0 &&
49 -f
'../stow/pkg1/bin1/file1' && ! -e
'bin1'
50 => 'unstow a simple tree'
54 # unstow a simple tree from an existing directory
57 $Option{'verbose'} = 0;
60 make_dir
('../stow/pkg2/lib2');
61 make_file
('../stow/pkg2/lib2/file2');
62 make_link
('lib2/file2', '../../stow/pkg2/lib2/file2');
63 unstow_contents
('../stow/pkg2','./');
66 scalar(@Conflicts) == 0 &&
67 -f
'../stow/pkg2/lib2/file2' && -d
'lib2'
68 => 'unstow simple tree from a pre-existing directory'
72 # fold tree after unstowing
75 $Option{'verbose'} = 0;
79 make_dir
('../stow/pkg3a/bin3');
80 make_file
('../stow/pkg3a/bin3/file3a');
81 make_link
('bin3/file3a' => '../../stow/pkg3a/bin3/file3a'); # emulate stow
83 make_dir
('../stow/pkg3b/bin3');
84 make_file
('../stow/pkg3b/bin3/file3b');
85 make_link
('bin3/file3b' => '../../stow/pkg3b/bin3/file3b'); # emulate stow
86 unstow_contents
('../stow/pkg3b', './');
89 scalar(@Conflicts) == 0 &&
91 readlink('bin3') eq '../stow/pkg3a/bin3'
92 => 'fold tree after unstowing'
96 # existing link is owned by stow but is invalid so it gets removed anyway
99 $Option{'verbose'} = 0;
102 make_dir
('../stow/pkg4/bin4');
103 make_file
('../stow/pkg4/bin4/file4');
104 make_link
('bin4/file4', '../../stow/pkg4/bin4/does-not-exist');
106 unstow_contents
('../stow/pkg4', './');
109 scalar(@Conflicts) == 0 &&
111 => q
(remove invalid
link owned by stow
)
115 # Existing link is not owned by stow
118 $Option{'verbose'} = 0;
120 make_dir
('../stow/pkg5/bin5');
121 make_link
('bin5', '../not-stow');
123 unstow_contents
('../stow/pkg5', './');
125 $Conflicts[-1], qr
(CONFLICT
:.*existing target is
not owned by stow
)
126 => q
(existing
link not owned by stow
)
129 # Target already exists, is owned by stow, but points to a different package
132 $Option{'verbose'} = 0;
135 make_dir
('../stow/pkg6a/bin6');
136 make_file
('../stow/pkg6a/bin6/file6');
137 make_link
('bin6/file6', '../../stow/pkg6a/bin6/file6');
139 make_dir
('../stow/pkg6b/bin6');
140 make_file
('../stow/pkg6b/bin6/file6');
142 unstow_contents
('../stow/pkg6b', './');
144 scalar(@Conflicts) == 0 &&
146 readlink('bin6/file6') eq '../../stow/pkg6a/bin6/file6'
147 => q
(ignore existing
link that points to a different
package)
151 # Don't unlink anything under the stow directory
154 $Option{'verbose'} = 0;
156 make_dir
('stow'); # make out stow dir a subdir of target
159 # emulate stowing into ourself (bizzare corner case or accident)
160 make_dir
('stow/pkg7a/stow/pkg7b');
161 make_file
('stow/pkg7a/stow/pkg7b/file7b');
162 make_link
('stow/pkg7b', '../stow/pkg7a/stow/pkg7b');
164 unstow_contents
('stow/pkg7b', './');
167 scalar(@Conflicts) == 0 &&
169 readlink('stow/pkg7b') eq '../stow/pkg7a/stow/pkg7b'
170 => q
(don
't unlink any nodes under the stow directory)
174 # Don't
unlink any nodes under another stow directory
177 $Option{'verbose'} = 0;
179 make_dir
('stow'); # make out stow dir a subdir of target
182 make_dir
('stow2'); # make our alternate stow dir a subdir of target
183 make_file
('stow2/.stow');
185 # emulate stowing into ourself (bizzare corner case or accident)
186 make_dir
('stow/pkg8a/stow2/pkg8b');
187 make_file
('stow/pkg8a/stow2/pkg8b/file8b');
188 make_link
('stow2/pkg8b', '../stow/pkg8a/stow2/pkg8b');
190 unstow_contents
('stow/pkg8a', './');
193 scalar(@Conflicts) == 0 &&
195 readlink('stow2/pkg8b') eq '../stow/pkg8a/stow2/pkg8b'
196 => q
(don
't unlink any nodes under another stow directory)
200 # overriding already stowed documentation
203 $Stow_Path = '../stow
';
204 $Option{'verbose
'} = 0;
205 $Option{'override
'} = ['man9
', 'info9
'];
207 make_dir('../stow/pkg
9a
/man9/man
1');
208 make_file('../stow/pkg
9a
/man9/man
1/file9
.1
');
209 make_dir('man9
/man1
');
210 make_link('man9
/man1/file9
.1
' => '../../../stow/pkg
9a
/man9/man
1/file9
.1
'); # emulate stow
212 make_dir('../stow/pkg
9b
/man9/man
1');
213 make_file('../stow/pkg
9b
/man9/man
1/file9
.1
');
214 unstow_contents('../stow/pkg
9b
', './');
217 scalar(@Conflicts) == 0 &&
218 !-l 'man9
/man1/file9
.1
'
219 => 'overriding existing documentation files
'
223 # deferring to already stowed documentation
226 $Option{'verbose
'} = 0;
227 $Option{'defer
'} = ['man10
', 'info10
'];
229 make_dir('../stow/pkg
10a
/man10/man
1');
230 make_file('../stow/pkg
10a
/man10/man
1/file10a
.1');
231 make_dir('man10
/man1
');
232 make_link('man10
/man1/file10a
.1' => '../../../stow/pkg
10a
/man10/man
1/file10a
.1');
234 # need this to block folding
235 make_dir('../stow/pkg
10b
/man10/man
1');
236 make_file('../stow/pkg
10b
/man10/man
1/file10b
.1');
237 make_link('man10
/man1/file10b
.1' => '../../../stow/pkg
10b
/man10/man
1/file10b
.1');
240 make_dir('../stow/pkg
10c
/man10/man
1');
241 make_file('../stow/pkg
10c
/man10/man
1/file10a
.1');
242 unstow_contents('../stow/pkg
10c
', './');
245 scalar(@Conflicts) == 0 &&
246 readlink('man10
/man1/file10a
.1') eq '../../../stow/pkg
10a
/man10/man
1/file10a
.1'
247 => 'defer to existing documentation files
'
254 $Option{'verbose
'} = 0;
255 $Option{'ignore
'} = ['~', '\
.#.*'];
257 make_dir
('../stow/pkg12/man12/man1');
258 make_file
('../stow/pkg12/man12/man1/file12.1');
259 make_file
('../stow/pkg12/man12/man1/file12.1~');
260 make_file
('../stow/pkg12/man12/man1/.#file12.1');
261 make_dir
('man12/man1');
262 make_link
('man12/man1/file12.1' => '../../../stow/pkg12/man12/man1/file12.1');
264 unstow_contents
('../stow/pkg12', './');
267 scalar(@Conflicts) == 0 &&
268 !-e
'man12/man1/file12.1'
269 => 'ignore temp files'
275 # Test cleaning up subdirs with --paranoid option