diff --git a/.gitignore b/.gitignore index 451770c..4adccb8 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/Makefile.PL b/Makefile.PL index 945db7c..1bdf98b 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -39,7 +39,7 @@ WriteMakefile( ABSTRACT => 'Flexible smtpd daemon written in Perl', AUTHOR => 'Ask Bjoern Hansen ', EXE_FILES => [qw(qpsmtpd qpsmtpd-forkserver qpsmtpd-prefork)], - clean => { FILES => [ '*.bak' ], }, + clean => { FILES => [ '*.bak', 't/tmp' ], }, ); sub MY::libscan { diff --git a/t/Test/Qpsmtpd.pm b/t/Test/Qpsmtpd.pm index 9ec569d..f36864c 100644 --- a/t/Test/Qpsmtpd.pm +++ b/t/Test/Qpsmtpd.pm @@ -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( diff --git a/t/config/plugins b/t/config/plugins index 4e85186..c4b4d79 100644 --- a/t/config/plugins +++ b/t/config/plugins @@ -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 diff --git a/t/plugin_tests.t b/t/plugin_tests.t index b5f2e65..24857d7 100644 --- a/t/plugin_tests.t +++ b/t/plugin_tests.t @@ -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; -} - diff --git a/t/plugin_tests/greylisting b/t/plugin_tests/greylisting index a6dd167..7fd2a84 100644 --- a/t/plugin_tests/greylisting +++ b/t/plugin_tests/greylisting @@ -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; diff --git a/t/qpsmtpd-db-file-dbm.t b/t/qpsmtpd-db-file-dbm.t index d3b215e..6cf2b73 100644 --- a/t/qpsmtpd-db-file-dbm.t +++ b/t/qpsmtpd-db-file-dbm.t @@ -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' );