Skip to content

Commit

Permalink
Advancing a bit in the direction of #17, #16, #13
Browse files Browse the repository at this point in the history
Understanding the power of the cache
  • Loading branch information
JJ committed Feb 26, 2020
1 parent 43d2d8f commit 33670b8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
8 changes: 8 additions & 0 deletions pod-cached.iml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,13 @@
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="JSON::Fast:ver&lt;0.9.18+&gt;" type="perl6">
<CLASSES />
<SOURCES>
<root url="raku://1165951813:JSON::Fast:ver&lt;0.9.18+&gt;!/" />
</SOURCES>
</library>
</orderEntry>
</component>
</module>
11 changes: 8 additions & 3 deletions t/007-load-precompile.t
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -18,9 +16,16 @@ for <simple sub/simple> -> $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";

This comment has been minimized.

Copy link
@antoniogamiz

antoniogamiz Feb 29, 2020

Collaborator

What is the purpose of these lines?

my @dirs = dir("cache/", test => /ABCD/);

is bound to fail the test. The directory inside cache/ will get a name like 7710BE40DEE87AED4CAFCC5C2D350391227AD5E2 (a real example).

Maybe you wanted to test the creation of the cache directory and not its contents?

This comment has been minimized.

Copy link
@JJ

JJ Feb 29, 2020

Author Collaborator

It always started with ABCD in my case. Guess it's what's used to generate the hash. Maybe it's not for some other versions of Raku or some other installations.

This comment has been minimized.

Copy link
@JJ

JJ Feb 29, 2020

Author Collaborator

But the point is what you mentioned, check that there's something there. Maybe we should have other tests.

This comment has been minimized.

Copy link
@antoniogamiz

antoniogamiz Feb 29, 2020

Collaborator

OK, let me solve that. I'm working on #13 too.

}

rmtree(cache-name);
#rmtree(cache-name);

done-testing;

=begin pod
Expand Down
5 changes: 2 additions & 3 deletions t/040-pod-extraction.t
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion t/050-multiple-instance.t
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 33670b8

Please sign in to comment.