#!perl -w
-# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
use strict;
-use Test::More;
+use v5.10.1;
use Time::Local qw(timegm);
use PublicInbox::TestCommon;
-require_mods(qw(DBD::SQLite Email::Address::XS||Mail::Address
- Parse::RecDescent));
+require_mods(qw(-imapd));
use_ok 'PublicInbox::IMAPsearchqp';
use_ok 'PublicInbox::IMAP';
$q = $parse->(qq{CHARSET WTF-8 From b});
like($q, qr/\ANO \[/, 'bad charset rejected');
{
- # TODO: squelch errors by default? clients could flood logs
- open my $fh, '>:scalar', \(my $buf) or die;
+ open my $fh, '>:scalar', \(my $buf = '') or die;
local *STDERR = $fh;
$q = $parse->(qq{CHARSET});
+ is($buf, '', 'nothing spewed to STDERR on bad query');
}
like($q, qr/\ABAD /, 'bad charset rejected');
$q = $parse->($s = qq{BEFORE 2-Oct-1993});
is_deeply($q->{sql}, \" AND ts <= $t0", 'BEFORE SQL');
$q = $parse->("FROM z $s");
- is($q->{xap}, qq{f:"z" ts:..$t0}, 'BEFORE Xapian');
+ is($q->{xap}, qq{f:"z" rt:..$t0}, 'BEFORE Xapian');
$q = $parse->($s = qq{SINCE 2-Oct-1993});
is_deeply($q->{sql}, \" AND ts >= $t0", 'SINCE SQL');
$q = $parse->("FROM z $s");
- is($q->{xap}, qq{f:"z" ts:$t0..}, 'SINCE Xapian');
+ is($q->{xap}, qq{f:"z" rt:$t0..}, 'SINCE Xapian');
$q = $parse->($s = qq{ON 2-Oct-1993});
is_deeply($q->{sql}, \" AND ts >= $t0 AND ts <= $t1", 'ON SQL');
$q = $parse->("FROM z $s");
- is($q->{xap}, qq{f:"z" ts:$t0..$t1}, 'ON Xapian');
+ is($q->{xap}, qq{f:"z" rt:$t0..$t1}, 'ON Xapian');
}
{