4 # Testing examples from the documentation
8 BEGIN { use lib
qw(.); require "t/util.pm"; require "stow"; }
10 use Test
::More tests
=> 4;
11 use English
qw(-no_match_vars);
24 eval { remove_dir
('t/target'); };
25 make_dir
('t/target/stow');
30 ## set up some fake packages to stow
33 make_dir
('stow/perl/bin');
34 make_file
('stow/perl/bin/perl');
35 make_file
('stow/perl/bin/a2p');
36 make_dir
('stow/perl/info');
37 make_file
('stow/perl/info/perl');
38 make_dir
('stow/perl/lib/perl');
39 make_dir
('stow/perl/man/man1');
40 make_file
('stow/perl/man/man1/perl.1');
43 make_dir
('stow/emacs/bin');
44 make_file
('stow/emacs/bin/emacs');
45 make_file
('stow/emacs/bin/etags');
46 make_dir
('stow/emacs/info');
47 make_file
('stow/emacs/info/emacs');
48 make_dir
('stow/emacs/libexec/emacs');
49 make_dir
('stow/emacs/man/man1');
50 make_file
('stow/emacs/man/man1/emacs.1');
53 # stow perl into an empty target
56 $Option{'verbose'} = 0;
58 make_dir
('stow/perl/bin');
59 make_file
('stow/perl/bin/perl');
60 make_file
('stow/perl/bin/a2p');
61 make_dir
('stow/perl/info');
62 make_dir
('stow/perl/lib/perl');
63 make_dir
('stow/perl/man/man1');
64 make_file
('stow/perl/man/man1/perl.1');
66 stow_contents
('stow/perl','./','stow/perl');
69 scalar(@Conflicts) == 0 &&
70 -l
'bin' && -l
'info' && -l
'lib' && -l
'man' &&
71 readlink('bin') eq 'stow/perl/bin' &&
72 readlink('info') eq 'stow/perl/info' &&
73 readlink('lib') eq 'stow/perl/lib' &&
74 readlink('man') eq 'stow/perl/man'
75 => 'stow perl into an empty target'
80 # stow perl into a non-empty target
83 $Option{'verbose'} = 0;
85 # clean up previous stow
95 stow_contents
('stow/perl','./','stow/perl');
98 scalar(@Conflicts) == 0 &&
99 -d
'bin' && -d
'lib' && -d
'man' && -d
'man/man1' &&
100 -l
'info' && -l
'bin/perl' && -l
'bin/a2p' &&
101 -l
'lib/perl' && -l
'man/man1/perl.1' &&
102 readlink('info') eq 'stow/perl/info' &&
103 readlink('bin/perl') eq '../stow/perl/bin/perl' &&
104 readlink('bin/a2p') eq '../stow/perl/bin/a2p' &&
105 readlink('lib/perl') eq '../stow/perl/lib/perl' &&
106 readlink('man/man1/perl.1') eq '../../stow/perl/man/man1/perl.1'
107 => 'stow perl into a non-empty target'
112 # Install perl into an empty target and then install emacs
115 $Option{'verbose'} = 0;
117 # clean up previous stow
123 stow_contents
('stow/perl', './','stow/perl');
124 stow_contents
('stow/emacs','./','stow/emacs');
127 scalar(@Conflicts) == 0 &&
133 readlink('bin/perl') eq '../stow/perl/bin/perl' &&
134 readlink('bin/a2p') eq '../stow/perl/bin/a2p' &&
135 readlink('bin/emacs') eq '../stow/emacs/bin/emacs' &&
136 readlink('bin/etags') eq '../stow/emacs/bin/etags' &&
141 readlink('info/perl') eq '../stow/perl/info/perl' &&
142 readlink('info/emacs') eq '../stow/emacs/info/emacs' &&
146 -l
'man/man1/perl.1' &&
147 -l
'man/man1/emacs.1' &&
148 readlink('man/man1/perl.1') eq '../../stow/perl/man/man1/perl.1' &&
149 readlink('man/man1/emacs.1') eq '../../stow/emacs/man/man1/emacs.1' &&
153 readlink('lib') eq 'stow/perl/lib' &&
154 readlink('libexec') eq 'stow/emacs/libexec' &&
156 => 'stow perl into an empty target, then stow emacs'
161 # 1. stowing a package with an empty directory
162 # 2. stow another package with the same directory but non empty
163 # 3. unstow the second package
164 # Q. the original empty directory should remain
165 # behaviour is the same as if the empty directory had nothing to do with stow
168 $Option{'verbose'} = 0;
170 make_dir
('stow/pkg1a/bin1');
171 make_dir
('stow/pkg1b/bin1');
172 make_file
('stow/pkg1b/bin1/file1b');
174 stow_contents
('stow/pkg1a', './', 'stow/pkg1a');
175 stow_contents
('stow/pkg1b', './', 'stow/pkg1b');
176 unstow_contents
('stow/pkg1b', './', 'stow/pkg1b');
180 scalar(@Conflicts) == 0 &&
182 => 'bug 1: stowing empty dirs'
187 # BUG 2: split open tree-folding symlinks pointing inside different stow
191 $Option{'verbose'} = 0;
193 make_dir
('stow2a/pkg2a/bin2');
194 make_file
('stow2a/pkg2a/bin2/file2a');
195 make_file
('stow2a/.stow');
196 make_dir
('stow2b/pkg2b/bin2');
197 make_file
('stow2b/pkg2b/bin2/file2b');
198 make_file
('stow2b/.stow');
200 stow_contents
('stow2a/pkg2a','./', 'stow2a/pkg2a');
201 stow_contents
('stow2b/pkg2b','./', 'stow2b/pkg2b');