Welcome! Log In Create A New Profile

Advanced

[PATCH 1 of 1] Tests: unbreak reading new stderr data after eof

Sergey Kandaurov
May 26, 2023 07:30AM
# HG changeset patch
# User Sergey Kandaurov <pluknet@nginx.com>
# Date 1685100180 -14400
# Fri May 26 15:23:00 2023 +0400
# Node ID dc3539be2a14a0cd0b8be9e1e9aae8c95b806828
# Parent 4dad7cf8ebe807f9230a82dde5fc02b5e12e390b
Tests: unbreak reading new stderr data after eof.

Tests don't expect to stop reading redirected stderr when end of file is
reached, but rather to read new data being appended, similar to "tail -f".
The behaviour is first changed in Ubuntu 23.04 Perl 5.36, by applying the
upstream patch [1], and is expected for inclusion in the next Perl 5.38.
The fix is to set filehandle's position to the end of file to clear the
error state and allow to continue readline() further from that position.

[1] https://github.com/Perl/perl5/commit/80c1f1e45e8e

Updated mail_error_log.t and stream_error_log.t for consistency.

diff --git a/error_log.t b/error_log.t
--- a/error_log.t
+++ b/error_log.t
@@ -183,7 +183,9 @@ sub lines {
my ($t, $file, $pattern) = @_;

if ($file eq 'stderr') {
- return map { $_ =~ /\Q$pattern\E/ } (<$stderr>);
+ my $value = map { $_ =~ /\Q$pattern\E/ } (<$stderr>);
+ seek $stderr, 0, Fcntl::SEEK_END;
+ return $value;
}

my $path = $t->testdir() . '/' . $file;
diff --git a/mail_error_log.t b/mail_error_log.t
--- a/mail_error_log.t
+++ b/mail_error_log.t
@@ -144,7 +144,9 @@ sub lines {
my ($t, $file, $pattern) = @_;

if ($file eq 'stderr') {
- return map { $_ =~ /\Q$pattern\E/ } (<$stderr>);
+ my $value = map { $_ =~ /\Q$pattern\E/ } (<$stderr>);
+ seek $stderr, 0, Fcntl::SEEK_END;
+ return $value;
}

my $path = $t->testdir() . '/' . $file;
diff --git a/stream_error_log.t b/stream_error_log.t
--- a/stream_error_log.t
+++ b/stream_error_log.t
@@ -150,7 +150,9 @@ sub lines {
my ($t, $file, $pattern) = @_;

if ($file eq 'stderr') {
- return map { $_ =~ /\Q$pattern\E/ } (<$stderr>);
+ my $value = map { $_ =~ /\Q$pattern\E/ } (<$stderr>);
+ seek $stderr, 0, Fcntl::SEEK_END;
+ return $value;
}

my $path = $t->testdir() . '/' . $file;
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH 0 of 1] Tests: unbreak reading new stderr data after eof ...

Sergey Kandaurov 287 May 26, 2023 07:30AM

[PATCH 1 of 1] Tests: unbreak reading new stderr data after eof

Sergey Kandaurov 71 May 26, 2023 07:30AM

Re: [PATCH 1 of 1] Tests: unbreak reading new stderr data after eof

Maxim Dounin 77 May 26, 2023 12:48PM

Re: [PATCH 1 of 1] Tests: unbreak reading new stderr data after eof

Sergey Kandaurov 91 May 29, 2023 09:32AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 293
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready