unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH 0/3] test dependency fixes for minimal installs
@ 2021-09-12  8:42 Eric Wong
  2021-09-12  8:42 ` [PATCH 1/3] t/lei-*.t: guard setup_public_inboxes with test_lei Eric Wong
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eric Wong @ 2021-09-12  8:42 UTC (permalink / raw)
  To: meta

Everything that worked in 2014 when this project started
should still work today without new dependencies.

Eric Wong (3):
  t/lei-*.t: guard setup_public_inboxes with test_lei
  lei sucks: allow it to work without SQLite
  test_common: only print $@ for Gcf2 failure

 lib/PublicInbox/LeiSucks.pm   |  4 ++--
 lib/PublicInbox/TestCommon.pm | 14 ++++++++------
 t/lei-auto-watch.t            |  3 +--
 t/lei-up.t                    |  2 +-
 t/lei.t                       |  4 ++++
 5 files changed, 16 insertions(+), 11 deletions(-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] t/lei-*.t: guard setup_public_inboxes with test_lei
  2021-09-12  8:42 [PATCH 0/3] test dependency fixes for minimal installs Eric Wong
@ 2021-09-12  8:42 ` Eric Wong
  2021-09-12  8:42 ` [PATCH 2/3] lei sucks: allow it to work without SQLite Eric Wong
  2021-09-12  8:42 ` [PATCH 3/3] test_common: only print $@ for Gcf2 failure Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2021-09-12  8:42 UTC (permalink / raw)
  To: meta

This ensures tests are skipped properly if SQLite or Xapian
are missing and don't bail out.
---
 t/lei-auto-watch.t | 3 +--
 t/lei-up.t         | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/t/lei-auto-watch.t b/t/lei-auto-watch.t
index 3b0c1b10..e5e132eb 100644
--- a/t/lei-auto-watch.t
+++ b/t/lei-auto-watch.t
@@ -3,14 +3,13 @@
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict; use v5.10.1; use PublicInbox::TestCommon;
 use File::Basename qw(basename);
-my ($ro_home, $cfg_path) = setup_public_inboxes;
 my $have_fast_inotify = eval { require Linux::Inotify2 } ||
 	eval { require IO::KQueue };
