user/dev discussion of public-inbox itself
 help / color / mirror / 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	[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

user/dev discussion of public-inbox itself

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ https://public-inbox.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for the project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git