From 33670b89379648c09e673fcfbde292c8c0b32942 Mon Sep 17 00:00:00 2001 From: JJ Merelo Date: Wed, 26 Feb 2020 20:03:05 +0100 Subject: [PATCH] Advancing a bit in the direction of #17, #16, #13 Understanding the power of the cache --- pod-cached.iml | 8 ++++++++ t/007-load-precompile.t | 11 ++++++++--- t/040-pod-extraction.t | 5 ++--- t/050-multiple-instance.t | 2 +- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/pod-cached.iml b/pod-cached.iml index 480c6ba..3c3bad6 100644 --- a/pod-cached.iml +++ b/pod-cached.iml @@ -14,5 +14,13 @@ + + + + + + + + \ No newline at end of file diff --git a/t/007-load-precompile.t b/t/007-load-precompile.t index f4e5496..f59b105 100644 --- a/t/007-load-precompile.t +++ b/t/007-load-precompile.t @@ -5,8 +5,6 @@ use nqp; use CompUnit::PrecompilationRepository::Document; use File::Directory::Tree; -plan 2; - constant cache-name = "cache"; my $precomp-store = CompUnit::PrecompilationStore::File.new(prefix => cache-name.IO ); @@ -18,9 +16,16 @@ for -> $doc-name { my $handle = $precomp.load($key)[0]; my $precompiled-pod = nqp::atkey($handle.unit,'$=pod')[0]; is-deeply $precompiled-pod, $=pod[0], "Load precompiled pod $doc-name"; + my @dirs = dir( "cache/", test => /ABCD/); + is @dirs.elems, 1, "Cached dir created"; + my $dir = @dirs[0] ~ "/" ~ $key.substr(0,2); + ok $dir.IO.d, "Key directory created"; + ok "$dir/$key".IO.f, "File cached"; } -rmtree(cache-name); +#rmtree(cache-name); + +done-testing; =begin pod diff --git a/t/040-pod-extraction.t b/t/040-pod-extraction.t index 858d397..98afa8c 100644 --- a/t/040-pod-extraction.t +++ b/t/040-pod-extraction.t @@ -17,7 +17,7 @@ my Pod::To::Cached $cache; my $rv; diag 'Test pod extraction'; -mkdir( DOC ); +mkdir DOC; (DOC ~ '/a-pod-file.pod6').IO.spurt(q:to/POD-CONTENT/); =pod A test file =TITLE This is a title @@ -27,10 +27,9 @@ mkdir( DOC ); =end pod POD-CONTENT -mkdir( REP ); - $cache .= new( :source( DOC ), :path( REP ), :!verbose); $cache.update-cache; + #--MARKER-- Test 1 ok $cache.pod('a-pod-file')[0] ~~ Pod::Block::Named, 'pod is returned from cache'; diff --git a/t/050-multiple-instance.t b/t/050-multiple-instance.t index acda760..213d674 100644 --- a/t/050-multiple-instance.t +++ b/t/050-multiple-instance.t @@ -8,10 +8,10 @@ use File::Directory::Tree; constant REP = 't/tmp/ref'; constant DOC = 't/tmp/doc'; constant COUNT = 3; # number of caches to create + rmtree DOC if DOC.IO ~~ :d; rmtree REP if REP.IO ~~ :d; -mkdir DOC; mkdir REP; diag "Create multiple ({ COUNT }) caches";