[Catalyst-commits] r8178 - in trunk/Config-Any: . lib/Config
lib/Config/Any t t/conf t/invalid
bricas at dev.catalyst.perl.org
bricas at dev.catalyst.perl.org
Tue Aug 5 13:03:26 BST 2008
Author: bricas
Date: 2008-08-05 13:03:26 +0100 (Tue, 05 Aug 2008)
New Revision: 8178
Added:
trunk/Config-Any/t/invalid/
trunk/Config-Any/t/invalid/conf.conf
trunk/Config-Any/t/invalid/conf.ini
trunk/Config-Any/t/invalid/conf.json
trunk/Config-Any/t/invalid/conf.pl
trunk/Config-Any/t/invalid/conf.xml
trunk/Config-Any/t/invalid/conf.yml
Removed:
trunk/Config-Any/t/63-invalid.t
trunk/Config-Any/t/conf/conf_invalid.pl
Modified:
trunk/Config-Any/Changes
trunk/Config-Any/lib/Config/Any.pm
trunk/Config-Any/lib/Config/Any/INI.pm
trunk/Config-Any/t/50-general.t
trunk/Config-Any/t/51-ini.t
trunk/Config-Any/t/52-json.t
trunk/Config-Any/t/53-perl.t
trunk/Config-Any/t/54-xml.t
trunk/Config-Any/t/55-yaml.t
Log:
add parse error tests. ensure INI errors are trapped. bumped version.
Modified: trunk/Config-Any/Changes
===================================================================
--- trunk/Config-Any/Changes 2008-08-05 02:23:12 UTC (rev 8177)
+++ trunk/Config-Any/Changes 2008-08-05 12:03:26 UTC (rev 8178)
@@ -1,6 +1,9 @@
Revision history for Config-Any
- - Show actual parse error when parse fails (Marcus Ramberg).
+0.13 XXX
+ - show actual parse error when parse fails (Marcus Ramberg)
+ - ensure Config::Tiny parse errors are trapped
+ - added tests for each format to ensure they throw parse errors
0.12 Mon 07 Apr 2008
- ensure Perl loader dies on a failed require() (RT #32995)
Modified: trunk/Config-Any/lib/Config/Any/INI.pm
===================================================================
--- trunk/Config-Any/lib/Config/Any/INI.pm 2008-08-05 02:23:12 UTC (rev 8177)
+++ trunk/Config-Any/lib/Config/Any/INI.pm 2008-08-05 12:03:26 UTC (rev 8178)
@@ -45,6 +45,9 @@
require Config::Tiny;
my $config = Config::Tiny->read( $file );
+
+ die $Config::Tiny::errstr if not defined $config;
+
my $out = delete $config->{ _ } || {};
for my $k ( keys %$config ) {
Modified: trunk/Config-Any/lib/Config/Any.pm
===================================================================
--- trunk/Config-Any/lib/Config/Any.pm 2008-08-05 02:23:12 UTC (rev 8177)
+++ trunk/Config-Any/lib/Config/Any.pm 2008-08-05 12:03:26 UTC (rev 8178)
@@ -6,7 +6,7 @@
use Carp;
use Module::Pluggable::Object ();
-our $VERSION = '0.12';
+our $VERSION = '0.13';
=head1 NAME
Modified: trunk/Config-Any/t/50-general.t
===================================================================
--- trunk/Config-Any/t/50-general.t 2008-08-05 02:23:12 UTC (rev 8177)
+++ trunk/Config-Any/t/50-general.t 2008-08-05 12:03:26 UTC (rev 8178)
@@ -8,7 +8,7 @@
plan skip_all => 'Config::General format not supported';
}
else {
- plan tests => 4;
+ plan tests => 6;
}
{
@@ -23,3 +23,12 @@
{ -LowerCaseNames => 1 } );
ok( exists $config->{ component } );
}
+
+# test invalid config
+{
+ my $file = 't/invalid/conf.conf';
+ my $config = eval { Config::Any::General->load( $file ) };
+
+ ok( !$config, 'config load failed' );
+ ok( $@, "error thrown ($@)" );
+}
Modified: trunk/Config-Any/t/51-ini.t
===================================================================
--- trunk/Config-Any/t/51-ini.t 2008-08-05 02:23:12 UTC (rev 8177)
+++ trunk/Config-Any/t/51-ini.t 2008-08-05 12:03:26 UTC (rev 8178)
@@ -8,7 +8,7 @@
plan skip_all => 'INI format not supported';
}
else {
- plan tests => 11;
+ plan tests => 13;
}
{
@@ -46,3 +46,12 @@
ok( $config, 'config loaded' );
is_deeply( $config, \%expected, 'subsections parsed properly' );
}
+
+# test invalid config
+{
+ my $file = 't/invalid/conf.ini';
+ my $config = eval { Config::Any::INI->load( $file ) };
+
+ ok( !$config, 'config load failed' );
+ ok( $@, "error thrown ($@)" );
+}
Modified: trunk/Config-Any/t/52-json.t
===================================================================
--- trunk/Config-Any/t/52-json.t 2008-08-05 02:23:12 UTC (rev 8177)
+++ trunk/Config-Any/t/52-json.t 2008-08-05 12:03:26 UTC (rev 8178)
@@ -8,7 +8,7 @@
plan skip_all => 'JSON format not supported';
}
else {
- plan tests => 2;
+ plan tests => 4;
}
{
@@ -16,3 +16,12 @@
ok( $config );
is( $config->{ name }, 'TestApp' );
}
+
+# test invalid config
+{
+ my $file = 't/invalid/conf.json';
+ my $config = eval { Config::Any::JSON->load( $file ) };
+
+ ok( !$config, 'config load failed' );
+ ok( $@, "error thrown ($@)" );
+}
Modified: trunk/Config-Any/t/53-perl.t
===================================================================
--- trunk/Config-Any/t/53-perl.t 2008-08-05 02:23:12 UTC (rev 8177)
+++ trunk/Config-Any/t/53-perl.t 2008-08-05 12:03:26 UTC (rev 8178)
@@ -1,7 +1,7 @@
use strict;
use warnings;
-use Test::More tests => 3;
+use Test::More tests => 5;
use Config::Any::Perl;
@@ -16,3 +16,11 @@
is_deeply( $config_load2, $config, 'multiple loads of the same file' );
}
+# test invalid config
+{
+ my $file = 't/invalid/conf.pl';
+ my $config = eval { Config::Any::Perl->load( $file ) };
+
+ ok( !$config, 'config load failed' );
+ ok( $@, "error thrown ($@)" );
+}
Modified: trunk/Config-Any/t/54-xml.t
===================================================================
--- trunk/Config-Any/t/54-xml.t 2008-08-05 02:23:12 UTC (rev 8177)
+++ trunk/Config-Any/t/54-xml.t 2008-08-05 12:03:26 UTC (rev 8178)
@@ -8,7 +8,7 @@
plan skip_all => 'XML format not supported';
}
else {
- plan tests => 2;
+ plan tests => 4;
}
{
@@ -16,3 +16,12 @@
ok( $config );
is( $config->{ name }, 'TestApp' );
}
+
+# test invalid config
+{
+ my $file = 't/invalid/conf.xml';
+ my $config = eval { Config::Any::XML->load( $file ) };
+
+ ok( !$config, 'config load failed' );
+ ok( $@, "error thrown ($@)" );
+}
Modified: trunk/Config-Any/t/55-yaml.t
===================================================================
--- trunk/Config-Any/t/55-yaml.t 2008-08-05 02:23:12 UTC (rev 8177)
+++ trunk/Config-Any/t/55-yaml.t 2008-08-05 12:03:26 UTC (rev 8178)
@@ -8,7 +8,7 @@
plan skip_all => 'YAML format not supported';
}
else {
- plan tests => 2;
+ plan tests => 4;
}
{
@@ -16,3 +16,12 @@
ok( $config );
is( $config->{ name }, 'TestApp' );
}
+
+# test invalid config
+{
+ my $file = 't/invalid/conf.yml';
+ my $config = eval { Config::Any::YAML->load( $file ) };
+
+ ok( !$config, 'config load failed' );
+ ok( $@, "error thrown ($@)" );
+}
Deleted: trunk/Config-Any/t/63-invalid.t
===================================================================
--- trunk/Config-Any/t/63-invalid.t 2008-08-05 02:23:12 UTC (rev 8177)
+++ trunk/Config-Any/t/63-invalid.t 2008-08-05 12:03:26 UTC (rev 8178)
@@ -1,14 +0,0 @@
-use strict;
-use warnings;
-
-use Test::More tests => 2;
-
-use Config::Any::Perl;
-
-{
- my $file = 't/conf/conf_invalid.pl';
- my $config = eval { Config::Any::Perl->load( $file ) };
-
- ok( !$config, 'config load failed' );
- ok( $@, "error thrown ($@)" );
-}
Deleted: trunk/Config-Any/t/conf/conf_invalid.pl
===================================================================
--- trunk/Config-Any/t/conf/conf_invalid.pl 2008-08-05 02:23:12 UTC (rev 8177)
+++ trunk/Config-Any/t/conf/conf_invalid.pl 2008-08-05 12:03:26 UTC (rev 8178)
@@ -1 +0,0 @@
-this is not valid perl.
Added: trunk/Config-Any/t/invalid/conf.conf
===================================================================
--- trunk/Config-Any/t/invalid/conf.conf (rev 0)
+++ trunk/Config-Any/t/invalid/conf.conf 2008-08-05 12:03:26 UTC (rev 8178)
@@ -0,0 +1,7 @@
+name = TestApp
+<Component Controller::Foo
+ foo bar
+</Component>
+<Model Model::Baz>
+ qux xyzzy
+</Model>
Added: trunk/Config-Any/t/invalid/conf.ini
===================================================================
--- trunk/Config-Any/t/invalid/conf.ini (rev 0)
+++ trunk/Config-Any/t/invalid/conf.ini 2008-08-05 12:03:26 UTC (rev 8178)
@@ -0,0 +1,7 @@
+name=TestApp
+
+[Component Controller::Foo
+foo=bar
+
+[Model Model::Baz]
+qux=xyzzy
Added: trunk/Config-Any/t/invalid/conf.json
===================================================================
--- trunk/Config-Any/t/invalid/conf.json (rev 0)
+++ trunk/Config-Any/t/invalid/conf.json 2008-08-05 12:03:26 UTC (rev 8178)
@@ -0,0 +1,13 @@
+{
+ "name": "TestApp",
+ "Component": {
+ "Controller::Foo": {
+ "foo": "bar"
+ }
+ },
+ "Model": {
+ "Model::Baz": {
+ "qux": "xyzzy"
+ }
+ }
+
Added: trunk/Config-Any/t/invalid/conf.pl
===================================================================
--- trunk/Config-Any/t/invalid/conf.pl (rev 0)
+++ trunk/Config-Any/t/invalid/conf.pl 2008-08-05 12:03:26 UTC (rev 8178)
@@ -0,0 +1,4 @@
+{ name => 'TestApp'
+ Component => { 'Controller::Foo' => { foo => 'bar' } },
+ Model => { 'Model::Baz' => { qux => 'xyzzy' } }
+}
Added: trunk/Config-Any/t/invalid/conf.xml
===================================================================
--- trunk/Config-Any/t/invalid/conf.xml (rev 0)
+++ trunk/Config-Any/t/invalid/conf.xml 2008-08-05 12:03:26 UTC (rev 8178)
@@ -0,0 +1,9 @@
+<config>
+ <name>TestApp</name
+ <Component name="Controller::Foo">
+ <foo>bar</foo>
+ </Component>
+ <Model name="Model::Baz">
+ <qux>xyzzy</qux>
+ </Model>
+</config>
Added: trunk/Config-Any/t/invalid/conf.yml
===================================================================
--- trunk/Config-Any/t/invalid/conf.yml (rev 0)
+++ trunk/Config-Any/t/invalid/conf.yml 2008-08-05 12:03:26 UTC (rev 8178)
@@ -0,0 +1,8 @@
+---
+name: TestApp
+Component:
+ Controller::Foo:
+ foo: bar
+Model:
+ Model::Baz:
+ qux: xyzzy
More information about the Catalyst-commits
mailing list