4 # Testing examples from the documentation
12 use Test
::More tests
=> 10;
13 use English
qw(-no_match_vars);
16 cd
("$OUT_DIR/target");
20 ## set up some fake packages to stow
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');
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();
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
80 $stow = new_Stow
(dir
=> 'stow');
81 $stow->plan_stow('perl');
82 $stow->process_tasks();
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'
98 # Install perl into an empty target and then install emacs
101 # clean up previous stow
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');
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' &&
125 readlink('info/perl') eq '../stow/perl/info/perl' &&
126 readlink('info/emacs') eq '../stow/emacs/info/emacs' &&
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' &&
137 readlink('lib') eq 'stow/perl/lib' &&
138 readlink('libexec') eq 'stow/emacs/libexec' &&
140 => 'stow perl into an empty target, then stow emacs'
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
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');