Subject: | tests fail without JSON::Any |
Date: | Mon, 25 May 2009 12:01:37 +0100 |
To: | bug-MooseX-Storage [...] rt.cpan.org |
From: | Nicholas Clark <nick [...] ccl4.org> |
MooseX::Storage fails 1 regression test when JSON::Any isn't installed:
$ /home/nick/Sandpit/589/bin/perl5.8.9 -Mblib t/040_basic_utils.t
1..5
ok 1 - use MooseX::Storage;
ok 2 - use MooseX::Storage::Util;
ok 3 - ... got the right class name from the packed item
Can't locate JSON/Any.pm in @INC (@INC contains: /home/nick/.cpan/build/MooseX-Storage-0.17-4rlGYo/blib/arch /home/nick/.cpan/build/MooseX-Storage-0.17-4rlGYo/blib/lib /home/nick/Sandpit/589/lib/perl5/5.8.9/x86_64-linux /home/nick/Sandpit/589/lib/perl5/5.8.9 /home/nick/Sandpit/589/lib/perl5/site_perl/5.8.9/x86_64-linux /home/nick/Sandpit/589/lib/perl5/site_perl/5.8.9 .) at /home/nick/.cpan/build/MooseX-Storage-0.17-4rlGYo/blib/lib/MooseX/Storage/Util.pm line 35.
not ok 4 - ... got the right class name from the json item
# Failed test '... got the right class name from the json item'
# at t/040_basic_utils.t line 71.
# got: 'Foo'
# expected: undef
ok 5 # skip No YAML module found
# Looks like you failed 1 test of 5.
It looks like the code to detect a missing JSON::Any and fail gracefully is
at fault, and the correct fix is something like:
--- lib/MooseX/Storage/Util.pm.orig 2009-04-06 11:20:26.000000000 +0100
+++ lib/MooseX/Storage/Util.pm 2009-05-25 12:00:31.000000000 +0100
@@ -32,8 +32,7 @@ sub peek {
sub _inflate_json {
my ($class, $json) = @_;
- require JSON::Any;
- eval { JSON::Any->import };
+ eval { require JSON::Any; JSON::Any->import(); };
confess "Could not load JSON module because : $@" if $@;
utf8::encode($json) if utf8::is_utf8($json);
Nicholas Clark