user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] tests: fix running without SQLite or Xapian
Date: Sat,  4 Jan 2020 22:09:38 +0000	[thread overview]
Message-ID: <20200104220938.93619-1-e@80x24.org> (raw)

PublicInbox::Search always loads DBD::SQLite, so we
can't blindly "use" it in t/xcpdb-reshard.t.  We also
need to account for that in TestCommon.
---
 lib/PublicInbox/TestCommon.pm | 12 ++++++++----
 t/xcpdb-reshard.t             |  7 +++++--
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm
index 532cbee6..68785969 100644
--- a/lib/PublicInbox/TestCommon.pm
+++ b/lib/PublicInbox/TestCommon.pm
@@ -65,11 +65,15 @@ sub require_mods {
 	my @need;
 	for my $mod (@mods) {
 		if ($mod eq 'Search::Xapian') {
-			require PublicInbox::Search;
-			PublicInbox::Search::load_xapian() and next;
+			if (eval { require PublicInbox::Search } &&
+				PublicInbox::Search::load_xapian()) {
+				next;
+			}
 		} elsif ($mod eq 'Search::Xapian::WritableDatabase') {
-			require PublicInbox::SearchIdx;
-			PublicInbox::SearchIdx::load_xapian_writable() and next;
+			if (eval { require PublicInbox::SearchIdx } &&
+				PublicInbox::SearchIdx::load_xapian_writable()){
+					next;
+			}
 		} else {
 			eval "require $mod";
 		}
diff --git a/t/xcpdb-reshard.t b/t/xcpdb-reshard.t
index 2a0aeb45..9f0034f1 100644
--- a/t/xcpdb-reshard.t
+++ b/t/xcpdb-reshard.t
@@ -8,7 +8,7 @@ require_mods(qw(DBD::SQLite Search::Xapian));
 require_git('2.6');
 use PublicInbox::MIME;
 use PublicInbox::InboxWritable;
-use PublicInbox::Search;
+require PublicInbox::Search;
 
 my $mime = PublicInbox::MIME->create(
 	header => [
@@ -62,7 +62,10 @@ for my $R (qw(2 4 1 3 3)) {
 	# ensure docids in Xapian match NNTP article numbers
 	my $tot = 0;
 	my %tmp = %nums;
-	my $XapianDatabase = $PublicInbox::Search::X{Database};
+	my $XapianDatabase = do {
+		no warnings 'once';
+		$PublicInbox::Search::X{Database};
+	};
 	foreach my $d (@new_shards) {
 		my $xdb = $XapianDatabase->new($d);
 		$tot += $xdb->get_doccount;

                 reply	other threads:[~2020-01-04 22:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20200104220938.93619-1-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).