-
 $have_fast_inotify or
 	diag("$0 IO::KQueue or Linux::Inotify2 missing, test will be slow");
 
 test_lei(sub {
+	my ($ro_home, $cfg_path) = setup_public_inboxes;
 	my $x = "$ENV{HOME}/x";
 	my $y = "$ENV{HOME}/y";
 	lei_ok qw(add-external), "$ro_home/t1";
diff --git a/t/lei-up.t b/t/lei-up.t
index c6f31c74..6b34774d 100644
--- a/t/lei-up.t
+++ b/t/lei-up.t
@@ -2,9 +2,9 @@
 # Copyright 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;
-my ($ro_home, $cfg_path) = setup_public_inboxes;
 use IO::Uncompress::Gunzip qw(gunzip $GunzipError);
 test_lei(sub {
+	my ($ro_home, $cfg_path) = setup_public_inboxes;
 	my $s = eml_load('t/plack-qp.eml')->as_string;
 	lei_ok [qw(import -q -F eml -)], undef, { 0 => \$s, %$lei_opt };
 	lei_ok qw(q z:0.. -f mboxcl2 -o), "$ENV{HOME}/a.mbox.gz";

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] lei sucks: allow it to work without SQLite
  2021-09-12  8:42 [PATCH 0/3] test dependency fixes for minimal installs Eric Wong
  2021-09-12  8:42 ` [PATCH 1/3] t/lei-*.t: guard setup_public_inboxes with test_lei Eric Wong
@ 2021-09-12  8:42 ` Eric Wong
  2021-09-12  8:42 ` [PATCH 3/3] test_common: only print $@ for Gcf2 failure Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2021-09-12  8:42 UTC (permalink / raw)
  To: meta

And try to improve the message about Inline::C while we're at
it, since Socket::Msghdr isn't widely-packaged, yet.
---
 lib/PublicInbox/LeiSucks.pm   |  4 ++--
 lib/PublicInbox/TestCommon.pm | 12 +++++++-----
 t/lei.t                       |  4 ++++
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/lib/PublicInbox/LeiSucks.pm b/lib/PublicInbox/LeiSucks.pm
index 3e945d0b..e832f95e 100644
--- a/lib/PublicInbox/LeiSucks.pm
+++ b/lib/PublicInbox/LeiSucks.pm
@@ -11,7 +11,6 @@ use Digest::SHA ();
 use Config;
 use POSIX ();
 use PublicInbox::Config;
-use PublicInbox::Search;
 
 sub lei_sucks {
 	my ($lei, @argv) = @_;
@@ -41,7 +40,8 @@ sub lei_sucks {
 	} else {
 		push @out, "Unable to load DBI / DBD::SQLite: $@\n";
 	}
-	if (PublicInbox::Search::load_xapian()) {
+	if (eval { require PublicInbox::Search } &&
+			PublicInbox::Search::load_xapian()) {
 		push @out, 'Xapian '.
 			join('.', map {
 				$PublicInbox::Search::Xap->can($_)->();
diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm
index 14dac03f..d28b32b0 100644
--- a/lib/PublicInbox/TestCommon.pm
+++ b/lib/PublicInbox/TestCommon.pm
@@ -521,7 +521,8 @@ SKIP: {
 	local $lei_cwdfh;
 	opendir $lei_cwdfh, '.' or xbail "opendir .: $!";
 	require_git(2.6, 1) or skip('git 2.6+ required for lei test', 2);
-	require_mods(qw(json DBD::SQLite Search::Xapian), 2);
+	my $mods = $test_opt->{mods} // [ 'lei' ];
+	require_mods(@$mods, 2);
 	require PublicInbox::Config;
 	require File::Path;
 	local %ENV = %ENV;
@@ -534,10 +535,11 @@ SKIP: {
 	require PublicInbox::Spawn;
 	state $lei_daemon = PublicInbox::Spawn->can('send_cmd4') ||
 				eval { require Socket::MsgHdr; 1 };
-	# XXX fix and move this inside daemon-only before 1.7 release
-	skip <<'EOM', 1 unless $lei_daemon;
-Socket::MsgHdr missing or Inline::C is unconfigured/missing
-EOM
+	unless ($lei_daemon) {
+		skip('Inline::C unconfigured/missing '.
+'(mkdir -p ~/.cache/public-inbox/inline-c) OR Socket::MsgHdr missing',
+			1);
+	}
 	$lei_opt = { 1 => \$lei_out, 2 => \$lei_err };
 	my ($daemon_pid, $for_destroy, $daemon_xrd);
 	my $tmpdir = $test_opt->{tmpdir};
diff --git a/t/lei.t b/t/lei.t
index dfbcb1f3..d1f1cbc0 100644
--- a/t/lei.t
+++ b/t/lei.t
@@ -176,4 +176,8 @@ test_lei(sub {
 	$test_fail->();
 });
 
+test_lei({ mods => [] }, sub {
+	lei_ok('sucks', \'no optional modules required');
+});
+
 done_testing;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] test_common: only print $@ for Gcf2 failure
  2021-09-12  8:42 [PATCH 0/3] test dependency fixes for minimal installs Eric Wong
  2021-09-12  8:42 ` [PATCH 1/3] t/lei-*.t: guard setup_public_inboxes with test_lei Eric Wong
  2021-09-12  8:42 ` [PATCH 2/3] lei sucks: allow it to work without SQLite Eric Wong
@ 2021-09-12  8:42 ` Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2021-09-12  8:42 UTC (permalink / raw)
  To: meta

Other missing dependencies are more straightforward, but
Gcf2 requires a combination of libgit2-dev, pkg-config,
Inline::C, and proper setup.

This significantly reduces noise in tests with a minimal
set of dependencies installed.
---
 lib/PublicInbox/TestCommon.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm
index d28b32b0..628beaf1 100644
--- a/lib/PublicInbox/TestCommon.pm
+++ b/lib/PublicInbox/TestCommon.pm
@@ -144,7 +144,7 @@ sub require_mods {
 			eval "require $mod";
 		}
 		if ($@) {
-			diag "require $mod: $@";
+			diag "require $mod: $@" if $mod =~ /Gcf2/;
 			push @need, $mod;
 		} elsif ($mod eq 'IO::Socket::SSL' &&
 			# old versions of IO::Socket::SSL aren't supported

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-09-12  8:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-12  8:42 [PATCH 0/3] test dependency fixes for minimal installs Eric Wong
2021-09-12  8:42 ` [PATCH 1/3] t/lei-*.t: guard setup_public_inboxes with test_lei Eric Wong
2021-09-12  8:42 ` [PATCH 2/3] lei sucks: allow it to work without SQLite Eric Wong
2021-09-12  8:42 ` [PATCH 3/3] test_common: only print $@ for Gcf2 failure Eric Wong

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