From: Eric Wong Date: Mon, 25 Nov 2024 08:59:33 +0000 (+0000) Subject: imap_searchqp: attempt to suppress error messages harder X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bfa08d1be316c05a3f2147fce012c4d086e33c5b;p=thirdparty%2Fpublic-inbox.git imap_searchqp: attempt to suppress error messages harder 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) --- diff --git a/lib/PublicInbox/IMAPsearchqp.pm b/lib/PublicInbox/IMAPsearchqp.pm index 0c37220c9..d1a943e53 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'); { 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 d7840dd0c..95cdd2017 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');