unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH] imap_searchqp: attempt to suppress error messages harder
@ 2024-11-25  8:59 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2024-11-25  8:59 UTC (permalink / raw)
  To: meta

In addition to setting $::RD_ERRORS and $::RD_WARN to `undef'
for parsing the generated $prd object, we'll make those `undef'
on Parse::RecDescent object instantion, too, in an attempt to
reduce test failures.

Furthermore, add a note about the occasional test failure and
maybe somebody else can help us figure it out since it's been
sporadically failing for a while...

Followup-to: 31ca305f28d747a0 (t/imap_searchqp: hopefully fix test reliability, 2024-04-28)
Followup-to: fa8bce03925461ef (t/imap_searchqp.t: retry bad query test on failure, 2023-10-10)
---
 lib/PublicInbox/IMAPsearchqp.pm | 8 +++++---
 t/imap_searchqp.t               | 7 ++++++-
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/lib/PublicInbox/IMAPsearchqp.pm b/lib/PublicInbox/IMAPsearchqp.pm
index 0c37220c..d1a943e5 100644
--- a/lib/PublicInbox/IMAPsearchqp.pm
+++ b/lib/PublicInbox/IMAPsearchqp.pm
@@ -170,6 +170,9 @@ sub impossible {
 	$$sql .= ' AND num < 0';
 }
 
+# XXX not sure suppessing RD_* is needed here, but t/imap_searchqp.t
+# sporadically fails
+local ($::RD_ERRORS, $::RD_WARN);
 my $prd = Parse::RecDescent->new(<<'EOG');
 <nocheck>
 { my $q = $PublicInbox::IMAPsearchqp::q; }
@@ -278,9 +281,8 @@ sub parse {
 	my ($imap, $query) = @_;
 	my $sql = '';
 	%$q = (sql => \$sql, imap => $imap); # imap = PublicInbox::IMAP obj
-	# $::RD_TRACE = 1;
-	local $::RD_ERRORS = undef;
-	local $::RD_WARN = undef;
+	# XXX not always effective for t/imap_searchqp.t
+	local ($::RD_ERRORS, $::RD_WARN);
 	my $res = eval { $prd->search_key(uc($query)) };
 	return $@ if $@ && $@ =~ /\A(?:BAD|NO) /;
 	return 'BAD unexpected result' if !$res || $res != $q;
diff --git a/t/imap_searchqp.t b/t/imap_searchqp.t
index d7840dd0..95cdd201 100644
--- a/t/imap_searchqp.t
+++ b/t/imap_searchqp.t
@@ -39,7 +39,12 @@ like($q, qr/\ANO \[/, 'bad charset rejected');
 	open STDERR, '>&', $olderr;
 	seek $tmperr, 0, SEEK_SET;
 	read($tmperr, my $buf, -s $tmperr);
-	is($buf, '', 'nothing spewed to STDERR on bad query');
+	is($buf, '', 'nothing spewed to STDERR on bad query') or warn <<'EOM';
+FIXME: this sometimes fails despite setting $::RD_ERRORS + $::RD_WARN to
+undef in PublicInbox::IMAPsearchqp::parse and I don't understand why.
+It usually suceeds.  Let us know if you can help us understand this
+occasional failure at meta@public-inbox.org
+EOM
 }
 
 like($q, qr/\ABAD /, 'bad charset rejected');

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-11-25  8:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-25  8:59 [PATCH] imap_searchqp: attempt to suppress error messages harder Eric Wong

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).