From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id BCBA120078 for ; Wed, 3 Feb 2021 21:51:44 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 4/4] tests: guard against missing DBD::SQLite Date: Wed, 3 Feb 2021 15:51:44 -0600 Message-Id: <20210203215144.21535-5-e@80x24.org> In-Reply-To: <20210203215144.21535-1-e@80x24.org> References: <20210203215144.21535-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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;