Mercurial > hg > nginx-tests
changeset 1629:a1874249496d
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.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 30 Nov 2020 20:53:11 +0300 |
parents | 54f867e69cb5 |
children | 6f573329e862 |
files | lib/Test/Nginx.pm |
diffstat | 1 files changed, 11 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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 (<F>); close F; }