comparison stream_error_log.t @ 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 f3ba4c74de31
children
comparison
equal deleted inserted replaced
1896:8b74936ff2ac 1897:38f1fd9ca3e6
148 148
149 sub lines { 149 sub lines {
150 my ($t, $file, $pattern) = @_; 150 my ($t, $file, $pattern) = @_;
151 151
152 if ($file eq 'stderr') { 152 if ($file eq 'stderr') {
153 return map { $_ =~ /\Q$pattern\E/ } (<$stderr>); 153 my $value = map { $_ =~ /\Q$pattern\E/ } (<$stderr>);
154 $stderr->clearerr();
155 return $value;
154 } 156 }
155 157
156 my $path = $t->testdir() . '/' . $file; 158 my $path = $t->testdir() . '/' . $file;
157 open my $fh, '<', $path or return "$!"; 159 open my $fh, '<', $path or return "$!";
158 my $value = map { $_ =~ /\Q$pattern\E/ } (<$fh>); 160 my $value = map { $_ =~ /\Q$pattern\E/ } (<$fh>);