From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 4/4] tests: guard against missing DBD::SQLite
Date: Wed, 3 Feb 2021 15:51:44 -0600 [thread overview]
Message-ID: <20210203215144.21535-5-e@80x24.org> (raw)
In-Reply-To: <20210203215144.21535-1-e@80x24.org>
The features we use for SharedKV could probably be implemented
with GDBM_File or SDBM_File, but that doesn't seem worth it at
the moment since we depend on SQLite elsewhere.
---
lib/PublicInbox/Config.pm | 2 +-
lib/PublicInbox/Inbox.pm | 2 +-
lib/PublicInbox/LeiDedupe.pm | 8 +++++---
t/extsearch.t | 2 +-
t/lei_overview.t | 1 +
t/lei_xsearch.t | 2 +-
t/shared_kv.t | 1 +
7 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm
index 4f63bc93..a4b1756d 100644
--- a/lib/PublicInbox/Config.pm
+++ b/lib/PublicInbox/Config.pm
@@ -496,7 +496,7 @@ EOF
sub _fill_ei ($$) {
my ($self, $pfx) = @_;
- require PublicInbox::ExtSearch;
+ eval { require PublicInbox::ExtSearch } or return;
my $d = $self->{"$pfx.topdir"};
defined($d) && -d $d ? PublicInbox::ExtSearch->new($d) : undef;
}
diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm
index bee44f8a..a1e34797 100644
--- a/lib/PublicInbox/Inbox.pm
+++ b/lib/PublicInbox/Inbox.pm
@@ -196,7 +196,7 @@ sub isrch { $_[0]->{isrch} // search($_[0]) }
sub over {
$_[0]->{over} //= eval {
- my $srch = $_[0]->{search} //= eval {
+ my $srch = $_[0]->{search} //= do {
_cleanup_later($_[0]);
require PublicInbox::Search;
PublicInbox::Search->new($_[0]);
diff --git a/lib/PublicInbox/LeiDedupe.pm b/lib/PublicInbox/LeiDedupe.pm
index 5c83fd80..2114c0e8 100644
--- a/lib/PublicInbox/LeiDedupe.pm
+++ b/lib/PublicInbox/LeiDedupe.pm
@@ -3,7 +3,6 @@
package PublicInbox::LeiDedupe;
use strict;
use v5.10.1;
-use PublicInbox::SharedKV;
use PublicInbox::ContentHash qw(content_hash);
use Digest::SHA ();
@@ -98,8 +97,11 @@ sub new {
return if ($dd eq 'none' && substr($dst // '', -1) eq '/');
my $m = "dedupe_$dd";
$cls->can($m) or die "unsupported dedupe strategy: $dd\n";
- my $skv = $dd eq 'none' ? undef : PublicInbox::SharedKV->new;
-
+ my $skv;
+ if ($dd ne 'none') {
+ require PublicInbox::SharedKV;
+ $skv = PublicInbox::SharedKV->new;
+ }
# [ $skv, $eml_cb, $smsg_cb, "dedupe_$dd" ]
bless [ $skv, undef, undef, $m ], $cls;
}
diff --git a/t/extsearch.t b/t/extsearch.t
index 2c3f7547..26c3d4ae 100644
--- a/t/extsearch.t
+++ b/t/extsearch.t
@@ -5,11 +5,11 @@ use strict;
use Test::More;
use PublicInbox::TestCommon;
use PublicInbox::Config;
-use PublicInbox::Search;
use PublicInbox::InboxWritable;
use Fcntl qw(:seek);
require_git(2.6);
require_mods(qw(json DBD::SQLite Search::Xapian));
+require PublicInbox::Search;
use_ok 'PublicInbox::ExtSearch';
use_ok 'PublicInbox::ExtSearchIdx';
use_ok 'PublicInbox::OverIdx';
diff --git a/t/lei_overview.t b/t/lei_overview.t
index 896cc01a..dd9e2cad 100644
--- a/t/lei_overview.t
+++ b/t/lei_overview.t
@@ -6,6 +6,7 @@ use v5.10.1;
use Test::More;
use PublicInbox::TestCommon;
use POSIX qw(_exit);
+require_mods(qw(Search::Xapian DBD::SQLite));
require_ok 'PublicInbox::LeiOverview';
my $ovv = bless {}, 'PublicInbox::LeiOverview';
diff --git a/t/lei_xsearch.t b/t/lei_xsearch.t
index f745ea3e..f865ff43 100644
--- a/t/lei_xsearch.t
+++ b/t/lei_xsearch.t
@@ -6,10 +6,10 @@ use v5.10.1;
use Test::More;
use List::Util qw(shuffle max);
use PublicInbox::TestCommon;
-use PublicInbox::ExtSearchIdx;
use PublicInbox::Eml;
use PublicInbox::InboxWritable;
require_mods(qw(DBD::SQLite Search::Xapian));
+require PublicInbox::ExtSearchIdx;
require_git 2.6;
require_ok 'PublicInbox::LeiXSearch';
my ($home, $for_destroy) = tmpdir();
diff --git a/t/shared_kv.t b/t/shared_kv.t
index fcae688a..251b7f39 100644
--- a/t/shared_kv.t
+++ b/t/shared_kv.t
@@ -5,6 +5,7 @@ use strict;
use v5.10.1;
use Test::More;
use PublicInbox::TestCommon;
+require_mods(qw(DBD::SQLite));
use_ok 'PublicInbox::SharedKV';
my ($tmpdir, $for_destroy) = tmpdir();
local $ENV{TMPDIR} = $tmpdir;
prev parent reply other threads:[~2021-02-03 21:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-03 21:51 [PATCH 0/4] doc and dependency updates Eric Wong
2021-02-03 21:51 ` [PATCH 1/4] HACKING: use "just-ahead-of-time" to describe Inline::C Eric Wong
2021-02-03 21:51 ` [PATCH 2/4] spawn: merge common C code together Eric Wong
2021-02-03 21:51 ` [PATCH 3/4] doc: update dependencies (+Storable, Data::Dumper) Eric Wong
2021-02-03 21:51 ` Eric Wong [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210203215144.21535-5-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
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).