Skip to content

Commit

Permalink
fixing memorized-related bug
Browse files Browse the repository at this point in the history
  • Loading branch information
shmuelfomberg committed Jul 2, 2013
1 parent 1b8cde1 commit 0bf589e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Dist/Surveyor/Inquiry.pm
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ my $locking_file;

sub perma_cache {
my $class = shift;
my $db_generation = 2; # XXX increment on incompatible change
my $db_generation = 3; # XXX increment on incompatible change
my $pname = $FindBin::Script;
$pname =~ s/\..*$//;
my $memoize_file = "$pname-$db_generation.db";
Expand All @@ -95,6 +95,7 @@ for my $subname (@memoize_subs) {
my %memoize_args = (
SCALAR_CACHE => [ HASH => \%memoize_cache ],
LIST_CACHE => 'FAULT',
NORMALIZER => sub { return join("\034", $subname, @_) }
);
memoize($subname, %memoize_args);
}
Expand Down
6 changes: 6 additions & 0 deletions t/02-inquery.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use strict;
use warnings;
use Dist::Surveyor::Inquiry;
use Data::Dumper;
use Test::More;

my $module_data = get_module_versions_in_release('SEMUELF', 'Dist-Surveyor-0.009');
Expand All @@ -24,4 +25,9 @@ my $releases = get_candidate_cpan_dist_releases("Dist::Surveyor::DB_File", "0.00
is_deeply([keys %$releases], ['Dist-Surveyor-0.009'], "Got the right release");
is( $releases->{'Dist-Surveyor-0.009'}->{path}, 'lib/Dist/Surveyor/DB_File.pm', "Found the file" );

my $release_info = get_release_info('SEMUELF', 'Dist-Surveyor-0.009');
is($release_info->{name}, 'Dist-Surveyor-0.009', "Got the right release");
is($release_info->{download_url}, 'http://cpan.metacpan.org/authors/id/S/SE/SEMUELF/Dist-Surveyor-0.009.tar.gz',
"Got the right download URL");

done_testing();
24 changes: 24 additions & 0 deletions t/03-scanlib.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use strict;
use warnings;
use Dist::Surveyor;
use FindBin;
use File::Spec;
use Test::More;


my $options = {
distro_key_mod_names => {},
};
my $libdirs = [ File::Spec->catdir($FindBin::Bin, "scanlib") ];
my @installed_releases = determine_installed_releases($options, $libdirs);
@installed_releases = sort { $a->{name} cmp $b->{name} } @installed_releases;
is_deeply(
[ 'Dist-Surveyor-0.009', 'Test-Class-0.36', 'Test-Deep-0.084' ],
[ map $_->{name}, @installed_releases ],
"Got all three releases" );
is_deeply(
['100.00', '100.00', '2.78'],
[ map $_->{dist_data}->{percent_installed}, @installed_releases ],
"Got all three percents correctly" );

done_testing();

0 comments on commit 0bf589e

Please sign in to comment.