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] t: avoid "subtest" for Perl 5.10.1 compatibility
Date: Tue,  4 Jun 2019 11:36:39 +0000	[thread overview]
Message-ID: <20190604113639.5413-1-e@80x24.org> (raw)

The version of Test::More from Perl 5.10.1 did not support
"subtest", and the earliest version which did is Perl 5.12.0

The good news is this gives me an excuse to parallelize
the indexlevels-mirror test by splitting it into two.
(it could be further split, even).

Update t/nntpd. to use PI_TEST_VERSION consistently while
we're at it.
---
 MANIFEST                  |  1 +
 t/ds-leak.t               |  4 ++--
 t/indexlevels-mirror-v1.t |  4 ++++
 t/indexlevels-mirror.t    | 29 ++++++++++-------------------
 t/nntpd.t                 |  2 +-
 5 files changed, 18 insertions(+), 22 deletions(-)
 create mode 100644 t/indexlevels-mirror-v1.t

diff --git a/MANIFEST b/MANIFEST
index 8a3f2a4..251f95f 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -204,6 +204,7 @@ t/httpd.t
 t/hval.t
 t/import.t
 t/inbox.t
+t/indexlevels-mirror-v1.t
 t/indexlevels-mirror.t
 t/init.t
 t/linkify.t
diff --git a/t/ds-leak.t b/t/ds-leak.t
index 9e3243e..dd8446d 100644
--- a/t/ds-leak.t
+++ b/t/ds-leak.t
@@ -8,7 +8,7 @@ use warnings;
 use Test::More;
 use_ok 'PublicInbox::DS';
 
-subtest('close-on-exec for epoll and kqueue' => sub {
+if ('close-on-exec for epoll and kqueue') {
 	use PublicInbox::Spawn qw(spawn);
 	my $pid;
 	my $evfd_re = qr/(?:kqueue|eventpoll)/i;
@@ -29,7 +29,7 @@ subtest('close-on-exec for epoll and kqueue' => sub {
 		waitpid($pid, 0);
 	}
 	PublicInbox::DS->Reset;
-});
+}
 
 SKIP: {
 	# not bothering with BSD::Resource
diff --git a/t/indexlevels-mirror-v1.t b/t/indexlevels-mirror-v1.t
new file mode 100644
index 0000000..9998a09
--- /dev/null
+++ b/t/indexlevels-mirror-v1.t
@@ -0,0 +1,4 @@
+# Copyright (C) 2019 all contributors <meta@public-inbox.org>
+# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
+$ENV{PI_TEST_VERSION} = 1;
+require './t/indexlevels-mirror.t';
diff --git a/t/indexlevels-mirror.t b/t/indexlevels-mirror.t
index bf0f801..3597494 100644
--- a/t/indexlevels-mirror.t
+++ b/t/indexlevels-mirror.t
@@ -9,12 +9,12 @@ use PublicInbox::InboxWritable;
 use File::Temp qw/tempdir/;
 require PublicInbox::Admin;
 require './t/common.perl';
-require_git(2.6);
-my $this = (split('/', __FILE__))[-1];
+my $PI_TEST_VERSION = $ENV{PI_TEST_VERSION} || 2;
+require_git('2.6') if $PI_TEST_VERSION == 2;
 
 foreach my $mod (qw(DBD::SQLite)) {
 	eval "require $mod";
-	plan skip_all => "$mod missing for $this" if $@;
+	plan skip_all => "$mod missing for $0" if $@;
 }
 
 my $path = 'blib/script';
@@ -33,10 +33,11 @@ my $mime = PublicInbox::MIME->create(
 
 sub import_index_incremental {
 	my ($v, $level) = @_;
-	my $tmpdir = tempdir("pi-$this-tmp-XXXXXX", TMPDIR => 1, CLEANUP => 1);
+	my $this = "pi-$v-$level-indexlevels";
+	my $tmpdir = tempdir("$this-tmp-XXXXXX", TMPDIR => 1, CLEANUP => 1);
 	my $ibx = PublicInbox::Inbox->new({
 		mainrepo => "$tmpdir/testbox",
-		name => "$this-$v",
+		name => $this,
 		version => $v,
 		-primary_address => 'test@example.com',
 		indexlevel => $level,
@@ -165,24 +166,14 @@ sub import_index_incremental {
 	   'indexlevel detectable by Admin '.$v.$level);
 }
 
-# we can probably cull some other tests and put full/medium tests, here
-for my $level (qw(basic)) {
-	for my $v (1..2) {
-		subtest("v$v indexlevel=$level" => sub {
-			import_index_incremental($v, $level);
-		})
-	}
-}
+# we can probably cull some other tests
+import_index_incremental($PI_TEST_VERSION, 'basic');
 
 SKIP: {
 	require PublicInbox::Search;
 	PublicInbox::Search::load_xapian() or skip 'Search::Xapian missing', 2;
-	for my $v (1..2) {
-		foreach my $l (qw(medium full)) {
-			subtest("v$v indexlevel=$l" => sub {
-				import_index_incremental($v, $l);
-			});
-		}
+	foreach my $l (qw(medium full)) {
+		import_index_incremental($PI_TEST_VERSION, $l);
 	}
 }
 
diff --git a/t/nntpd.t b/t/nntpd.t
index aa62ff6..c73cc12 100644
--- a/t/nntpd.t
+++ b/t/nntpd.t
@@ -19,7 +19,7 @@ use Sys::Hostname;
 require './t/common.perl';
 
 # FIXME: make easier to test both versions
-my $version = $ENV{PI_VERSION} || 2;
+my $version = $ENV{PI_TEST_VERSION} || 2;
 require_git('2.6') if $version == 2;
 
 my $tmpdir = tempdir('pi-nntpd-XXXXXX', TMPDIR => 1, CLEANUP => 1);
-- 
EW


                 reply	other threads:[~2019-06-04 11:36 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: http://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=20190604113639.5413-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).