Skip to content

Commit

Permalink
Adds tests to catch Windows error refs #5
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ committed Sep 4, 2019
1 parent 80e7797 commit 3a1ba98
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
9 changes: 5 additions & 4 deletions lib/Pod/To/Cached.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ submethod TWEAK {
die "Invalid index file"
unless %config<source>:exists;
$!source = %config<source>;
%!files.map( {
.value<status> = Status( Status.enums{ .value<status> } ) ;
.value<added> = DateTime.new( .value<added> ).Instant
})
for %!files.keys -> $f {
die "File $f has no status" if !%!files{$f}<status>;
%!files{$f}<status> = Status( Status.enums{%!files{$f}<status> }) ;
%!files{$f}<added> = DateTime.new( %!files{$f}<added> ).Instant
}
}
die "Source verification failed with:\n" ~ @!error-messages.join("\n\t")
unless self.verify-source; # note a frozen cache always returns True
Expand Down
20 changes: 14 additions & 6 deletions t/020-source.t
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ my Pod::To::Cached $cache;
rmtree DOC if DOC.IO ~~ :d;
rmtree REP if REP.IO ~~ :d;

mktree DOC; # It assumes it's not there before, fails if it does - JJ
mktree DOC;
#--MARKER-- Test 1
throws-like { $cache .= new( :source( DOC ), :path( REP ) ) },
Exception, :message(/'No POD files found under'/), 'Detects absence of source files';
Expand Down Expand Up @@ -67,16 +67,18 @@ lives-ok { %config = from-json( INDEX.IO.slurp ) }, 'good json in index';
#--MARKER-- Test 8
ok (%config<frozen>:exists and %config<frozen> ~~ 'False'), 'frozen is False as expected';
#--MARKER-- Test 9
ok (%config<files>:exists
and %config<files>.WHAT ~~ Hash)
, 'files is as expected';
subtest "Files test", {
ok (%config<files>:exists and %config<files>.WHAT ~~ Hash), 'files is as expected';
}
#--MARKER-- Test 10
is +%config<files>.keys, 0, 'No source files in index because nothing in cache';

my $mod-time = INDEX.IO.modified;
my $rv;
#--MARKER-- Test 11
lives-ok {$rv = $cache.update-cache}, 'Updates cache without dying';
subtest "Cache updated", {
lives-ok {$rv = $cache.update-cache}, 'Updates cache without dying';
}
#--MARKER-- Test 12
nok $rv, 'Returned false because of compile errors';
#--MARKER-- Test 13
Expand Down Expand Up @@ -113,7 +115,13 @@ $cache.verbose = False;
POD-CONTENT

#--MARKER-- Test 18
ok $cache.update-cache, 'Returned true because both POD now compile';
subtest "Update cache", {
ok $cache.update-cache, 'Returned true because both POD now compile';
%config = from-json( INDEX.IO.slurp ); # Re-reads cache index
for <a-pod-file a-second-pod-file> -> $f {
ok( %config<files>{$f}<status>, "Status of $f is OK and %config<files>{$f}<status>")
}
}
# this works because the source paths are in the cache object, and they are new

#--MARKER-- Test 19
Expand Down

0 comments on commit 3a1ba98

Please sign in to comment.