Commit 87d5550c authored by Kevin Falcone's avatar Kevin Falcone
Browse files

Move tests from t to xt

pod tests should never be run by an end user (especially the failing
ones) and letting end users try to create/drop test databases is a
recipe for failure (especially if run from the cpan client).

Write up docs on how to run tests in case you're developing.
parent 7d6c703d
......@@ -14,6 +14,6 @@ META.yml
*.swp
rtldapimport
*.bak
t/tmp/
t/lib/RT/Extension/LDAPImport/Test.pm
xt/tmp/
xt/lib/RT/Extension/LDAPImport/Test.pm
MYMETA.*
......@@ -18,7 +18,7 @@ name: RT-Extension-LDAPImport
no_index:
directory:
- inc
- t
- xt
recommends:
Net::LDAP::Server::Test: 0
requires:
......
......@@ -45,9 +45,11 @@ substitute(
{
sufix => '.in'
},
q(t/lib/RT/Extension/LDAPImport/Test.pm),
q(xt/lib/RT/Extension/LDAPImport/Test.pm),
);
author_tests('xt');
sign;
&auto_install();
&WriteAll;
......@@ -253,6 +253,14 @@ LDAP Filters
DAP+2.0-Release> utility in openldap can be very helpful while refining
your filters.
Developing
If you want to run tests for this extension, you should create the
inc/.author directory and will need to set RT_DBA_USER and
RT_DBA_PASSWORD environment variables to a database user that can
create/drop tests databases as needed.
Do not run tests in a production environment.
METHODS
connect_ldap
Relies on the config variables $RT::LDAPHost, $RT::LDAPUser and
......
#line 1
package Module::Install::AuthorTests;
use 5.005;
use strict;
use Module::Install::Base;
use Carp ();
#line 16
use vars qw{$VERSION $ISCORE @ISA};
BEGIN {
$VERSION = '0.002';
$ISCORE = 1;
@ISA = qw{Module::Install::Base};
}
#line 42
sub author_tests {
my ($self, @dirs) = @_;
_add_author_tests($self, \@dirs, 0);
}
#line 56
sub recursive_author_tests {
my ($self, @dirs) = @_;
_add_author_tests($self, \@dirs, 1);
}
sub _wanted {
my $href = shift;
sub { /\.t$/ and -f $_ and $href->{$File::Find::dir} = 1 }
}
sub _add_author_tests {
my ($self, $dirs, $recurse) = @_;
return unless $Module::Install::AUTHOR;
my @tests = $self->tests ? (split / /, $self->tests) : 't/*.t';
# XXX: pick a default, later -- rjbs, 2008-02-24
my @dirs = @$dirs ? @$dirs : Carp::confess "no dirs given to author_tests";
@dirs = grep { -d } @dirs;
if ($recurse) {
require File::Find;
my %test_dir;
File::Find::find(_wanted(\%test_dir), @dirs);
$self->tests( join ' ', @tests, map { "$_/*.t" } sort keys %test_dir );
} else {
$self->tests( join ' ', @tests, map { "$_/*.t" } sort @dirs );
}
}
#line 107
1;
......@@ -8,7 +8,7 @@ no warnings 'once';
use Module::Install::Base;
use base 'Module::Install::Base';
our $VERSION = '0.31';
our $VERSION = '0.32';
use FindBin;
use File::Glob ();
......@@ -136,6 +136,7 @@ install ::
$has_etc{acl}++;
}
if ( -e 'etc/initialdata' ) { $has_etc{initialdata}++; }
if ( -d 'etc/upgrade/' ) { $has_etc{upgrade}++; }
$self->postamble("$postamble\n");
unless ( $subdirs{'lib'} ) {
......@@ -164,40 +165,23 @@ install ::
.
$self->postamble("initdb ::\n$initdb\n");
$self->postamble("initialize-database ::\n$initdb\n");
if ($has_etc{upgrade}) {
print "To upgrade from a previous version of this extension, use 'make upgrade-database'\n";
my $upgradedb = qq|\t\$(NOECHO) \$(PERL) -Ilib -I"$local_lib_path" -I"$lib_path" -Minc::Module::Install -e"RTxInitDB(qw(upgrade \$(NAME) \$(VERSION)))"\n|;
$self->postamble("upgrade-database ::\n$upgradedb\n");
$self->postamble("upgradedb ::\n$upgradedb\n");
}
}
}
# stolen from RT::Handle so we work on 3.6 (cmp_versions came in with 3.8)
{ my %word = (
a => -4,
alpha => -4,
b => -3,
beta => -3,
pre => -2,
rc => -1,
head => 9999,
);
sub cmp_version($$) {
my ($a, $b) = (@_);
my @a = grep defined, map { /^[0-9]+$/? $_ : /^[a-zA-Z]+$/? $word{$_}|| -10 : undef }
split /([^0-9]+)/, $a;
my @b = grep defined, map { /^[0-9]+$/? $_ : /^[a-zA-Z]+$/? $word{$_}|| -10 : undef }
split /([^0-9]+)/, $b;
@a > @b
? push @b, (0) x (@a-@b)
: push @a, (0) x (@b-@a);
for ( my $i = 0; $i < @a; $i++ ) {
return $a[$i] <=> $b[$i] if $a[$i] <=> $b[$i];
}
return 0;
}}
sub requires_rt {
my ($self,$version) = @_;
# if we're exactly the same version as what we want, silently return
return if ($version eq $RT::VERSION);
my @sorted = sort cmp_version $version,$RT::VERSION;
require RT::Handle;
my @sorted = sort RT::Handle::cmp_version $version,$RT::VERSION;
if ($sorted[-1] eq $version) {
# should we die?
......@@ -209,4 +193,4 @@ sub requires_rt {
__END__
#line 329
#line 313
......@@ -52,6 +52,38 @@ Running the import:
/opt/rt4/local/plugins/RT-Extension-LDAPImport/bin/rtldapimport \
--import
=head1 INSTALLATION
=over
=item C<perl Makefile.PL>
=item C<make>
=item C<make install>
May need root permissions
=item Edit your F</opt/rt4/etc/RT_SiteConfig.pm>
If you are using RT 4.2 or greater, add this line:
Plugin('RT::Extension::LDAPImport');
For earlier releases of RT 4, add this line:
Set(@Plugins, qw(RT::Extension::LDAPImport));
or add C<RT::Extension::LDAPImport> to your existing C<@Plugins> line.
=item Clear your mason cache
rm -rf /opt/rt4/var/mason_data/obj
=item Restart your webserver
=back
=head1 CONFIGURATION
All of the configuration for the importer goes
......@@ -309,6 +341,15 @@ It may work with RT 3.6.
The L<ldapsearch|http://www.openldap.org/software/man.cgi?query=ldapsearch&manpath=OpenLDAP+2.0-Release>
utility in openldap can be very helpful while refining your filters.
=head1 Developing
If you want to run tests for this extension, you should create the
F<inc/.author> directory and will need to set RT_DBA_USER and
RT_DBA_PASSWORD environment variables to a database user that can
create/drop tests databases as needed.
Do not run tests in a production environment.
=head1 METHODS
=head2 connect_ldap
......
use strict;
use warnings;
use lib 't/lib';
use lib 'xt/lib';
use RT::Extension::LDAPImport::Test tests => undef;
eval { require Net::LDAP::Server::Test; 1; } or do {
plan skip_all => 'Unable to test without Net::Server::LDAP::Test';
......
use strict;
use warnings;
use lib 't/lib';
use lib 'xt/lib';
use RT::Extension::LDAPImport::Test tests => 66;
eval { require Net::LDAP::Server::Test; 1; } or do {
plan skip_all => 'Unable to test without Net::Server::LDAP::Test';
......
use strict;
use warnings;
use lib 't/lib';
use lib 'xt/lib';
use RT::Extension::LDAPImport::Test tests => undef;
eval { require Net::LDAP::Server::Test; 1; } or do {
plan skip_all => 'Unable to test without Net::Server::LDAP::Test';
......
use strict;
use warnings;
use lib 't/lib';
use lib 'xt/lib';
use RT::Extension::LDAPImport::Test tests => 7 + 13*3 + 3 + 2*2 + 1;
eval { require Net::LDAP::Server::Test; 1; } or do {
plan skip_all => 'Unable to test without Net::Server::LDAP::Test';
......
use strict;
use warnings;
use lib 't/lib';
use lib 'xt/lib';
use RT::Extension::LDAPImport::Test tests => 8 + 13*2;
eval { require Net::LDAP::Server::Test; 1; } or do {
plan skip_all => 'Unable to test without Net::Server::LDAP::Test';
......
use strict;
use warnings;
use lib 't/lib';
use lib 'xt/lib';
use RT::Extension::LDAPImport::Test tests => 8 + 13*2 + 3;
eval { require Net::LDAP::Server::Test; 1; } or do {
plan skip_all => 'Unable to test without Net::Server::LDAP::Test';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment