[Rt-commit] r20028 - rtir/2.5/trunk/lib/RT/IR

ruz at bestpractical.com ruz at bestpractical.com
Fri Jun 19 11:51:50 EDT 2009


Author: ruz
Date: Fri Jun 19 11:51:50 2009
New Revision: 20028

Modified:
   rtir/2.5/trunk/lib/RT/IR/Test.pm

Log:
* reuse new testing features in the latest RT from repo

Modified: rtir/2.5/trunk/lib/RT/IR/Test.pm
==============================================================================
--- rtir/2.5/trunk/lib/RT/IR/Test.pm	(original)
+++ rtir/2.5/trunk/lib/RT/IR/Test.pm	Fri Jun 19 11:51:50 2009
@@ -1,15 +1,23 @@
 use strict;
 use warnings;
 
-package RT::IR::Test;
-use base qw(Test::More);
-use Cwd;
-
 ### after: use lib qw(@RT_LIB_PATH@);
 use lib qw(/opt/rt3/local/lib /opt/rt3/lib);
 
-eval 'use RT::Test; 1'
-    or Test::More::plan skip_all => "requires 3.8 to run tests. Error:\n$@\nYou may need to set PERL5LIB=/path/to/rt/lib";
+package RT::IR::Test;
+
+our @ISA;
+BEGIN {
+    local $@;
+    eval { require RT::Test; 1 } or do {
+        require Test::More;
+        Test::More::BAIL_OUT(
+            "requires 3.8 to run tests. Error:\n$@\n"
+            ."You may need to set PERL5LIB=/path/to/rt/lib"
+        );
+    };
+    push @ISA, 'RT::Test';
+}
 
 use RT::IR::Test::Web;
 
@@ -18,61 +26,20 @@
     rtir_user
 );
 
-sub import_extra {
+sub import {
     my $class = shift;
-    my $args  = shift;
+    my %args  = @_;
 
-    # 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 {};
+    $args{'requires'} ||= [];
+    if ( $args{'testing'} ) {
+        unshift @{ $args{'requires'} }, 'RT::IR';
+    } else {
+        $args{'testing'} = 'RT::IR';
     }
+    unshift @{ $args{'requires'} }, 'RT::FM';
 
-    # we need to lie to RT and have it find RTFM's mason templates 
-    # in the local directory
-    {
-        require RT::Plugin;
-        no warnings 'redefine';
-        my $cwd = getcwd;
-        my $old_func = \&RT::Plugin::_BasePath;
-        *RT::Plugin::_BasePath = sub {
-            return $cwd if $_[0]->{name} eq 'RT::IR';
-            if ( $_[0]->{name} eq 'RT::FM' ) {
-                my ($path) = map $ENV{$_}, grep /^CHIMPS_RTFM.*_ROOT$/, keys %ENV;
-                return $path if $path;
-            }
-            return $old_func->(@_);
-        };
-    }
-    RT->Config->Set('Plugins',qw(RT::FM RT::IR));
-    RT->InitPluginPaths;
-
-    {
-        require RT::Plugin;
-        my $rtfm = RT::Plugin->new( name => 'RT::FM' );
-        # RTFM's data
-
-        Test::More::diag("RTFM path: ". $rtfm->Path('etc') );
-        my ($ret, $msg) = $RT::Handle->InsertSchema( undef, $rtfm->Path('etc') );
-        Test::More::ok($ret,"Created Schema: ".($msg||''));
-        ($ret, $msg) = $RT::Handle->InsertACL( undef, $rtfm->Path('etc') );
-        Test::More::ok($ret,"Created ACL: ".($msg||''));
-
-        # RTIR's data
-        ($ret, $msg) = $RT::Handle->InsertData('etc/initialdata');
-        Test::More::ok($ret,"Created ACL: ".($msg||''));
-
-        $RT::Handle->Connect;
-    }
+    $class->SUPER::import( %args );
+    $class->export_to_level(1);
 
     RT->Config->LoadConfig( File => 'RTIR_Config.pm' );
     RT->Config->Set( 'rtirname' => 'regression_tests' );


More information about the Rt-commit mailing list