unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH] test_common: require_mods bundles
@ 2021-03-28  0:17 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2021-03-28  0:17 UTC (permalink / raw)
  To: meta

This makes it easier to manage test dependencies on systems
where optional stuff isn't installed.  This fixes some lei tests
which didn't check for Plack before starting -httpd, and ensures
Parse::RecDescent is available for -imapd in case
Mail::IMAPClient stops using it.
---
 lib/PublicInbox/TestCommon.pm | 23 ++++++++++++++++-------
 t/altid_v2.t                  |  2 +-
 t/imap.t                      |  5 ++---
 t/imap_searchqp.t             |  5 ++---
 t/imapd-tls.t                 |  3 +--
 t/imapd.t                     |  3 +--
 t/init.t                      |  2 +-
 t/lei-convert.t               |  3 +--
 t/lei-import-imap.t           |  3 +--
 t/lei-mirror.t                |  3 +--
 t/lei-q-remote-import.t       |  3 +--
 t/net_reader-imap.t           |  2 +-
 xt/imapd-mbsync-oimap.t       |  4 ++--
 xt/imapd-validate.t           |  4 ++--
 xt/mem-imapd-tls.t            |  5 ++---
 15 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm
index 72617a78..d36a63aa 100644
--- a/lib/PublicInbox/TestCommon.pm
+++ b/lib/PublicInbox/TestCommon.pm
@@ -107,20 +107,29 @@ sub require_mods {
 	my $maybe = pop @mods if $mods[-1] =~ /\A[0-9]+\z/;
 	my @need;
 	while (my $mod = shift(@mods)) {
+		if ($mod eq 'lei') {
+			require_git(2.6, $maybe ? $maybe : ());
+			push @mods, qw(DBD::SQLite Search::Xapian);
+			$mod = 'json'; # fall-through
+		}
 		if ($mod eq 'json') {
-			$mod = 'Cpanel::JSON::XS||JSON::MaybeXS||'.
-				'JSON||JSON::PP'
+			$mod = 'Cpanel::JSON::XS||JSON::MaybeXS||JSON||JSON::PP'
+		} elsif ($mod eq '-httpd') {
+			push @mods, qw(Plack::Builder Plack::Util);
+			next;
+		} elsif ($mod eq '-imapd') {
+			push @mods, qw(Parse::RecDescent DBD::SQLite
+					Email::Address::XS||Mail::Address);
+			next;
+		} elsif ($mod eq '-nntpd') {
+			push @mods, qw(DBD::SQLite);
+			next;
 		}
 		if ($mod eq 'Search::Xapian') {
 			if (eval { require PublicInbox::Search } &&
 				PublicInbox::Search::load_xapian()) {
 				next;
 			}
-		} elsif ($mod eq 'Search::Xapian::WritableDatabase') {
-			if (eval { require PublicInbox::SearchIdx } &&
-				PublicInbox::SearchIdx::load_xapian_writable()){
-					next;
-			}
 		} elsif (index($mod, '||') >= 0) { # "Foo||Bar"
 			my $ok;
 			for my $m (split(/\Q||\E/, $mod)) {
diff --git a/t/altid_v2.t b/t/altid_v2.t
index 493982a1..47ebec85 100644
--- a/t/altid_v2.t
+++ b/t/altid_v2.t
@@ -5,9 +5,9 @@ use strict;
 use v5.10.1;
 use PublicInbox::TestCommon;
 use PublicInbox::Eml;
-use PublicInbox::Msgmap;
 require_git(2.6);
 require_mods(qw(DBD::SQLite Search::Xapian));
+require PublicInbox::Msgmap;
 my $another = 'another-nntp.sqlite3';
 my $altid = [ "serial:gmane:file=$another" ];
 my $ibx = create_inbox 'v2', version => 2, indexlevel => 'medium',
diff --git a/t/imap.t b/t/imap.t
index 0ec02818..e6efe04f 100644
--- a/t/imap.t
+++ b/t/imap.t
@@ -3,11 +3,10 @@
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 # unit tests (no network) for IMAP, see t/imapd.t for end-to-end tests
 use strict;
-use Test::More;
+use v5.10.1;
 use PublicInbox::TestCommon;
 require_git 2.6;
-require_mods(qw(DBD::SQLite Email::Address::XS||Mail::Address
-	Parse::RecDescent));
+require_mods(qw(-imapd));
 require_ok 'PublicInbox::IMAP';
 require_ok 'PublicInbox::IMAPD';
 
diff --git a/t/imap_searchqp.t b/t/imap_searchqp.t
index 6b4121ea..e2f49e5a 100644
--- a/t/imap_searchqp.t
+++ b/t/imap_searchqp.t
@@ -2,11 +2,10 @@
 # Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict;
-use Test::More;
+use v5.10.1;
 use Time::Local qw(timegm);
 use PublicInbox::TestCommon;
-require_mods(qw(DBD::SQLite Email::Address::XS||Mail::Address
-	Parse::RecDescent));
+require_mods(qw(-imapd));
 use_ok 'PublicInbox::IMAPsearchqp';
 use_ok 'PublicInbox::IMAP';
 
diff --git a/t/imapd-tls.t b/t/imapd-tls.t
index 125846e2..72ba8769 100644
--- a/t/imapd-tls.t
+++ b/t/imapd-tls.t
@@ -6,8 +6,7 @@ use Test::More;
 use Socket qw(IPPROTO_TCP SOL_SOCKET);
 use PublicInbox::TestCommon;
 # IO::Poll is part of the standard library, but distros may split it off...
-require_mods(qw(DBD::SQLite IO::Socket::SSL Mail::IMAPClient IO::Poll
-	Email::Address::XS||Mail::Address Parse::RecDescent));
+require_mods(qw(-imapd IO::Socket::SSL Mail::IMAPClient IO::Poll));
 my $imap_client = 'Mail::IMAPClient';
 $imap_client->can('starttls') or
 	plan skip_all => 'Mail::IMAPClient does not support TLS';
diff --git a/t/imapd.t b/t/imapd.t
index c9911d1b..8cdb4e4a 100644
--- a/t/imapd.t
+++ b/t/imapd.t
@@ -8,8 +8,7 @@ use Time::HiRes ();
 use PublicInbox::TestCommon;
 use PublicInbox::Config;
 use PublicInbox::Spawn qw(which);
-require_mods(qw(DBD::SQLite Mail::IMAPClient Mail::IMAPClient::BodyStructure
-	Email::Address::XS||Mail::Address Parse::RecDescent));
+require_mods(qw(-imapd Mail::IMAPClient));
 my $imap_client = 'Mail::IMAPClient';
 my $can_compress = $imap_client->can('compress');
 if ($can_compress) { # hope this gets fixed upstream, soon
diff --git a/t/init.t b/t/init.t
index b8dfea66..d46bef23 100644
--- a/t/init.t
+++ b/t/init.t
@@ -74,7 +74,7 @@ sub quiet_fail {
 }
 
 SKIP: {
-	require_mods(qw(DBD::SQLite Search::Xapian::WritableDatabase), 2);
+	require_mods(qw(DBD::SQLite Search::Xapian), 2);
 	require_git(2.6, 1) or skip "git 2.6+ required", 2;
 	use_ok 'PublicInbox::Msgmap';
 	local $ENV{PI_DIR} = "$tmpdir/.public-inbox/";
diff --git a/t/lei-convert.t b/t/lei-convert.t
index 9b430d8e..7ff628f9 100644
--- a/t/lei-convert.t
+++ b/t/lei-convert.t
@@ -6,8 +6,7 @@ use PublicInbox::MboxReader;
 use PublicInbox::MdirReader;
 use PublicInbox::NetReader;
 use PublicInbox::Eml;
-require_git 2.6;
-require_mods(qw(DBD::SQLite Search::Xapian Mail::IMAPClient Net::NNTP));
+require_mods(qw(lei -imapd -nntpd Mail::IMAPClient Net::NNTP));
 my ($tmpdir, $for_destroy) = tmpdir;
 my $sock = tcp_server;
 my $cmd = [ '-imapd', '-W0', "--stdout=$tmpdir/i1", "--stderr=$tmpdir/i2" ];
diff --git a/t/lei-import-imap.t b/t/lei-import-imap.t
index 15a355ab..fd38037a 100644
--- a/t/lei-import-imap.t
+++ b/t/lei-import-imap.t
@@ -2,8 +2,7 @@
 # Copyright (C) 2021 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict; use v5.10.1; use PublicInbox::TestCommon;
-require_git 2.6;
-require_mods(qw(DBD::SQLite Search::Xapian Mail::IMAPClient));
+require_mods(qw(lei -imapd Mail::IMAPClient));
 my ($ro_home, $cfg_path) = setup_public_inboxes;
 my ($tmpdir, $for_destroy) = tmpdir;
 my $sock = tcp_server;
diff --git a/t/lei-mirror.t b/t/lei-mirror.t
index 6039e568..5ab18b6d 100644
--- a/t/lei-mirror.t
+++ b/t/lei-mirror.t
@@ -2,8 +2,7 @@
 # Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict; use v5.10.1; use PublicInbox::TestCommon;
-require_git 2.6;
-require_mods(qw(DBD::SQLite Search::Xapian));
+require_mods(qw(-httpd lei));
 my $sock = tcp_server();
 my ($tmpdir, $for_destroy) = tmpdir();
 my $http = 'http://'.tcp_host_port($sock);
diff --git a/t/lei-q-remote-import.t b/t/lei-q-remote-import.t
index 93828a24..32c5172b 100644
--- a/t/lei-q-remote-import.t
+++ b/t/lei-q-remote-import.t
@@ -2,8 +2,7 @@
 # Copyright (C) 2021 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict; use v5.10.1; use PublicInbox::TestCommon;
-require_git 2.6;
-require_mods(qw(json DBD::SQLite Search::Xapian));
+require_mods(qw(lei -httpd));
 use PublicInbox::MboxReader;
 my ($ro_home, $cfg_path) = setup_public_inboxes;
 my $sock = tcp_server;
diff --git a/t/net_reader-imap.t b/t/net_reader-imap.t
index adcd6931..e478ee07 100644
--- a/t/net_reader-imap.t
+++ b/t/net_reader-imap.t
@@ -3,7 +3,7 @@
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict; use v5.10.1; use PublicInbox::TestCommon;
 require_git 2.6;
-require_mods(qw(DBD::SQLite Search::Xapian Mail::IMAPClient));
+require_mods(qw(-imapd Search::Xapian Mail::IMAPClient));
 use PublicInbox::Config;
 my ($tmpdir, $for_destroy) = tmpdir;
 my ($ro_home, $cfg_path) = setup_public_inboxes;
diff --git a/xt/imapd-mbsync-oimap.t b/xt/imapd-mbsync-oimap.t
index 6635e2b4..0baf5b4c 100644
--- a/xt/imapd-mbsync-oimap.t
+++ b/xt/imapd-mbsync-oimap.t
@@ -3,11 +3,11 @@
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 # ensure mbsync and offlineimap compatibility
 use strict;
-use Test::More;
+use v5.10.1;
 use File::Path qw(mkpath);
 use PublicInbox::TestCommon;
 use PublicInbox::Spawn qw(which spawn);
-require_mods(qw(DBD::SQLite Email::Address::XS||Mail::Address));
+require_mods(qw(-imapd));
 my $inboxdir = $ENV{GIANT_INBOX_DIR};
 (defined($inboxdir) && -d $inboxdir) or
 	plan skip_all => "GIANT_INBOX_DIR not defined for $0";
diff --git a/xt/imapd-validate.t b/xt/imapd-validate.t
index 3a229883..5d27d2a0 100644
--- a/xt/imapd-validate.t
+++ b/xt/imapd-validate.t
@@ -3,7 +3,7 @@
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 # Expensive test to validate compression and TLS.
 use strict;
-use Test::More;
+use v5.10.1;
 use Symbol qw(gensym);
 use PublicInbox::DS qw(now);
 use POSIX qw(_exit);
@@ -15,7 +15,7 @@ my $BATCH = $ENV{TEST_BATCH} // 100;
 my $REPEAT = $ENV{TEST_REPEAT} // 1;
 diag "TEST_BATCH=$BATCH TEST_REPEAT=$REPEAT";
 
-require_mods(qw(Mail::IMAPClient Email::Address::XS||Mail::Address));
+require_mods(qw(Mail::IMAPClient -imapd));
 my $imap_client = 'Mail::IMAPClient';
 my $can_compress = $imap_client->can('compress');
 if ($can_compress) { # hope this gets fixed upstream, soon
diff --git a/xt/mem-imapd-tls.t b/xt/mem-imapd-tls.t
index 99d8cb0d..bd75ef45 100644
--- a/xt/mem-imapd-tls.t
+++ b/xt/mem-imapd-tls.t
@@ -4,13 +4,12 @@
 # Idle client memory usage test, particularly after EXAMINE when
 # Message Sequence Numbers are loaded
 use strict;
-use Test::More;
+use v5.10.1;
 use Socket qw(SOCK_STREAM IPPROTO_TCP SOL_SOCKET);
 use PublicInbox::TestCommon;
 use PublicInbox::Syscall qw(:epoll);
 use PublicInbox::DS;
-require_mods(qw(DBD::SQLite Email::Address::XS||Mail::Address
-	Parse::RecDescent));
+require_mods(qw(-imapd));
 my $inboxdir = $ENV{GIANT_INBOX_DIR};
 my $TEST_TLS;
 SKIP: {

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

only message in thread, other threads:[~2021-03-28  0:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-28  0:17 [PATCH] test_common: require_mods bundles Eric Wong

unofficial mirror of meta@public-inbox.org

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/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://yhetil.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.mail.public-inbox.meta
	nntp://news.public-inbox.org/inbox.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git