user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* Re: [PATCH] t/imap_searchqp: hopefully fix test reliability
  2024-04-28 20:08  6% [PATCH] t/imap_searchqp: hopefully fix test reliability Eric Wong
@ 2024-05-07  7:42  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2024-05-07  7:42 UTC (permalink / raw)
  To: meta

Eric Wong <e@80x24.org> wrote:
> Localizing assignments to *STDERR doesn't seem to always work
> with scalar (String) IO objects.  Fortunately, doing actual dup2
> redirects always seems reliable, so do that instead of
> attempting to understand why PerlIO sometimes fails with the
> assignment.

*sigh* Nope...  I just got another failure even with this
commit.  I suspect it's down to Parse::RecDescent using the
less common:

	print {*STDERR} ...

Instead of the more common:

	print STDERR ...

^ permalink raw reply	[relevance 7%]

* [PATCH] t/imap_searchqp: hopefully fix test reliability
@ 2024-04-28 20:08  6% Eric Wong
  2024-05-07  7:42  7% ` Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2024-04-28 20:08 UTC (permalink / raw)
  To: meta

Localizing assignments to *STDERR doesn't seem to always work
with scalar (String) IO objects.  Fortunately, doing actual dup2
redirects always seems reliable, so do that instead of
attempting to understand why PerlIO sometimes fails with the
assignment.
---
 t/imap_searchqp.t | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/t/imap_searchqp.t b/t/imap_searchqp.t
index ff1b4535..d7840dd0 100644
--- a/t/imap_searchqp.t
+++ b/t/imap_searchqp.t
@@ -3,6 +3,8 @@
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict;
 use v5.10.1;
+use autodie qw(open seek read);
+use Fcntl qw(SEEK_SET);
 use Time::Local qw(timegm);
 use PublicInbox::TestCommon;
 require_mods(qw(-imapd));
@@ -29,12 +31,15 @@ is($q->{xap}, 'f:"b"', 'charset handled');
 $q = $parse->(qq{CHARSET WTF-8 From b});
 like($q, qr/\ANO \[/, 'bad charset rejected');
 
-for my $x ('', ' (try #2)') {
-	open my $fh, '>:scalar', \(my $buf = '') or die;
-	local *STDERR = $fh;
+{
+	open my $tmperr, '+>', undef;
+	open my $olderr, '>&', \*STDERR;
+	open STDERR, '>&', $tmperr;
 	$q = $parse->(qq{CHARSET});
-	last if is($buf, '', "nothing spewed to STDERR on bad query$x");
-	diag 'FIXME: above fails mysteriously sometimes, so we try again...';
+	open STDERR, '>&', $olderr;
+	seek $tmperr, 0, SEEK_SET;
+	read($tmperr, my $buf, -s $tmperr);
+	is($buf, '', 'nothing spewed to STDERR on bad query');
 }
 
 like($q, qr/\ABAD /, 'bad charset rejected');

^ permalink raw reply related	[relevance 6%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2024-04-28 20:08  6% [PATCH] t/imap_searchqp: hopefully fix test reliability Eric Wong
2024-05-07  7:42  7% ` Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).