From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id DF3921F4C1 for ; Mon, 25 Nov 2024 08:59:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1732525173; bh=3bM47j0lm9XJ4cstOU2QnhHQ5La/h68JYQa7HX4brzk=; h=From:To:Subject:Date:From; b=bGyp2yJtIvVmiW/x+s2ds2GgLhaOmlDQEjfNwaHK+ooiETCVVkfsLSLto0+Y0STtj 3alCpqrfrzqaFwHExNkY8jr9/0GQh9w3sEPaqYwtf5DaoOOSBxom6nOK0zGvSN0vTp vIdmskKT7gImVbPIiRUPaDUQ+JzI/J1CtTKOzCPg= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] imap_searchqp: attempt to suppress error messages harder Date: Mon, 25 Nov 2024 08:59:33 +0000 Message-ID: <20241125085933.726538-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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'); { 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');