# HG changeset patch # User Maxim Dounin # Date 1606758791 -10800 # Node ID a1874249496dfaf789fdd97a56dbb43316e4a14f # Parent 54f867e69cb536a749e7d9f59c94ffdd8b83f72a Tests: reworked try_run() to redirect stderr. Previously, if TEST_NGINX_VERBOSE was set, the code tried to use compiled-in error log. While this works in typical development cases when --error-log-path is relative to prefix, it is unlikely to work correctly if --error-log-path is absolute. The recently introduced '-e' command line option might be used to fix this. On the other hand, a more compatible solution would be to redirect stderr to a file instead. diff --git a/lib/Test/Nginx.pm b/lib/Test/Nginx.pm --- a/lib/Test/Nginx.pm +++ b/lib/Test/Nginx.pm @@ -291,19 +291,24 @@ sub try_run($$) { my ($self, $message) = @_; eval { - open OLDERR, ">&", \*STDERR; close STDERR; + open OLDERR, ">&", \*STDERR; + open NEWERR, ">", $self->{_testdir} . '/stderr' + or die "Can't open stderr: $!"; + close STDERR; + open STDERR, ">&", \*NEWERR; + close NEWERR; + $self->run(); + + close STDERR; open STDERR, ">&", \*OLDERR; }; return $self unless $@; if ($ENV{TEST_NGINX_VERBOSE}) { - my $path = $self->{_configure_args} =~ m!--error-log-path=(\S+)! - ? $1 : 'logs/error.log'; - $path = "$self->{_testdir}/$path" if index($path, '/'); - - open F, '<', $path or die "Can't open $path: $!"; + open F, '<', $self->{_testdir} . '/stderr' + or die "Can't open stderr: $!"; log_core($_) while (); close F; }