4 # Testing cleanup_invalid_links()
8 BEGIN { use lib
qw(.); require "t/util.pm"; require "stow"; }
10 use Test
::More tests
=> 3;
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 # nothing to clean in a simple tree
38 $Option{'verbose'} = 1;
40 make_dir
('../stow/pkg1/bin1');
41 make_file
('../stow/pkg1/bin1/file1');
42 make_link
('bin1','../stow/pkg1/bin1');
44 cleanup_invalid_links
('./');
51 # cleanup a bad link in a simple tree
54 $Option{'verbose'} = 0;
57 make_dir
('../stow/pkg2/bin2');
58 make_file
('../stow/pkg2/bin2/file2a');
59 make_link
('bin2/file2a','../../stow/pkg2/bin2/file2a');
60 make_link
('bin2/file2b','../../stow/pkg2/bin2/file2b');
62 cleanup_invalid_links
('bin2');
64 scalar(@Conflicts) == 0 &&
66 $Link_Task_For{'bin2/file2b'}->{'action'} eq 'remove'
67 => 'cleanup a bad link'
71 #print Dumper(\@Tasks,\%Link_Task_For,\%Dir_Task_For);
74 # dont cleanup a bad link not owned by stow
77 $Option{'verbose'} = 0;
80 make_dir
('../stow/pkg3/bin3');
81 make_file
('../stow/pkg3/bin3/file3a');
82 make_link
('bin3/file3a','../../stow/pkg3/bin3/file3a');
83 make_link
('bin3/file3b','../../empty');
85 cleanup_invalid_links
('bin3');
87 scalar(@Conflicts) == 0 &&
89 => 'dont cleanup a bad link not owned by stow'