[PATCH 1 of 1] Tests: unbreak reading new stderr data after eof
Sergey Kandaurov
pluknet at nginx.com
Fri May 26 11:24:12 UTC 2023
# HG changeset patch
# User Sergey Kandaurov <pluknet at 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;
More information about the nginx-devel
mailing list