]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
imap_searchqp: attempt to suppress error messages harder
authorEric Wong <e@80x24.org>
Mon, 25 Nov 2024 08:59:33 +0000 (08:59 +0000)
committerEric Wong <e@80x24.org>
Tue, 26 Nov 2024 09:09:40 +0000 (09:09 +0000)
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
t/imap_searchqp.t

index 0c37220c9dcf3884d1ddd2b096cb03e1b784fc3e..d1a943e53733c2c39dcb364590890e13d15d38fe 100644 (file)
@@ -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;
index d7840dd0c02d29b32fb795650d87fb07c0fd3481..95cdd2017a0cfca92c31dcb24625c38ce53a110a 100644 (file)
@@ -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');