From: Karen Etheridge Date: Mon, 15 Jul 2013 18:12:24 +0000 (-0700) Subject: set JSON configs first before loading, so Test::Requires can skip cleanly X-Git-Tag: 0.35~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=30d5da5cf4163e05f21f720776da10080247fe64;p=gitmo%2FMooseX-Storage.git set JSON configs first before loading, so Test::Requires can skip cleanly --- diff --git a/Changes b/Changes index cbdc3e2..959b82b 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Revision history for MooseX-Storage + * properly skip optional tests when the required JSON backends aren't + available + 0.34 2013-06-20 * JSON storage works when Cpanel::JSON::XS is the only JSON backend installed diff --git a/t/011_basic_json_w_utf8.t b/t/011_basic_json_w_utf8.t index a5bd3d8..7a84b40 100644 --- a/t/011_basic_json_w_utf8.t +++ b/t/011_basic_json_w_utf8.t @@ -3,25 +3,22 @@ use warnings; use Test::More; +# NOTE: +# this is because JSON::XS (and Cpanel::JSON::XS) is +# the only one which really gets utf8 correct +# - SL +BEGIN { + $ENV{JSON_ANY_ORDER} = 'XS CPANEL'; + $ENV{JSON_ANY_CONFIG} = "utf8=0,canonical=1"; +} + use Test::Requires { 'Encode' => 0.01, # skip all if not installed 'JSON::Any' => 0.01, }; -BEGIN { - # NOTE: - # this is because JSON::XS (and Cpanel::JSON::XS) is - # the only one which really gets - # utf8 correct - # - SL - BEGIN { - $ENV{JSON_ANY_ORDER} = 'XS CPANEL'; - $ENV{JSON_ANY_CONFIG} = "utf8=0,canonical=1"; - } - - plan tests => 16; - use_ok('MooseX::Storage'); -} +plan tests => 16; +use_ok('MooseX::Storage'); { package Foo; diff --git a/t/104_io_w_utf8.t b/t/104_io_w_utf8.t index 77ddbb9..bc05023 100644 --- a/t/104_io_w_utf8.t +++ b/t/104_io_w_utf8.t @@ -6,24 +6,22 @@ use File::Temp qw(tempdir); use File::Spec::Functions; my $dir = tempdir( CLEANUP => 1 ); +# NOTE: +# this is because JSON::XS (and Cpanel::JSON::XS) is +# the only one which really gets utf8 correct +# - SL +BEGIN { + $ENV{JSON_ANY_ORDER} = 'XS CPANEL'; + $ENV{JSON_ANY_CONFIG} = "utf8=0,canonical=1"; +} + use Test::Requires { 'JSON::Any' => 0.01, # skip all if not installed 'IO::AtomicFile' => 0.01, }; -BEGIN { - # NOTE: - # this is because JSON::XS (and Cpanel::JSON::XS) is - # the only one which really gets - # utf8 correct - # - SL - BEGIN { - $ENV{JSON_ANY_ORDER} = 'XS CPANEL'; - $ENV{JSON_ANY_CONFIG} = "utf8=0,canonical=1"; - } - plan tests => 8; - use_ok('MooseX::Storage'); -} +plan tests => 8; +use_ok('MooseX::Storage'); use utf8;