r77096 - in /trunk/dh-make-perl: debian/changelog lib/Debian/WNPP/Query.pm t/cache.t
diocles at users.alioth.debian.org
diocles at users.alioth.debian.org
Mon Jul 4 16:15:42 UTC 2011
Author: diocles
Date: Mon Jul 4 16:15:40 2011
New Revision: 77096
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=77096
Log:
Avoid error when cache file is unreadable.
Added:
trunk/dh-make-perl/t/cache.t (with props)
Modified:
trunk/dh-make-perl/debian/changelog
trunk/dh-make-perl/lib/Debian/WNPP/Query.pm
Modified: trunk/dh-make-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/dh-make-perl/debian/changelog?rev=77096&op=diff
==============================================================================
--- trunk/dh-make-perl/debian/changelog (original)
+++ trunk/dh-make-perl/debian/changelog Mon Jul 4 16:15:40 2011
@@ -1,3 +1,11 @@
+dh-make-perl (0.74-1) UNRELEASED; urgency=low
+
+ * t/cache.t: New test for handling unreadable cache files.
+ * Debian::WNPP::Query: return an empty hashref rather than undef after
+ failing to read cache file.
+
+ -- Tim Retout <diocles at debian.org> Mon, 04 Jul 2011 17:12:39 +0100
+
dh-make-perl (0.73-1) unstable; urgency=low
[ gregor herrmann ]
Modified: trunk/dh-make-perl/lib/Debian/WNPP/Query.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/dh-make-perl/lib/Debian/WNPP/Query.pm?rev=77096&op=diff
==============================================================================
--- trunk/dh-make-perl/lib/Debian/WNPP/Query.pm (original)
+++ trunk/dh-make-perl/lib/Debian/WNPP/Query.pm Mon Jul 4 16:15:40 2011
@@ -85,7 +85,7 @@
return unless $self->cache_file and -e $self->cache_file;
$self->_cache( eval { Storable::retrieve( $self->cache_file ) }
- || undef );
+ || {} );
}
sub _write_cache {
Added: trunk/dh-make-perl/t/cache.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/dh-make-perl/t/cache.t?rev=77096&op=file
==============================================================================
--- trunk/dh-make-perl/t/cache.t (added)
+++ trunk/dh-make-perl/t/cache.t Mon Jul 4 16:15:40 2011
@@ -1,0 +1,49 @@
+#!/usr/bin/perl -w
+
+#
+# Test we don't get this error when failing to read wnpp cache file:
+# "Can't use an undefined value as a HASH reference at /usr/share/perl5/Debian/WNPP/Query.pm line 75."
+#
+# Bug reported by jawnsy on IRC.
+#
+
+use strict;
+use warnings;
+
+use Test::More tests => 1;
+
+use FindBin qw($Bin);
+use File::Path ();
+
+sub dist_ok($) {
+ my $dist_dir = shift;
+ my $dist = "$Bin/dists/$dist_dir";
+
+ # Create an unreadable cache file.
+ -e "$Bin/contents/wnpp.cache" and ( unlink "$Bin/contents/wnpp.cache"
+ or die "unlink($Bin/contents/wnpp.cache): $!" );
+ system('touch', "$Bin/contents/wnpp.cache");
+
+ system( "$Bin/../dh-make-perl", "--no-verbose",
+ "--home-dir", "$Bin/contents",
+ "--apt-contents-dir", "$Bin/contents",
+ "--data-dir", "$Bin/../share",
+ $ENV{NO_NETWORK} ? '--no-network' : (),
+ "--sources-list",
+ "$Bin/contents/sources.list", "--email", "joemaint\@test.local",
+ $dist );
+
+ is( $?, 0, "$dist_dir: system returned 0" );
+
+ # clean after the test
+ File::Path::rmtree("$dist/debian");
+
+ unlink "$Bin/contents/Contents.cache" or die "unlink($Bin/contents.cache): $!";
+ -e "$Bin/contents/wnpp.cache" and ( unlink "$Bin/contents/wnpp.cache"
+ or die "unlink($Bin/contents/wnpp.cache): $!" );
+}
+
+$ENV{PERL5LIB} = "lib";
+$ENV{DEBFULLNAME} = "Joe Maintainer";
+
+dist_ok('Strange-0.1');
Propchange: trunk/dh-make-perl/t/cache.t
------------------------------------------------------------------------------
svn:executable = *
More information about the Pkg-perl-cvs-commits
mailing list