Subject: | Test failures under perl-5.17 |
Hello,
Catalyst::Auth::Store::DBIC fails most of its tests when run under perl v5.17.3 or later. Starting with perl commit
613c63b46 anything saved to %ENV is stringified, so the TESTAPP_CONFIG and TESTAPP_PLUGINS values are converted
to "HASH(0xdeadbeef)" and "ARRAY(0xdeadbeef)" before being given to TestApp->config and TestApp->setup. The
attached patch calls TestApp->config() and ->setup() directly in the BEGIN blocks of all the affected tests, avoiding
%ENV entirely. I don't know if this is the best way to fix this bug, but it works on 5.10.1, 5.12.5, 5.14.3, and 5.16.2.
On 5.17.8 Catalyst::Plugin::Authorization::Roles is uninstallable due to a bug in Set::Object, so t/0[5689]-*.t are
skipped, and I can't say for sure that they work. t/{03,04,07,11}-*.t all pass after this patch is applied.
Please let me know if I should make any adjustments to the patch. Thank you for your time and have a great weekend!
Cheers,
Fitz
Subject: | 0001-set-TestApp-config-in-tests-BEGIN-blocks-to-avoid-EN.patch |
From b2be9c1d6c5fb0892656a99e8abca4c1955800fb Mon Sep 17 00:00:00 2001
From: Fitz Elliott <fitz.elliott@gmail.com>
Date: Thu, 24 Jan 2013 23:41:24 -0500
Subject: [PATCH] set TestApp config in tests' BEGIN blocks to avoid %ENV
stringifcation
---
t/03-authtest.t | 11 ++++++-----
t/04-authsessions.t | 9 +++++----
t/05-auth-roles-relationship.t | 9 +++++----
t/06-auth-roles-column.t | 9 +++++----
t/07-authsessions-cached.t | 9 +++++----
t/08-simpledb-auth-roles-relationship.t | 9 +++++----
t/09-simpledb-auth-roles-column.t | 9 +++++----
t/11-authsessions-load-app-context.t | 9 +++++----
t/lib/TestApp.pm | 4 ----
9 files changed, 41 insertions(+), 37 deletions(-)
diff --git a/t/03-authtest.t b/t/03-authtest.t
index f704281..0ecdc8f 100644
--- a/t/03-authtest.t
+++ b/t/03-authtest.t
@@ -19,7 +19,8 @@ BEGIN {
plan tests => 19;
- $ENV{TESTAPP_CONFIG} = {
+ use TestApp;
+ TestApp->config( {
name => 'TestApp',
authentication => {
default_realm => "users",
@@ -37,11 +38,11 @@ BEGIN {
},
},
},
- };
+ } );
- $ENV{TESTAPP_PLUGINS} = [
+ TestApp->setup(
qw/Authentication/
- ];
+ );
}
use Catalyst::Test 'TestApp';
@@ -102,7 +103,7 @@ use Catalyst::Test 'TestApp';
{
- $ENV{TESTAPP_CONFIG}->{authentication}->{realms}->{users}->{store}->{user_model} = 'Nonexistent::Class';
+ TestApp->config->{authentication}->{realms}->{users}->{store}->{user_model} = 'Nonexistent::Class';
my $res = request('http://localhost/user_login?username=joeuser&password=hackme');
like( $res->content, qr/\$\Qc->model('Nonexistent::Class') did not return a resultset. Did you set user_model correctly?/, 'test for wrong user_class' );
}
diff --git a/t/04-authsessions.t b/t/04-authsessions.t
index 2d649ba..4952ed4 100644
--- a/t/04-authsessions.t
+++ b/t/04-authsessions.t
@@ -33,7 +33,8 @@ BEGIN {
plan tests => 8;
- $ENV{TESTAPP_CONFIG} = {
+ use TestApp;
+ TestApp->config( {
name => 'TestApp',
authentication => {
default_realm => "users",
@@ -52,15 +53,15 @@ BEGIN {
},
},
},
- };
+ } );
- $ENV{TESTAPP_PLUGINS} = [
+ TestApp->setup(
qw/Authentication
Session
Session::Store::Dummy
Session::State::Cookie
/
- ];
+ );
}
use Test::WWW::Mechanize::Catalyst 'TestApp';
diff --git a/t/05-auth-roles-relationship.t b/t/05-auth-roles-relationship.t
index 55da53c..7b5f1c8 100644
--- a/t/05-auth-roles-relationship.t
+++ b/t/05-auth-roles-relationship.t
@@ -23,7 +23,8 @@ BEGIN {
plan tests => 8;
- $ENV{TESTAPP_CONFIG} = {
+ use TestApp;
+ TestApp->config( {
name => 'TestApp',
authentication => {
default_realm => "users",
@@ -43,13 +44,13 @@ BEGIN {
},
},
},
- };
+ } );
- $ENV{TESTAPP_PLUGINS} = [
+ TestApp->setup(
qw/Authentication
Authorization::Roles
/
- ];
+ );
}
use Catalyst::Test 'TestApp';
diff --git a/t/06-auth-roles-column.t b/t/06-auth-roles-column.t
index 70f5643..a021fca 100644
--- a/t/06-auth-roles-column.t
+++ b/t/06-auth-roles-column.t
@@ -23,7 +23,8 @@ BEGIN {
plan tests => 8;
- $ENV{TESTAPP_CONFIG} = {
+ use TestApp;
+ TestApp->config( {
name => 'TestApp',
authentication => {
default_realm => "users",
@@ -42,13 +43,13 @@ BEGIN {
},
},
},
- };
+ } );
- $ENV{TESTAPP_PLUGINS} = [
+ TestApp->setup(
qw/Authentication
Authorization::Roles
/
- ];
+ );
}
use Catalyst::Test 'TestApp';
diff --git a/t/07-authsessions-cached.t b/t/07-authsessions-cached.t
index 745bf95..2c8b1d3 100644
--- a/t/07-authsessions-cached.t
+++ b/t/07-authsessions-cached.t
@@ -33,7 +33,8 @@ BEGIN {
plan tests => 8;
- $ENV{TESTAPP_CONFIG} = {
+ use TestApp;
+ TestApp->config( {
name => 'TestApp',
authentication => {
default_realm => "users",
@@ -52,15 +53,15 @@ BEGIN {
},
},
},
- };
+ } );
- $ENV{TESTAPP_PLUGINS} = [
+ TestApp->setup(
qw/Authentication
Session
Session::Store::Dummy
Session::State::Cookie
/
- ];
+ );
}
use Test::WWW::Mechanize::Catalyst 'TestApp';
diff --git a/t/08-simpledb-auth-roles-relationship.t b/t/08-simpledb-auth-roles-relationship.t
index d5251e1..25b85e7 100644
--- a/t/08-simpledb-auth-roles-relationship.t
+++ b/t/08-simpledb-auth-roles-relationship.t
@@ -23,7 +23,8 @@ BEGIN {
plan tests => 8;
- $ENV{TESTAPP_CONFIG} = {
+ use TestApp;
+ TestApp->config( {
name => 'TestApp',
'Plugin::Authentication' => {
default => {
@@ -32,13 +33,13 @@ BEGIN {
password_type => 'clear'
}
}
- };
+ } );
- $ENV{TESTAPP_PLUGINS} = [
+ TestApp->setup(
qw/Authentication
Authorization::Roles
/
- ];
+ );
}
use Catalyst::Test 'TestApp';
diff --git a/t/09-simpledb-auth-roles-column.t b/t/09-simpledb-auth-roles-column.t
index bced500..b13494f 100644
--- a/t/09-simpledb-auth-roles-column.t
+++ b/t/09-simpledb-auth-roles-column.t
@@ -23,7 +23,8 @@ BEGIN {
plan tests => 8;
- $ENV{TESTAPP_CONFIG} = {
+ use TestApp;
+ TestApp->config( {
name => 'TestApp',
'Plugin::Authentication' => {
default => {
@@ -34,13 +35,13 @@ BEGIN {
}
}
- };
+ } );
- $ENV{TESTAPP_PLUGINS} = [
+ TestApp->setup(
qw/Authentication
Authorization::Roles
/
- ];
+ );
}
use Catalyst::Test 'TestApp';
diff --git a/t/11-authsessions-load-app-context.t b/t/11-authsessions-load-app-context.t
index e458c9f..7cc2e77 100644
--- a/t/11-authsessions-load-app-context.t
+++ b/t/11-authsessions-load-app-context.t
@@ -33,7 +33,8 @@ BEGIN {
plan tests => 4;
- $ENV{TESTAPP_CONFIG} = {
+ use TestApp;
+ TestApp->config( {
name => 'TestApp',
authentication => {
default_realm => "users",
@@ -50,15 +51,15 @@ BEGIN {
},
},
},
- };
+ } );
- $ENV{TESTAPP_PLUGINS} = [
+ TestApp->setup(
qw/Authentication
Session
Session::Store::Dummy
Session::State::Cookie
/
- ];
+ );
}
use Test::WWW::Mechanize::Catalyst 'TestApp';
diff --git a/t/lib/TestApp.pm b/t/lib/TestApp.pm
index 619b4dd..a58b02a 100644
--- a/t/lib/TestApp.pm
+++ b/t/lib/TestApp.pm
@@ -4,8 +4,4 @@ use strict;
use Catalyst;
use Data::Dumper;
-TestApp->config( $ENV{TESTAPP_CONFIG} );
-
-TestApp->setup( @{$ENV{TESTAPP_PLUGINS}} );
-
1;
--
1.8.1.1