Skip to content

Commit 95182bf

Browse files
committed
Add multiple instance tests. Remove rm-cache from Module.
rm-cache is an undocumented sub and was only used for tests. It's functionality is better supported with File::Directory::Tree
1 parent e2a9fb1 commit 95182bf

File tree

5 files changed

+39
-11
lines changed

5 files changed

+39
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ lib/.precomp/*
33
t/tmp/
44
.pod-cache
55
workspace.xml
6+
*.iml

lib/Pod/To/Cached.pm6

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -261,15 +261,6 @@ method freeze( --> Bool ) {
261261
self.save-index;
262262
}
263263

264-
sub rm-cache( $path ) is export {
265-
if $*SPEC ~~ IO::Spec::Win32 {
266-
my $win-path = "$*CWD/$path".trans( ["/"] => ["\\"] );
267-
shell "rmdir /S /Q $win-path" ;
268-
} else {
269-
shell "rm -rf $path";
270-
}
271-
}
272-
273264
=begin pod
274265
275266
=TITLE Pod::To::Cached

t/030-sub-directories.t

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use Test;
33
use Test::Output;
44
use JSON::Fast;
55
use Pod::To::Cached;
6+
use File::Directory::Tree;
67

78
constant REP = 't/tmp/ref';
89
constant DOC = 't/tmp/doc';
@@ -35,5 +36,6 @@ nok 'sub-dir-1' ~~ any( $cache.hash-files.keys ), 'sub-directories filtered from
3536
't'.IO.&indir( {$cache .= new(:source( 'tmp/doc' ) ) } );
3637
#--MARKER-- Test 4
3738
ok 't/.pod-cache'.IO ~~ :d, 'default repository created';
38-
39+
# clean up
40+
rmtree 't/.pod-cache';
3941
done-testing;

t/040-pod-extraction.t

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use lib 'lib';
22
use Test;
33
use Test::Output;
44
use Pod::To::Cached;
5+
use File::Directory::Tree;
56

67
constant REP = 't/tmp/ref';
78
constant DOC = 't/tmp/doc';
@@ -12,7 +13,9 @@ plan 11;
1213
my Pod::To::Cached $cache;
1314
my $rv;
1415
diag 'Test pod extraction';
15-
rm-cache( REP );
16+
17+
rmtree REP;
18+
1619
$cache .= new( :source( DOC ), :path( REP ), :!verbose);
1720
$cache.update-cache;
1821
#--MARKER-- Test 1

t/050-multiple-instance.t

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# assumes that there are directories REP and DOC left from tests in 040
2+
use lib 'lib';
3+
use Test;
4+
use Test::Output;
5+
use Pod::To::Cached;
6+
use File::Directory::Tree;
7+
8+
constant REP = 't/tmp/ref';
9+
constant DOC = 't/tmp/doc';
10+
constant COUNT = 3; # number of caches to create
11+
12+
diag "Create multiple ({ COUNT }) caches";
13+
14+
rmtree REP;
15+
16+
my @caches;
17+
18+
for ^COUNT {
19+
lives-ok {
20+
@caches[$_] = Pod::To::Cached.new( :source( DOC ), :path( REP ~ $_ ), :!verbose)
21+
}, "created cache no $_";
22+
lives-ok {
23+
@caches[$_].update-cache
24+
}, "update cache no $_";
25+
}
26+
27+
for ^COUNT {
28+
ok (REP ~ $_ ).IO.d
29+
}
30+
31+
done-testing;

0 commit comments

Comments
 (0)