Mercurial > hg > nginx-tests
comparison lib/Test/Nginx.pm @ 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 | c28ecaef065f |
children | 17c5a1cc8757 |
comparison
equal
deleted
inserted
replaced
394:8d436291c09b | 395:d7d9b4367bab |
---|---|
41 'nginx-test-XXXXXXXXXX', | 41 'nginx-test-XXXXXXXXXX', |
42 TMPDIR => 1 | 42 TMPDIR => 1 |
43 ) | 43 ) |
44 or die "Can't create temp directory: $!\n"; | 44 or die "Can't create temp directory: $!\n"; |
45 $self->{_testdir} =~ s!\\!/!g if $^O eq 'MSWin32'; | 45 $self->{_testdir} =~ s!\\!/!g if $^O eq 'MSWin32'; |
46 mkdir "$self->{_testdir}/logs" | |
47 or die "Can't create logs directory: $!\n"; | |
46 | 48 |
47 return $self; | 49 return $self; |
48 } | 50 } |
49 | 51 |
50 sub DESTROY { | 52 sub DESTROY { |
208 | 210 |
209 if ($pid == 0) { | 211 if ($pid == 0) { |
210 my @globals = $self->{_test_globals} ? | 212 my @globals = $self->{_test_globals} ? |
211 () : ('-g', "pid $testdir/nginx.pid; " | 213 () : ('-g', "pid $testdir/nginx.pid; " |
212 . "error_log $testdir/error.log debug;"); | 214 . "error_log $testdir/error.log debug;"); |
213 exec($NGINX, '-c', "$testdir/nginx.conf", @globals) | 215 exec($NGINX, '-p', $testdir, '-c', 'nginx.conf', @globals), |
214 or die "Unable to exec(): $!\n"; | 216 or die "Unable to exec(): $!\n"; |
215 } | 217 } |
216 | 218 |
217 # wait for nginx to start | 219 # wait for nginx to start |
218 | 220 |
273 if ($^O eq 'MSWin32') { | 275 if ($^O eq 'MSWin32') { |
274 my $testdir = $self->{_testdir}; | 276 my $testdir = $self->{_testdir}; |
275 my @globals = $self->{_test_globals} ? | 277 my @globals = $self->{_test_globals} ? |
276 () : ('-g', "pid $testdir/nginx.pid; " | 278 () : ('-g', "pid $testdir/nginx.pid; " |
277 . "error_log $testdir/error.log debug;"); | 279 . "error_log $testdir/error.log debug;"); |
278 system($NGINX, '-c', "$testdir/nginx.conf", '-s', 'stop', | 280 system($NGINX, '-p', $testdir, '-c', "nginx.conf", |
279 @globals) == 0 | 281 '-s', 'stop', @globals) == 0 |
280 or die "system() failed: $?\n"; | 282 or die "system() failed: $?\n"; |
281 | 283 |
282 } else { | 284 } else { |
283 kill 'QUIT', $pid; | 285 kill 'QUIT', $pid; |
284 } | 286 } |