Browse files

add stop() method; nuke DESTROY() method; all in response to RT 69615

  • Loading branch information...
1 parent d2573f1 commit 2e00b967b058fe15d99d47a68926c76b88ef0217 @karpet committed Sep 23, 2011
Showing with 22 additions and 16 deletions.
  1. +6 −0 Changes
  2. +12 −16 lib/Net/LDAP/Server/Test.pm
  3. +4 −0 t/01-ldap.t
View
6 Changes
@@ -45,3 +45,9 @@ Revision history for Net-LDAP-Server-Test
0.11 04 June 2011
* fixes for Net::LDAP::Server 0.43, per patch from RT https://rt.cpan.org/Ticket/Display.html?id=68577
+
+0.12 xxx
+ * added stop() method in response to https://rt.cpan.org/Ticket/Display.html?id=69615
+ removed DESTROY() method since it was a no-op.
+
+
View
28 lib/Net/LDAP/Server/Test.pm
@@ -7,7 +7,7 @@ use IO::Select;
use IO::Socket;
use Data::Dump ();
-our $VERSION = '0.11';
+our $VERSION = '0.12';
=head1 NAME
@@ -906,25 +906,21 @@ sub new {
}
-=head2 DESTROY
+=head2 stop
-When a LDAP test server object is destroyed, waitpid() is called
-on the associated child process. Typically this is unnecessary, but
-implemented here as an exercise.
+Calls waitpid() on the server's associated child process.
+You may find it helpful to call this method explicitly,
+especially if you are creating multiple
+servers in the same test. Otherwise, this method is typically not
+needed and may even cause your tests to hang indefinitely if
+they die prematurely. YMMV.
=cut
-sub DESTROY {
- my $pid = ${ $_[0] };
-
- #warn "DESTROYing a LDAP server with pid $pid";
-
- # calling waitpid() here causes some tests to hang indefinitely if they
- # die prematurely.
- #my $epid = waitpid( $pid, 0 );
-
- #carp "$pid [$epid] exited with value $?";
-
+sub stop {
+ my $server = shift;
+ my $pid = $$server;
+ return waitpid( $pid, 0 );
}
=head1 AUTHOR
View
4 t/01-ldap.t
@@ -63,6 +63,10 @@ $entry->add(
);
push @mydata, $entry;
+# RT 69615
+diag("stop() server");
+$server->stop();
+
ok( $server = Net::LDAP::Server::Test->new( $opts{port}, data => \@mydata ),
"spawn new server with our own data" );

0 comments on commit 2e00b96

Please sign in to comment.