changeset 1897:38f1fd9ca3e6

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 found changed in Ubuntu 23.04's Perl 5.36, which applies the upstream patch [1] expected for inclusion in the upcoming Perl 5.38. The fix is to clear the filehandle's error state to continue reading. [1] https://github.com/Perl/perl5/commit/80c1f1e45e8e Updated mail_error_log.t and stream_error_log.t for consistency.
author Sergey Kandaurov <pluknet@nginx.com>
date Mon, 29 May 2023 17:27:11 +0400
parents 8b74936ff2ac
children 26252394dd58
files error_log.t mail_error_log.t stream_error_log.t
diffstat 3 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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>);
+		$stderr->clearerr();
+		return $value;
 	}
 
 	my $path = $t->testdir() . '/' . $file;
--- 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>);
+		$stderr->clearerr();
+		return $value;
 	}
 
 	my $path = $t->testdir() . '/' . $file;
--- 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>);
+		$stderr->clearerr();
+		return $value;
 	}
 
 	my $path = $t->testdir() . '/' . $file;