changeset 415:020c4e47ecac

Tests: revert 068d020a8f85 and localize $? instead. The problem observed was due to $? being overwritten in the destructor after it has been set by exit(), specifically by waitpid() in stop_daemons(). Fix is to localize $? in the destructor to make sure it won't be accidentally changed.
author Maxim Dounin <mdounin@mdounin.ru>
date Fri, 20 Jun 2014 21:01:52 +0400
parents 068d020a8f85
children 5c25acbc870a
files lib/Test/Nginx.pm upstream_hash_memcached.t
diffstat 2 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lib/Test/Nginx.pm
+++ b/lib/Test/Nginx.pm
@@ -51,9 +51,13 @@ sub new {
 
 sub DESTROY {
 	my ($self) = @_;
+	local $?;
+
 	return if $self->{_pid} != $$;
+
 	$self->stop();
 	$self->stop_daemons();
+
 	if ($ENV{TEST_NGINX_CATLOG}) {
 		system("cat $self->{_testdir}/error.log");
 	}
--- a/upstream_hash_memcached.t
+++ b/upstream_hash_memcached.t
@@ -104,11 +104,10 @@ if ($memhelp =~ /-U/) {
 	push @memopts, '-U', '0';
 }
 
-$t->try_run('no upstream hash')->plan(4);
-
 $t->run_daemon('memcached', '-l', '127.0.0.1', '-p', '8081', @memopts);
 $t->run_daemon('memcached', '-l', '127.0.0.1', '-p', '8082', @memopts);
 $t->run_daemon('memcached', '-l', '127.0.0.1', '-p', '8083', @memopts);
+$t->try_run('no upstream hash')->plan(4);
 
 $t->waitforsocket('127.0.0.1:8081') or die "Can't start memcached";
 $t->waitforsocket('127.0.0.1:8082') or die "Can't start memcached";