[Rt-commit] r14666 - in rtfm/trunk: . t t/lib/RT t/lib/RT/FM
falcone at bestpractical.com
falcone at bestpractical.com
Wed Jul 30 16:07:00 EDT 2008
Author: falcone
Date: Wed Jul 30 16:06:55 2008
New Revision: 14666
Added:
rtfm/trunk/t/lib/
rtfm/trunk/t/lib/RT/
rtfm/trunk/t/lib/RT/FM/
rtfm/trunk/t/lib/RT/FM/Test.pm
Modified:
rtfm/trunk/ (props changed)
rtfm/trunk/t/00smoke.t
rtfm/trunk/t/04interface.t
rtfm/trunk/t/05cfsearch.t
rtfm/trunk/t/2basic_api.t
rtfm/trunk/t/3upload-customfields.t
rtfm/trunk/t/ArticleCollection_Overlay.pm.t
rtfm/trunk/t/Article_Overlay.pm.t
rtfm/trunk/t/Class_Overlay.pm.t
rtfm/trunk/t/URI_a.t
rtfm/trunk/t/URI_fsck_com_rtfm.t
Log:
r36398 at ketch: falcone | 2008-07-30 14:21:59 -0400
* add RT::FM::Test to t/lib and use it to hide much of the repeated testing code
Modified: rtfm/trunk/t/00smoke.t
==============================================================================
--- rtfm/trunk/t/00smoke.t (original)
+++ rtfm/trunk/t/00smoke.t Wed Jul 30 16:06:55 2008
@@ -3,7 +3,8 @@
use strict;
use warnings;
-use Test::More qw(no_plan);
+use lib 't/lib';
+use RT::FM::Test qw(no_plan);
use RT;
ok(RT::LoadConfig);
Modified: rtfm/trunk/t/04interface.t
==============================================================================
--- rtfm/trunk/t/04interface.t (original)
+++ rtfm/trunk/t/04interface.t Wed Jul 30 16:06:55 2008
@@ -3,20 +3,8 @@
use strict;
use warnings;
-use Test::More;
-eval 'use RT::Test; 1'
- or plan skip_all => 'requires 3.8 to run tests.';
-
-plan tests => 42;
-
-{
-my ($ret, $msg) = $RT::Handle->InsertSchema(undef,'etc/');
-ok($ret,"Created Schema: ".($msg||''));
-($ret, $msg) = $RT::Handle->InsertACL(undef,'etc/');
-ok($ret,"Created ACL: ".($msg||''));
-}
-
-RT->Config->Set('Plugins',qw(RT::FM));
+use lib 't/lib';
+use RT::FM::Test tests => 42;
use RT::CustomField;
use RT::EmailParser;
Modified: rtfm/trunk/t/05cfsearch.t
==============================================================================
--- rtfm/trunk/t/05cfsearch.t (original)
+++ rtfm/trunk/t/05cfsearch.t Wed Jul 30 16:06:55 2008
@@ -3,20 +3,8 @@
use strict;
use warnings;
-use Test::More;
-eval 'use RT::Test; 1'
- or plan skip_all => 'requires 3.8 to run tests.';
-
-plan tests => 13;
-
-{
-my ($ret, $msg) = $RT::Handle->InsertSchema(undef,'etc/');
-ok($ret,"Created Schema: ".($msg||''));
-($ret, $msg) = $RT::Handle->InsertACL(undef,'etc/');
-ok($ret,"Created ACL: ".($msg||''));
-}
-
-RT->Config->Set('Plugins',qw(RT::FM));
+use lib 't/lib';
+use RT::FM::Test tests => 13;
my $suffix = '-'. $$;
Modified: rtfm/trunk/t/2basic_api.t
==============================================================================
--- rtfm/trunk/t/2basic_api.t (original)
+++ rtfm/trunk/t/2basic_api.t Wed Jul 30 16:06:55 2008
@@ -3,19 +3,8 @@
use warnings;
use strict;
-use Test::More;
-eval 'use RT::Test; 1'
- or plan skip_all => 'requires 3.8 to run tests.';
-plan tests => 42;
-
-{
-my ($ret, $msg) = $RT::Handle->InsertSchema(undef,'etc/');
-ok($ret,"Created Schema: ".($msg||''));
-($ret, $msg) = $RT::Handle->InsertACL(undef,'etc/');
-ok($ret,"Created ACL: ".($msg||''));
-}
-
-RT->Config->Set('Plugins',qw(RT::FM));
+use lib 't/lib';
+use RT::FM::Test tests => 42;
use_ok 'RT::FM::System';
my $sys = new RT::FM::System;
Modified: rtfm/trunk/t/3upload-customfields.t
==============================================================================
--- rtfm/trunk/t/3upload-customfields.t (original)
+++ rtfm/trunk/t/3upload-customfields.t Wed Jul 30 16:06:55 2008
@@ -3,19 +3,8 @@
use strict;
use warnings;
-use Test::More;
-eval 'use RT::Test; 1'
- or plan skip_all => 'requires 3.8 to run tests.';
-plan tests => 25;
-
-{
-my ($ret, $msg) = $RT::Handle->InsertSchema(undef,'etc/');
-ok($ret,"Created Schema: ".($msg||''));
-($ret, $msg) = $RT::Handle->InsertACL(undef,'etc/');
-ok($ret,"Created ACL: ".($msg||''));
-}
-
-RT->Config->Set('Plugins',qw(RT::FM));
+use lib 't/lib';
+use RT::FM::Test tests => 25;
use RT;
use constant ImageFile => $RT::MasonComponentRoot .'/NoAuth/images/bplogo.gif';
Modified: rtfm/trunk/t/ArticleCollection_Overlay.pm.t
==============================================================================
--- rtfm/trunk/t/ArticleCollection_Overlay.pm.t (original)
+++ rtfm/trunk/t/ArticleCollection_Overlay.pm.t Wed Jul 30 16:06:55 2008
@@ -3,19 +3,8 @@
use strict;
use warnings;
-use Test::More;
-eval 'use RT::Test; 1'
- or plan skip_all => 'requires 3.8 to run tests.';
-plan tests => 32;
-
-{
-my ($ret, $msg) = $RT::Handle->InsertSchema(undef,'etc/');
-ok($ret,"Created Schema: ".($msg||''));
-($ret, $msg) = $RT::Handle->InsertACL(undef,'etc/');
-ok($ret,"Created ACL: ".($msg||''));
-}
-
-RT->Config->Set('Plugins',qw(RT::FM));
+use lib 't/lib';
+use RT::FM::Test tests => 32;
use_ok 'RT::FM::ArticleCollection';
use_ok 'RT::FM::ClassCollection';
Modified: rtfm/trunk/t/Article_Overlay.pm.t
==============================================================================
--- rtfm/trunk/t/Article_Overlay.pm.t (original)
+++ rtfm/trunk/t/Article_Overlay.pm.t Wed Jul 30 16:06:55 2008
@@ -3,19 +3,8 @@
use strict;
use warnings;
-use Test::More;
-eval 'use RT::Test; 1'
- or plan skip_all => 'requires 3.8 to run tests.';
-plan tests => 70;
-
-{
-my ($ret, $msg) = $RT::Handle->InsertSchema(undef,'etc/');
-ok($ret,"Created Schema: ".($msg||''));
-($ret, $msg) = $RT::Handle->InsertACL(undef,'etc/');
-ok($ret,"Created ACL: ".($msg||''));
-}
-
-RT->Config->Set('Plugins',qw(RT::FM));
+use lib 't/lib';
+use RT::FM::Test tests => 70;
use_ok 'RT::FM::ArticleCollection';
use_ok 'RT::FM::ClassCollection';
Modified: rtfm/trunk/t/Class_Overlay.pm.t
==============================================================================
--- rtfm/trunk/t/Class_Overlay.pm.t (original)
+++ rtfm/trunk/t/Class_Overlay.pm.t Wed Jul 30 16:06:55 2008
@@ -3,19 +3,8 @@
use strict;
use warnings;
-use Test::More;
-eval 'use RT::Test; 1'
- or plan skip_all => 'requires 3.8 to run tests.';
-plan tests => 15;
-
-{
-my ($ret, $msg) = $RT::Handle->InsertSchema(undef,'etc/');
-ok($ret,"Created Schema: ".($msg||''));
-($ret, $msg) = $RT::Handle->InsertACL(undef,'etc/');
-ok($ret,"Created ACL: ".($msg||''));
-}
-
-RT->Config->Set('Plugins',qw(RT::FM));
+use lib 't/lib';
+use RT::FM::Test tests => 15;
use_ok 'RT::FM::ArticleCollection';
use_ok 'RT::FM::ClassCollection';
Modified: rtfm/trunk/t/URI_a.t
==============================================================================
--- rtfm/trunk/t/URI_a.t (original)
+++ rtfm/trunk/t/URI_a.t Wed Jul 30 16:06:55 2008
@@ -3,19 +3,8 @@
use strict;
use warnings;
-use Test::More;
-eval 'use RT::Test; 1'
- or plan skip_all => 'requires 3.8 to run tests.';
-plan tests => 9;
-
-{
-my ($ret, $msg) = $RT::Handle->InsertSchema(undef,'etc/');
-ok($ret,"Created Schema: ".($msg||''));
-($ret, $msg) = $RT::Handle->InsertACL(undef,'etc/');
-ok($ret,"Created ACL: ".($msg||''));
-}
-
-RT->Config->Set('Plugins',qw(RT::FM));
+use lib 't/lib';
+use RT::FM::Test tests => 9;
use_ok("RT::URI::a");
my $uri = RT::URI::a->new($RT::SystemUser);
Modified: rtfm/trunk/t/URI_fsck_com_rtfm.t
==============================================================================
--- rtfm/trunk/t/URI_fsck_com_rtfm.t (original)
+++ rtfm/trunk/t/URI_fsck_com_rtfm.t Wed Jul 30 16:06:55 2008
@@ -3,19 +3,8 @@
use strict;
use warnings;
-use Test::More;
-eval 'use RT::Test; 1'
- or plan skip_all => 'requires 3.8 to run tests.';
-plan tests => 11;
-
-{
-my ($ret, $msg) = $RT::Handle->InsertSchema(undef,'etc/');
-ok($ret,"Created Schema: ".($msg||''));
-($ret, $msg) = $RT::Handle->InsertACL(undef,'etc/');
-ok($ret,"Created ACL: ".($msg||''));
-}
-
-RT->Config->Set('Plugins',qw(RT::FM));
+use lib 't/lib';
+use RT::FM::Test tests => 11;
use_ok "RT::URI::fsck_com_rtfm";
my $uri = RT::URI::fsck_com_rtfm->new( $RT::SystemUser );
Added: rtfm/trunk/t/lib/RT/FM/Test.pm
==============================================================================
--- (empty file)
+++ rtfm/trunk/t/lib/RT/FM/Test.pm Wed Jul 30 16:06:55 2008
@@ -0,0 +1,40 @@
+use strict;
+use warnings;
+
+package RT::FM::Test;
+use base qw(Test::More);
+
+eval 'use RT::Test; 1'
+ or Test::More::plan skip_all => 'requires 3.8 to run tests.';
+
+sub import_extra {
+ my $class = shift;
+ my $args = shift;
+
+ # Spit out a plan (if we got one) *before* we load modules, in
+ # case of compilation errors
+ $class->builder->plan(@{$args})
+ unless $class->builder->has_plan;
+
+ Test::More->export_to_level(2);
+
+ # Now, clobber Test::Builder::plan (if we got given a plan) so we
+ # don't try to spit one out *again* later. Test::Builder::Module
+ # plans for you in import
+ if ($class->builder->has_plan) {
+ no warnings 'redefine';
+ *Test::Builder::plan = sub {};
+ }
+
+ {
+ my ($ret, $msg) = $RT::Handle->InsertSchema(undef,'etc/');
+ Test::More::ok($ret,"Created Schema: ".($msg||''));
+ ($ret, $msg) = $RT::Handle->InsertACL(undef,'etc/');
+ Test::More::ok($ret,"Created ACL: ".($msg||''));
+ }
+
+ RT->Config->Set('Plugins',qw(RT::FM));
+
+}
+
+1;
More information about the Rt-commit
mailing list