Better handling of testing temp files

Rather than creating and ignoring a bunch of random files, create files in
t/tmp, ignored in .gitignore and cleaned up with 'make clean'
This commit is contained in:
Jared Johnson 2015-01-27 14:41:15 -06:00
parent 178c5f6884
commit 3bf1a7f48c
7 changed files with 12 additions and 17 deletions

7
.gitignore vendored
View File

@ -13,12 +13,7 @@ packaging/rpm/build/
*~
*.bak
denysoft_greylist.dbm
denysoft_greylist.dbm.lock
greylist.dbm
greylist.dbm.lock
greylisting.dbm
greylisting.dbm.lock
t/tmp
/cover_db/
.last_cover_stats

View File

@ -39,7 +39,7 @@ WriteMakefile(
ABSTRACT => 'Flexible smtpd daemon written in Perl',
AUTHOR => 'Ask Bjoern Hansen <ask@develooper.com>',
EXE_FILES => [qw(qpsmtpd qpsmtpd-forkserver qpsmtpd-prefork)],
clean => { FILES => [ '*.bak' ], },
clean => { FILES => [ '*.bak', 't/tmp' ], },
);
sub MY::libscan {

View File

@ -11,6 +11,10 @@ use parent 'Qpsmtpd::SMTP';
use Qpsmtpd::Constants;
use Test::Qpsmtpd::Plugin;
if ( ! -d 't/tmp' ) {
mkdir 't/tmp' or warn "Could not create temporary testing directory:$!";
}
sub new_conn {
ok(my $smtpd = __PACKAGE__->new(), "new");
ok(

View File

@ -46,7 +46,7 @@ badrcptto
helo
sender_permitted_from
greylisting p0f genre,windows
greylisting p0f genre,windows db_dir ./t/tmp
#auth/auth_checkpassword checkpw /usr/local/vpopmail/bin/vchkpw true /usr/bin/true
#auth/auth_vpopmail

View File

@ -7,8 +7,3 @@ my $qp = Test::Qpsmtpd->new();
$qp->run_plugin_tests($ARGV[0]);
foreach my $file ("./t/config/greylist.dbm", "./t/config/greylist.dbm.lock") {
next if !-f $file;
unlink $file;
}

View File

@ -237,7 +237,7 @@ sub test_prune_db {
};
for my $test_class (@Qpsmtpd::DB::child_classes) {
delete $self->{db};
eval { $self->db( class => $test_class ) };
eval { $self->db( class => $test_class, dir => 't/tmp' ) };
next if $@;
$self->db->lock;
$self->db->flush;
@ -291,7 +291,7 @@ sub test_greylist {
my $rcpt = Qpsmtpd::Address->new( "<$test_email>" );
for my $test_class (@Qpsmtpd::DB::child_classes) {
delete $self->{db};
eval { $self->db( class => $test_class ) };
eval { $self->db( class => $test_class, dir => 't/tmp' ) };
if ( $@ ) {
warn "Unable to test greylisting against $test_class: $@";
next;

View File

@ -6,9 +6,10 @@ use Test::More;
use lib 'lib'; # test lib/Qpsmtpd (vs site_perl)
use lib 't';
use Test::Qpsmtpd;
use_ok('Qpsmtpd::DB::File::DBM');
my $db = Qpsmtpd::DB::File::DBM->new( name => 'testing' );
my $db = Qpsmtpd::DB::File::DBM->new( name => 'testing', dir => 't/tmp' );
__new();
__get();
__mget();
@ -106,7 +107,7 @@ sub __untie_gotcha {
$db->flush;
$db->set( cut => 'itout' );
$db->unlock;
my $db2 = Qpsmtpd::DB::File::DBM->new( name => 'testing' );
my $db2 = Qpsmtpd::DB::File::DBM->new( name => 'testing', dir => 't/tmp' );
$db2->lock;
is( $db2->get('cut'), 'itout',
'get() in second db handle reads key set in first handle' );