user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* Re: [PATCH 5/6] tests: move t/common.perl to PublicInbox::TestCommon
  2019-12-18  3:36  2% ` [PATCH 5/6] tests: move t/common.perl to PublicInbox::TestCommon Eric Wong
@ 2019-12-19  4:02  7%   ` Eric Wong
  0 siblings, 0 replies; 3+ results
From: Eric Wong @ 2019-12-19  4:02 UTC (permalink / raw)
  To: meta

Eric Wong <e@80x24.org> wrote:
> diff --git a/t/common.perl b/lib/PublicInbox/TestCommon.pm
> similarity index 94%
> rename from t/common.perl
> rename to lib/PublicInbox/TestCommon.pm
> index 288a0a19..2804b5b6 100644
> --- a/t/common.perl
> +++ b/lib/PublicInbox/TestCommon.pm
> @@ -1,11 +1,15 @@
>  # Copyright (C) 2015-2019 all contributors <meta@public-inbox.org>
>  # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
>  
> +# internal APIs used only for tests
> +package PublicInbox::TestCommon;

Oops, forgot to account for the namespace change in the uncommon
tail(1) support code path.  Will squash the following:

diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm
index 2804b5b6..45306a5a 100644
--- a/lib/PublicInbox/TestCommon.pm
+++ b/lib/PublicInbox/TestCommon.pm
@@ -279,7 +279,7 @@ sub DESTROY {
 	my ($self) = @_;
 	return if $self->{owner} != $$;
 	if (my $tail = delete $self->{tail_pid}) {
-		::wait_for_tail();
+		PublicInbox::TestCommon::wait_for_tail();
 		CORE::kill('TERM', $tail);
 	}
 	my $pid = delete $self->{pid} or return;


^ permalink raw reply	[relevance 7%]

* [PATCH 5/6] tests: move t/common.perl to PublicInbox::TestCommon
  2019-12-18  3:36  4% [PATCH 0/6] test updates and speedups Eric Wong
@ 2019-12-18  3:36  2% ` Eric Wong
  2019-12-19  4:02  7%   ` Eric Wong
  0 siblings, 1 reply; 3+ results
From: Eric Wong @ 2019-12-18  3:36 UTC (permalink / raw)
  To: meta

We want to be able to use run_script with *.t files, so
t/common.perl putting subs into the top-level "main" namespace
won't work.  Instead, make it a module which uses Exporter
like other libraries.
---
 MANIFEST                                       |  2 +-
 t/common.perl => lib/PublicInbox/TestCommon.pm | 16 ++++++++++------
 t/admin.t                                      |  2 +-
 t/altid.t                                      |  2 +-
 t/altid_v2.t                                   |  2 +-
 t/cgi.t                                        |  2 +-
 t/config.t                                     |  2 +-
 t/convert-compact.t                            |  2 +-
 t/edit.t                                       |  2 +-
 t/emergency.t                                  |  2 +-
 t/feed.t                                       |  2 +-
 t/filter_rubylang.t                            |  2 +-
 t/git.t                                        |  2 +-
 t/html_index.t                                 |  2 +-
 t/httpd-corner.t                               |  2 +-
 t/httpd-https.t                                |  2 +-
 t/httpd-unix.t                                 |  2 +-
 t/httpd.t                                      |  2 +-
 t/import.t                                     |  2 +-
 t/indexlevels-mirror.t                         |  2 +-
 t/init.t                                       |  2 +-
 t/mda.t                                        |  2 +-
 t/mda_filter_rubylang.t                        |  2 +-
 t/msgmap.t                                     |  2 +-
 t/nntpd-tls.t                                  |  2 +-
 t/nntpd.t                                      |  2 +-
 t/nulsubject.t                                 |  2 +-
 t/over.t                                       |  2 +-
 t/plack.t                                      |  2 +-
 t/psgi_attach.t                                |  2 +-
 t/psgi_bad_mids.t                              |  2 +-
 t/psgi_mount.t                                 |  2 +-
 t/psgi_multipart_not.t                         |  2 +-
 t/psgi_scan_all.t                              |  2 +-
 t/psgi_search.t                                |  2 +-
 t/psgi_text.t                                  |  2 +-
 t/psgi_v2.t                                    |  2 +-
 t/purge.t                                      |  2 +-
 t/replace.t                                    |  2 +-
 t/search-thr-index.t                           |  2 +-
 t/search.t                                     |  2 +-
 t/solver_git.t                                 |  2 +-
 t/spamcheck_spamc.t                            |  2 +-
 t/v1-add-remove-add.t                          |  2 +-
 t/v1reindex.t                                  |  2 +-
 t/v2-add-remove-add.t                          |  2 +-
 t/v2mda.t                                      |  2 +-
 t/v2mirror.t                                   |  2 +-
 t/v2reindex.t                                  |  2 +-
 t/v2writable.t                                 |  2 +-
 t/watch_filter_rubylang.t                      |  2 +-
 t/watch_maildir.t                              |  2 +-
 t/watch_maildir_v2.t                           |  2 +-
 t/www_listing.t                                |  2 +-
 t/xcpdb-reshard.t                              |  2 +-
 xt/git-http-backend.t                          |  2 +-
 xt/nntpd-validate.t                            |  2 +-
 xt/perf-msgview.t                              |  2 +-
 xt/perf-nntpd.t                                |  2 +-
 59 files changed, 68 insertions(+), 64 deletions(-)
 rename t/common.perl => lib/PublicInbox/TestCommon.pm (94%)

diff --git a/MANIFEST b/MANIFEST
index 3a301ee7..6bff79ad 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -149,6 +149,7 @@ lib/PublicInbox/Spawn.pm
 lib/PublicInbox/SpawnPP.pm
 lib/PublicInbox/Syscall.pm
 lib/PublicInbox/TLS.pm
+lib/PublicInbox/TestCommon.pm
 lib/PublicInbox/Tmpfile.pm
 lib/PublicInbox/Unsubscribe.pm
 lib/PublicInbox/UserContent.pm
@@ -202,7 +203,6 @@ t/altid.t
 t/altid_v2.t
 t/cgi.t
 t/check-www-inbox.perl
-t/common.perl
 t/config.t
 t/config_limiter.t
 t/content_id.t
diff --git a/t/common.perl b/lib/PublicInbox/TestCommon.pm
similarity index 94%
rename from t/common.perl
rename to lib/PublicInbox/TestCommon.pm
index 288a0a19..2804b5b6 100644
--- a/t/common.perl
+++ b/lib/PublicInbox/TestCommon.pm
@@ -1,11 +1,15 @@
 # Copyright (C) 2015-2019 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 
+# internal APIs used only for tests
+package PublicInbox::TestCommon;
+use strict;
+use parent qw(Exporter);
 use Fcntl qw(FD_CLOEXEC F_SETFD F_GETFD :seek);
 use POSIX qw(dup2);
-use strict;
-use warnings;
 use IO::Socket::INET;
+our @EXPORT = qw(tmpdir tcp_server tcp_connect require_git
+	run_script start_script key2sub);
 
 sub tmpdir (;$) {
 	my ($base) = @_;
@@ -49,7 +53,7 @@ sub require_git ($;$) {
 	my $cur_int = ($cur_maj << 24) | ($cur_min << 16);
 	if ($cur_int < $req_int) {
 		return 0 if $maybe;
-		plan skip_all => "git $req+ required, have $cur_maj.$cur_min";
+		plan(skip_all => "git $req+ required, have $cur_maj.$cur_min");
 	}
 	1;
 }
@@ -105,7 +109,7 @@ package $pkg;
 use strict;
 use subs qw(exit);
 
-*exit = *::run_script_exit;
+*exit = *PublicInbox::TestCommon::run_script_exit;
 sub main {
 $str
 	0;
@@ -244,10 +248,10 @@ sub start_script {
 			die "FAIL: ",join(' ', $key, @argv), ": $!\n";
 		}
 	}
-	TestProcess->new($pid, $tail_pid);
+	PublicInboxTestProcess->new($pid, $tail_pid);
 }
 
-package TestProcess;
+package PublicInboxTestProcess;
 use strict;
 
 # prevent new threads from inheriting these objects
diff --git a/t/admin.t b/t/admin.t
index 6458982b..b517d2f8 100644
--- a/t/admin.t
+++ b/t/admin.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 use_ok 'PublicInbox::Admin', qw(resolve_repo_dir);
 my ($tmpdir, $for_destroy) = tmpdir();
 my $git_dir = "$tmpdir/v1";
diff --git a/t/altid.t b/t/altid.t
index 86e7f9de..fc5bcbc2 100644
--- a/t/altid.t
+++ b/t/altid.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 foreach my $mod (qw(DBD::SQLite Search::Xapian)) {
 	eval "require $mod";
 	plan skip_all => "$mod missing for altid.t" if $@;
diff --git a/t/altid_v2.t b/t/altid_v2.t
index 9e152fc4..5bd62e13 100644
--- a/t/altid_v2.t
+++ b/t/altid_v2.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 require_git(2.6);
 foreach my $mod (qw(DBD::SQLite Search::Xapian)) {
 	eval "require $mod";
diff --git a/t/cgi.t b/t/cgi.t
index 62cea499..424b738e 100644
--- a/t/cgi.t
+++ b/t/cgi.t
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use Test::More;
 use Email::MIME;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 my ($tmpdir, $for_destroy) = tmpdir();
 my $home = "$tmpdir/pi-home";
 my $pi_home = "$home/.public-inbox";
diff --git a/t/config.t b/t/config.t
index ade2e796..db3f9b2a 100644
--- a/t/config.t
+++ b/t/config.t
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 use Test::More;
 use PublicInbox::Config;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 my ($tmpdir, $for_destroy) = tmpdir();
 
 {
diff --git a/t/convert-compact.t b/t/convert-compact.t
index b8dc5ed5..c6da64ea 100644
--- a/t/convert-compact.t
+++ b/t/convert-compact.t
@@ -5,7 +5,7 @@ use warnings;
 use Test::More;
 use PublicInbox::MIME;
 use PublicInbox::Spawn qw(which);
-require './t/common.perl';
+use PublicInbox::TestCommon;
 require_git(2.6);
 my @mods = qw(DBD::SQLite Search::Xapian);
 foreach my $mod (@mods) {
diff --git a/t/edit.t b/t/edit.t
index 122aa19f..9a78b45d 100644
--- a/t/edit.t
+++ b/t/edit.t
@@ -4,7 +4,7 @@
 use strict;
 use warnings;
 use Test::More;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 require_git(2.6);
 require PublicInbox::Inbox;
 require PublicInbox::InboxWritable;
diff --git a/t/emergency.t b/t/emergency.t
index d6c7b6d5..1cb1098d 100644
--- a/t/emergency.t
+++ b/t/emergency.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 my ($tmpdir, $for_destroy) = tmpdir();
 use_ok 'PublicInbox::Emergency';
 
diff --git a/t/feed.t b/t/feed.t
index daf97a72..97468c73 100644
--- a/t/feed.t
+++ b/t/feed.t
@@ -10,7 +10,7 @@ use PublicInbox::Import;
 use PublicInbox::Config;
 use PublicInbox::Inbox;
 my $have_xml_feed = eval { require XML::Feed; 1 };
-require './t/common.perl';
+use PublicInbox::TestCommon;
 
 sub string_feed {
 	my $res = PublicInbox::Feed::generate($_[0]);
diff --git a/t/filter_rubylang.t b/t/filter_rubylang.t
index 33753925..576cbdeb 100644
--- a/t/filter_rubylang.t
+++ b/t/filter_rubylang.t
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 use Test::More;
 use Email::MIME;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 use_ok 'PublicInbox::Filter::RubyLang';
 
 my $f = PublicInbox::Filter::RubyLang->new;
diff --git a/t/git.t b/t/git.t
index cc4fc591..d4694f44 100644
--- a/t/git.t
+++ b/t/git.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 my ($dir, $for_destroy) = tmpdir();
 use PublicInbox::Spawn qw(popen_rd);
 
diff --git a/t/html_index.t b/t/html_index.t
index 51ea9a25..55aa6dc7 100644
--- a/t/html_index.t
+++ b/t/html_index.t
@@ -8,7 +8,7 @@ use PublicInbox::Feed;
 use PublicInbox::Git;
 use PublicInbox::Import;
 use PublicInbox::Inbox;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 my ($tmpdir, $for_destroy) = tmpdir();
 my $git_dir = "$tmpdir/gittest";
 my $ibx = PublicInbox::Inbox->new({
diff --git a/t/httpd-corner.t b/t/httpd-corner.t
index a8cdb2e9..fb3ffcf1 100644
--- a/t/httpd-corner.t
+++ b/t/httpd-corner.t
@@ -19,7 +19,7 @@ use IO::Socket::UNIX;
 use Fcntl qw(:seek);
 use Socket qw(IPPROTO_TCP TCP_NODELAY SOL_SOCKET);
 use POSIX qw(mkfifo);
-require './t/common.perl';
+use PublicInbox::TestCommon;
 my ($tmpdir, $for_destroy) = tmpdir();
 my $fifo = "$tmpdir/fifo";
 ok(defined mkfifo($fifo, 0777), 'created FIFO');
diff --git a/t/httpd-https.t b/t/httpd-https.t
index de74c20e..1d2e4d5c 100644
--- a/t/httpd-https.t
+++ b/t/httpd-https.t
@@ -17,7 +17,7 @@ unless (-r $key && -r $cert) {
 }
 use_ok 'PublicInbox::TLS';
 use_ok 'IO::Socket::SSL';
-require './t/common.perl';
+use PublicInbox::TestCommon;
 my $psgi = "./t/httpd-corner.psgi";
 my ($tmpdir, $for_destroy) = tmpdir();
 my $err = "$tmpdir/stderr.log";
diff --git a/t/httpd-unix.t b/t/httpd-unix.t
index 2c8f8d6b..bd4ee12e 100644
--- a/t/httpd-unix.t
+++ b/t/httpd-unix.t
@@ -4,7 +4,7 @@
 use strict;
 use warnings;
 use Test::More;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 use Errno qw(EADDRINUSE);
 
 foreach my $mod (qw(Plack::Util Plack::Builder HTTP::Date HTTP::Status)) {
diff --git a/t/httpd.t b/t/httpd.t
index f0b4efb4..517329fb 100644
--- a/t/httpd.t
+++ b/t/httpd.t
@@ -9,7 +9,7 @@ foreach my $mod (qw(Plack::Util Plack::Builder HTTP::Date HTTP::Status)) {
 	plan skip_all => "$mod missing for httpd.t" if $@;
 }
 use Socket qw(IPPROTO_TCP SOL_SOCKET);
-require './t/common.perl';
+use PublicInbox::TestCommon;
 
 # FIXME: too much setup
 my ($tmpdir, $for_destroy) = tmpdir();
diff --git a/t/import.t b/t/import.t
index 2f5b08a5..3cf7e2d2 100644
--- a/t/import.t
+++ b/t/import.t
@@ -10,7 +10,7 @@ use PublicInbox::Spawn qw(spawn);
 use IO::File;
 use Fcntl qw(:DEFAULT);
 use File::Temp qw/tempfile/;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 my ($dir, $for_destroy) = tmpdir();
 
 is(system(qw(git init -q --bare), $dir), 0, 'git init successful');
diff --git a/t/indexlevels-mirror.t b/t/indexlevels-mirror.t
index aae42510..876abd2c 100644
--- a/t/indexlevels-mirror.t
+++ b/t/indexlevels-mirror.t
@@ -7,7 +7,7 @@ use PublicInbox::MIME;
 use PublicInbox::Inbox;
 use PublicInbox::InboxWritable;
 require PublicInbox::Admin;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 my $PI_TEST_VERSION = $ENV{PI_TEST_VERSION} || 2;
 require_git('2.6') if $PI_TEST_VERSION == 2;
 
diff --git a/t/init.t b/t/init.t
index 16550868..f70d1c20 100644
--- a/t/init.t
+++ b/t/init.t
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 use Test::More;
 use PublicInbox::Config;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 use File::Basename;
 my ($tmpdir, $for_destroy) = tmpdir();
 sub quiet_fail {
diff --git a/t/mda.t b/t/mda.t
index 3686a97b..4556e323 100644
--- a/t/mda.t
+++ b/t/mda.t
@@ -7,7 +7,7 @@ use Email::MIME;
 use Cwd qw(getcwd);
 use PublicInbox::MID qw(mid2path);
 use PublicInbox::Git;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 my ($tmpdir, $for_destroy) = tmpdir();
 my $home = "$tmpdir/pi-home";
 my $pi_home = "$home/.public-inbox";
diff --git a/t/mda_filter_rubylang.t b/t/mda_filter_rubylang.t
index ce17d5a9..a5b6af3c 100644
--- a/t/mda_filter_rubylang.t
+++ b/t/mda_filter_rubylang.t
@@ -5,7 +5,7 @@ use warnings;
 use Test::More;
 use PublicInbox::MIME;
 use PublicInbox::Config;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 require_git(2.6);
 my @mods = qw(DBD::SQLite Search::Xapian);
 foreach my $mod (@mods) {
diff --git a/t/msgmap.t b/t/msgmap.t
index 7fcd131a..6edeed56 100644
--- a/t/msgmap.t
+++ b/t/msgmap.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 
 foreach my $mod (qw(DBD::SQLite)) {
 	eval "require $mod";
diff --git a/t/nntpd-tls.t b/t/nntpd-tls.t
index c6dceaaa..25b7bd1c 100644
--- a/t/nntpd-tls.t
+++ b/t/nntpd-tls.t
@@ -24,7 +24,7 @@ unless (-r $key && -r $cert) {
 
 use_ok 'PublicInbox::TLS';
 use_ok 'IO::Socket::SSL';
-require './t/common.perl';
+use PublicInbox::TestCommon;
 require PublicInbox::InboxWritable;
 require PublicInbox::MIME;
 require PublicInbox::SearchIdx;
diff --git a/t/nntpd.t b/t/nntpd.t
index 5b697344..30f3fb9c 100644
--- a/t/nntpd.t
+++ b/t/nntpd.t
@@ -15,7 +15,7 @@ use IO::Socket;
 use Socket qw(IPPROTO_TCP TCP_NODELAY);
 use Net::NNTP;
 use Sys::Hostname;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 
 # FIXME: make easier to test both versions
 my $version = $ENV{PI_TEST_VERSION} || 2;
diff --git a/t/nulsubject.t b/t/nulsubject.t
index 617997c0..45f95a9e 100644
--- a/t/nulsubject.t
+++ b/t/nulsubject.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 
 use_ok 'PublicInbox::Import';
 use_ok 'PublicInbox::Git';
diff --git a/t/over.t b/t/over.t
index 27168a33..5e33a0b0 100644
--- a/t/over.t
+++ b/t/over.t
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 use Test::More;
 use Compress::Zlib qw(compress);
-require './t/common.perl';
+use PublicInbox::TestCommon;
 foreach my $mod (qw(DBD::SQLite)) {
 	eval "require $mod";
 	plan skip_all => "$mod missing for over.t" if $@;
diff --git a/t/plack.t b/t/plack.t
index 6023a419..c9a2cf79 100644
--- a/t/plack.t
+++ b/t/plack.t
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 use Test::More;
 use Email::MIME;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 my $psgi = "./examples/public-inbox.psgi";
 my ($tmpdir, $for_destroy) = tmpdir();
 my $pi_config = "$tmpdir/config";
diff --git a/t/psgi_attach.t b/t/psgi_attach.t
index 45f05bac..5a7129f9 100644
--- a/t/psgi_attach.t
+++ b/t/psgi_attach.t
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 use Test::More;
 use Email::MIME;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 my ($tmpdir, $for_destroy) = tmpdir();
 my $maindir = "$tmpdir/main.git";
 my $addr = 'test-public@example.com';
diff --git a/t/psgi_bad_mids.t b/t/psgi_bad_mids.t
index 0e8fa114..b22f3652 100644
--- a/t/psgi_bad_mids.t
+++ b/t/psgi_bad_mids.t
@@ -6,7 +6,7 @@ use Test::More;
 use PublicInbox::MIME;
 use PublicInbox::Config;
 use PublicInbox::WWW;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 my @mods = qw(DBD::SQLite HTTP::Request::Common Plack::Test
 		URI::Escape Plack::Builder);
 foreach my $mod (@mods) {
diff --git a/t/psgi_mount.t b/t/psgi_mount.t
index ca573e1e..a2621a2a 100644
--- a/t/psgi_mount.t
+++ b/t/psgi_mount.t
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 use Test::More;
 use Email::MIME;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 my ($tmpdir, $for_destroy) = tmpdir();
 my $maindir = "$tmpdir/main.git";
 my $addr = 'test-public@example.com';
diff --git a/t/psgi_multipart_not.t b/t/psgi_multipart_not.t
index d3489f2d..9384d14a 100644
--- a/t/psgi_multipart_not.t
+++ b/t/psgi_multipart_not.t
@@ -6,7 +6,7 @@ use Test::More;
 use Email::MIME;
 use PublicInbox::Config;
 use PublicInbox::WWW;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 my @mods = qw(DBD::SQLite Search::Xapian HTTP::Request::Common
               Plack::Test URI::Escape Plack::Builder Plack::Test);
 foreach my $mod (@mods) {
diff --git a/t/psgi_scan_all.t b/t/psgi_scan_all.t
index 5d4cc263..fa636d32 100644
--- a/t/psgi_scan_all.t
+++ b/t/psgi_scan_all.t
@@ -5,7 +5,7 @@ use warnings;
 use Test::More;
 use Email::MIME;
 use PublicInbox::Config;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 my @mods = qw(HTTP::Request::Common Plack::Test URI::Escape DBD::SQLite);
 foreach my $mod (@mods) {
 	eval "require $mod";
diff --git a/t/psgi_search.t b/t/psgi_search.t
index 0c430aea..d1050437 100644
--- a/t/psgi_search.t
+++ b/t/psgi_search.t
@@ -9,7 +9,7 @@ use PublicInbox::Inbox;
 use PublicInbox::InboxWritable;
 use PublicInbox::WWW;
 use bytes (); # only for bytes::length
-require './t/common.perl';
+use PublicInbox::TestCommon;
 my @mods = qw(DBD::SQLite Search::Xapian HTTP::Request::Common Plack::Test
 		URI::Escape Plack::Builder);
 foreach my $mod (@mods) {
diff --git a/t/psgi_text.t b/t/psgi_text.t
index b9564181..ee4d9f14 100644
--- a/t/psgi_text.t
+++ b/t/psgi_text.t
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 use Test::More;
 use Email::MIME;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 my ($tmpdir, $for_destroy) = tmpdir();
 my $maindir = "$tmpdir/main.git";
 my $addr = 'test-public@example.com';
diff --git a/t/psgi_v2.t b/t/psgi_v2.t
index 1163e2bf..8e81e89b 100644
--- a/t/psgi_v2.t
+++ b/t/psgi_v2.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 require_git(2.6);
 use PublicInbox::MIME;
 use PublicInbox::Config;
diff --git a/t/purge.t b/t/purge.t
index db09b731..0262f791 100644
--- a/t/purge.t
+++ b/t/purge.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 require_git(2.6);
 my @mods = qw(DBI DBD::SQLite);
 foreach my $mod (@mods) {
diff --git a/t/replace.t b/t/replace.t
index 57290f96..2346c3a1 100644
--- a/t/replace.t
+++ b/t/replace.t
@@ -5,7 +5,7 @@ use warnings;
 use Test::More;
 use PublicInbox::MIME;
 use PublicInbox::InboxWritable;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 use Cwd qw(abs_path);
 require_git(2.6); # replace is v2 only, for now...
 foreach my $mod (qw(DBD::SQLite)) {
diff --git a/t/search-thr-index.t b/t/search-thr-index.t
index 4f793657..47454fe7 100644
--- a/t/search-thr-index.t
+++ b/t/search-thr-index.t
@@ -13,7 +13,7 @@ foreach my $mod (@mods) {
 }
 require PublicInbox::SearchIdx;
 require PublicInbox::Inbox;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 my ($tmpdir, $for_destroy) = tmpdir();
 my $git_dir = "$tmpdir/a.git";
 
diff --git a/t/search.t b/t/search.t
index 58684138..33a7596e 100644
--- a/t/search.t
+++ b/t/search.t
@@ -10,7 +10,7 @@ foreach my $mod (@mods) {
 };
 require PublicInbox::SearchIdx;
 require PublicInbox::Inbox;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 use Email::MIME;
 my ($tmpdir, $for_destroy) = tmpdir();
 my $git_dir = "$tmpdir/a.git";
diff --git a/t/solver_git.t b/t/solver_git.t
index 88f83bdb..99ee9b5e 100644
--- a/t/solver_git.t
+++ b/t/solver_git.t
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 use Test::More;
 use Cwd qw(abs_path);
-require './t/common.perl';
+use PublicInbox::TestCommon;
 require_git(2.6);
 use PublicInbox::Spawn qw(spawn);
 
diff --git a/t/spamcheck_spamc.t b/t/spamcheck_spamc.t
index a4a01a8b..92b4fd40 100644
--- a/t/spamcheck_spamc.t
+++ b/t/spamcheck_spamc.t
@@ -6,7 +6,7 @@ use Test::More;
 use Email::Simple;
 use IO::File;
 use Fcntl qw(:DEFAULT SEEK_SET);
-require './t/common.perl';
+use PublicInbox::TestCommon;
 my ($tmpdir, $for_destroy) = tmpdir();
 
 use_ok 'PublicInbox::Spamcheck::Spamc';
diff --git a/t/v1-add-remove-add.t b/t/v1-add-remove-add.t
index 13e9f29c..aabb2fa5 100644
--- a/t/v1-add-remove-add.t
+++ b/t/v1-add-remove-add.t
@@ -5,7 +5,7 @@ use warnings;
 use Test::More;
 use PublicInbox::MIME;
 use PublicInbox::Import;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 
 foreach my $mod (qw(DBD::SQLite Search::Xapian)) {
 	eval "require $mod";
diff --git a/t/v1reindex.t b/t/v1reindex.t
index c0e21a56..321b3b21 100644
--- a/t/v1reindex.t
+++ b/t/v1reindex.t
@@ -6,7 +6,7 @@ use Test::More;
 use PublicInbox::MIME;
 use PublicInbox::ContentId qw(content_digest);
 use File::Path qw(remove_tree);
-require './t/common.perl';
+use PublicInbox::TestCommon;
 require_git(2.6);
 
 foreach my $mod (qw(DBD::SQLite Search::Xapian)) {
diff --git a/t/v2-add-remove-add.t b/t/v2-add-remove-add.t
index c0dec300..7cce2493 100644
--- a/t/v2-add-remove-add.t
+++ b/t/v2-add-remove-add.t
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 use Test::More;
 use PublicInbox::MIME;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 require_git(2.6);
 
 foreach my $mod (qw(DBD::SQLite Search::Xapian)) {
diff --git a/t/v2mda.t b/t/v2mda.t
index 11a517e4..4b1249ea 100644
--- a/t/v2mda.t
+++ b/t/v2mda.t
@@ -6,7 +6,7 @@ use Test::More;
 use PublicInbox::MIME;
 use Fcntl qw(SEEK_SET);
 use Cwd;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 require_git(2.6);
 
 my $V = 2;
diff --git a/t/v2mirror.t b/t/v2mirror.t
index 213a5f15..e3c384fa 100644
--- a/t/v2mirror.t
+++ b/t/v2mirror.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 use Cwd qw(abs_path);
 require_git(2.6);
 local $ENV{HOME} = abs_path('t');
diff --git a/t/v2reindex.t b/t/v2reindex.t
index e222d0f1..a14bf798 100644
--- a/t/v2reindex.t
+++ b/t/v2reindex.t
@@ -6,7 +6,7 @@ use Test::More;
 use PublicInbox::MIME;
 use PublicInbox::ContentId qw(content_digest);
 use File::Path qw(remove_tree);
-require './t/common.perl';
+use PublicInbox::TestCommon;
 require_git(2.6);
 
 foreach my $mod (qw(DBD::SQLite Search::Xapian)) {
diff --git a/t/v2writable.t b/t/v2writable.t
index 8bbcd45a..bf2064d0 100644
--- a/t/v2writable.t
+++ b/t/v2writable.t
@@ -5,7 +5,7 @@ use warnings;
 use Test::More;
 use PublicInbox::MIME;
 use PublicInbox::ContentId qw(content_digest);
-require './t/common.perl';
+use PublicInbox::TestCommon;
 use Cwd qw(abs_path);
 require_git(2.6);
 foreach my $mod (qw(DBD::SQLite Search::Xapian)) {
diff --git a/t/watch_filter_rubylang.t b/t/watch_filter_rubylang.t
index c4078879..0ea680ee 100644
--- a/t/watch_filter_rubylang.t
+++ b/t/watch_filter_rubylang.t
@@ -2,7 +2,7 @@
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict;
 use warnings;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 use Test::More;
 use PublicInbox::MIME;
 use PublicInbox::Config;
diff --git a/t/watch_maildir.t b/t/watch_maildir.t
index d2e6fecd..38297043 100644
--- a/t/watch_maildir.t
+++ b/t/watch_maildir.t
@@ -5,7 +5,7 @@ use Test::More;
 use Email::MIME;
 use Cwd;
 use PublicInbox::Config;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 my @mods = qw(Filesys::Notify::Simple);
 foreach my $mod (@mods) {
 	eval "require $mod";
diff --git a/t/watch_maildir_v2.t b/t/watch_maildir_v2.t
index 53f1bdfc..77e4b981 100644
--- a/t/watch_maildir_v2.t
+++ b/t/watch_maildir_v2.t
@@ -5,7 +5,7 @@ use Test::More;
 use PublicInbox::MIME;
 use Cwd;
 use PublicInbox::Config;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 require_git(2.6);
 my @mods = qw(Search::Xapian DBD::SQLite Filesys::Notify::Simple);
 foreach my $mod (@mods) {
diff --git a/t/www_listing.t b/t/www_listing.t
index e1263360..75698ee5 100644
--- a/t/www_listing.t
+++ b/t/www_listing.t
@@ -5,7 +5,7 @@ use strict;
 use warnings;
 use Test::More;
 use PublicInbox::Spawn qw(which);
-require './t/common.perl';
+use PublicInbox::TestCommon;
 my @mods = qw(URI::Escape Plack::Builder Digest::SHA
 		IO::Compress::Gzip IO::Uncompress::Gunzip HTTP::Tiny);
 foreach my $mod (@mods) {
diff --git a/t/xcpdb-reshard.t b/t/xcpdb-reshard.t
index a4ab35d6..0d78d2b2 100644
--- a/t/xcpdb-reshard.t
+++ b/t/xcpdb-reshard.t
@@ -8,7 +8,7 @@ foreach my $mod (@mods) {
 	eval "require $mod";
 	plan skip_all => "missing $mod for $0" if $@;
 };
-require './t/common.perl';
+use PublicInbox::TestCommon;
 require_git('2.6');
 use PublicInbox::MIME;
 use PublicInbox::InboxWritable;
diff --git a/xt/git-http-backend.t b/xt/git-http-backend.t
index a927d89e..5f96369f 100644
--- a/xt/git-http-backend.t
+++ b/xt/git-http-backend.t
@@ -7,7 +7,7 @@ use strict;
 use warnings;
 use Test::More;
 use POSIX qw(setsid);
-require './t/common.perl';
+use PublicInbox::TestCommon;
 
 my $git_dir = $ENV{GIANT_GIT_DIR};
 plan 'skip_all' => 'GIANT_GIT_DIR not defined' unless $git_dir;
diff --git a/xt/nntpd-validate.t b/xt/nntpd-validate.t
index 39108639..c82d46e2 100644
--- a/xt/nntpd-validate.t
+++ b/xt/nntpd-validate.t
@@ -29,7 +29,7 @@ my $key = 'certs/server-key.pem';
 if ($test_tls && !-r $key || !-r $cert) {
 	plan skip_all => "certs/ missing for $0, run $^X ./certs/create-certs.perl";
 }
-require './t/common.perl';
+use PublicInbox::TestCommon;
 my ($tmpdir, $ftd) = tmpdir();
 $File::Temp::KEEP_ALL = !!$ENV{TEST_KEEP_TMP};
 my (%OPT, $td, $host_port, $group);
diff --git a/xt/perf-msgview.t b/xt/perf-msgview.t
index 22d8ce20..11bd3a5d 100644
--- a/xt/perf-msgview.t
+++ b/xt/perf-msgview.t
@@ -6,7 +6,7 @@ use Test::More;
 use Benchmark qw(:all);
 use PublicInbox::Inbox;
 use PublicInbox::View;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 
 my $inboxdir = $ENV{GIANT_INBOX_DIR} // $ENV{GIANT_PI_DIR};
 plan skip_all => "GIANT_INBOX_DIR not defined for $0" unless $inboxdir;
diff --git a/xt/perf-nntpd.t b/xt/perf-nntpd.t
index 5a176e08..df5ecb41 100644
--- a/xt/perf-nntpd.t
+++ b/xt/perf-nntpd.t
@@ -10,7 +10,7 @@ my $inboxdir = $ENV{GIANT_INBOX_DIR} // $ENV{GIANT_PI_DIR};
 plan skip_all => "GIANT_INBOX_DIR not defined for $0" unless defined($inboxdir);
 eval { require PublicInbox::Search };
 my ($host_port, $group, %opts, $s, $td, $tmp_obj);
-require './t/common.perl';
+use PublicInbox::TestCommon;
 
 if (($ENV{NNTP_TEST_URL} || '') =~ m!\Anntp://([^/]+)/([^/]+)\z!) {
 	($host_port, $group) = ($1, $2);

^ permalink raw reply	[relevance 2%]

* [PATCH 0/6] test updates and speedups
@ 2019-12-18  3:36  4% Eric Wong
  2019-12-18  3:36  2% ` [PATCH 5/6] tests: move t/common.perl to PublicInbox::TestCommon Eric Wong
  0 siblings, 1 reply; 3+ results
From: Eric Wong @ 2019-12-18  3:36 UTC (permalink / raw)
  To: meta

Tests are now faster with the "make check-run" target by
avoiding Perl startup time for each *.t file.

"make check-run" is nearly 3x faster than "make check"
under 1.2.0 due to the dozens of internal improvements
and cleanups since 1.2.0.

I've also beefed up the "solver" tests to cover the ViewVCS
PSGI frontend, more work there on the horizon...

Eric Wong (6):
  TODO: add UUCP address item
  viewvcs: flesh out some functionality and test
  Makefile.PL: sort target and var lists
  t/*.t: avoid sharing "my" variables in subs
  tests: move t/common.perl to PublicInbox::TestCommon
  t/run.perl: to avoid repeated process spawning for *.t

 .gitignore                                    |   1 +
 MANIFEST                                      |   3 +-
 Makefile.PL                                   |  20 +-
 TODO                                          |   2 +
 .../PublicInbox/TestCommon.pm                 |  28 ++-
 lib/PublicInbox/ViewVCS.pm                    |   8 +-
 t/admin.t                                     |   2 +-
 t/altid.t                                     |   2 +-
 t/altid_v2.t                                  |   2 +-
 t/cgi.t                                       |   2 +-
 t/config.t                                    |   2 +-
 t/convert-compact.t                           |   2 +-
 t/edit.t                                      |   2 +-
 t/emergency.t                                 |   2 +-
 t/feed.t                                      |   2 +-
 t/filter_rubylang.t                           |   2 +-
 t/git.t                                       |   2 +-
 t/html_index.t                                |   2 +-
 t/httpd-corner.t                              |  10 +-
 t/httpd-https.t                               |   2 +-
 t/httpd-unix.t                                |   2 +-
 t/httpd.t                                     |   2 +-
 t/import.t                                    |   2 +-
 t/indexlevels-mirror.t                        |  12 +-
 t/init.t                                      |   2 +-
 t/mda.t                                       |  48 ++---
 t/mda_filter_rubylang.t                       |   2 +-
 t/msgmap.t                                    |   2 +-
 t/nntpd-tls.t                                 |   4 +-
 t/nntpd.t                                     |   5 +-
 t/nulsubject.t                                |   2 +-
 t/over.t                                      |   2 +-
 t/plack.t                                     |   2 +-
 t/psgi_attach.t                               |   2 +-
 t/psgi_bad_mids.t                             |   2 +-
 t/psgi_mount.t                                |   2 +-
 t/psgi_multipart_not.t                        |   2 +-
 t/psgi_scan_all.t                             |   2 +-
 t/psgi_search.t                               |   2 +-
 t/psgi_text.t                                 |   2 +-
 t/psgi_v2.t                                   |   2 +-
 t/purge.t                                     |   2 +-
 t/replace.t                                   |   2 +-
 t/run.perl                                    | 182 ++++++++++++++++++
 t/search-thr-index.t                          |   2 +-
 t/search.t                                    |   2 +-
 t/solver_git.t                                |  86 ++++++++-
 t/spamcheck_spamc.t                           |   2 +-
 t/v1-add-remove-add.t                         |   2 +-
 t/v1reindex.t                                 |   2 +-
 t/v2-add-remove-add.t                         |   2 +-
 t/v2mda.t                                     |   2 +-
 t/v2mirror.t                                  |  12 +-
 t/v2reindex.t                                 |   2 +-
 t/v2writable.t                                |   2 +-
 t/view.t                                      |  12 +-
 t/watch_filter_rubylang.t                     |   2 +-
 t/watch_maildir.t                             |   2 +-
 t/watch_maildir_v2.t                          |   2 +-
 t/www_listing.t                               |   6 +-
 t/xcpdb-reshard.t                             |   2 +-
 xt/git-http-backend.t                         |   2 +-
 xt/nntpd-validate.t                           |   2 +-
 xt/perf-msgview.t                             |   2 +-
 xt/perf-nntpd.t                               |   2 +-
 65 files changed, 404 insertions(+), 133 deletions(-)
 rename t/common.perl => lib/PublicInbox/TestCommon.pm (90%)
 create mode 100755 t/run.perl


^ permalink raw reply	[relevance 4%]

Results 1-3 of 3 | reverse | sort options + mbox downloads above
-- links below jump to the message on this page --
2019-12-18  3:36  4% [PATCH 0/6] test updates and speedups Eric Wong
2019-12-18  3:36  2% ` [PATCH 5/6] tests: move t/common.perl to PublicInbox::TestCommon Eric Wong
2019-12-19  4:02  7%   ` Eric Wong

Code repositories for project(s) associated with this 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).