user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH] tests: fix running without SQLite or Xapian
@ 2020-01-04 22:09 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2020-01-04 22:09 UTC (permalink / raw)
  To: meta

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;

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-01-04 22:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-04 22:09 [PATCH] tests: fix running without SQLite or Xapian Eric Wong

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).