changeset 395:d7d9b4367bab

Tests: start nginx prefixed to a temporary directory. This fixes spurious alert "could not open error log file ..." usually seen with the build-in error.log path when running an uninstalled nginx built with default --error-log-path.
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 25 Apr 2014 18:44:46 +0400
parents 8d436291c09b
children 5eb0df61f371
files lib/Test/Nginx.pm
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lib/Test/Nginx.pm
+++ b/lib/Test/Nginx.pm
@@ -43,6 +43,8 @@ sub new {
 	)
 		or die "Can't create temp directory: $!\n";
 	$self->{_testdir} =~ s!\\!/!g if $^O eq 'MSWin32';
+	mkdir "$self->{_testdir}/logs"
+		or die "Can't create logs directory: $!\n";
 
 	return $self;
 }
@@ -210,7 +212,7 @@ sub run(;$) {
 		my @globals = $self->{_test_globals} ?
 			() : ('-g', "pid $testdir/nginx.pid; "
 			. "error_log $testdir/error.log debug;");
-		exec($NGINX, '-c', "$testdir/nginx.conf", @globals)
+		exec($NGINX, '-p', $testdir, '-c', 'nginx.conf', @globals),
 			or die "Unable to exec(): $!\n";
 	}
 
@@ -275,8 +277,8 @@ sub stop() {
 		my @globals = $self->{_test_globals} ?
 			() : ('-g', "pid $testdir/nginx.pid; "
 			. "error_log $testdir/error.log debug;");
-		system($NGINX, '-c', "$testdir/nginx.conf", '-s', 'stop',
-			@globals) == 0
+		system($NGINX, '-p', $testdir, '-c', "nginx.conf",
+			'-s', 'stop', @globals) == 0
 			or die "system() failed: $?\n";
 
 	} else {