MANIFEST | 2 +- t/admin.t | 2 +- t/altid.t | 2 +- t/altid_v2.t | 2 +- t/cgi.t | 2 +- t/common.perl => lib/PublicInbox/TestCommon.pm | 18 +++++++++++------- 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 +- diff --git a/MANIFEST b/MANIFEST index 3a301ee7226671ea6f701956f04912fd28559a51..6bff79adb40b7df406830c4ce8c87b6056d1efba 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/admin.t b/t/admin.t index 6458982bd662dccee6b241f86996f42b37d3d8fe..b517d2f897ecd4b96ba7309fe39cfed219c9b078 100644 --- a/t/admin.t +++ b/t/admin.t @@ -3,7 +3,7 @@ # License: AGPL-3.0+ 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 86e7f9dec30b442327cede6f9eb1a99c3362eb52..fc5bcbc2349a09852a0003f962ebaf00a9e4e6d2 100644 --- a/t/altid.t +++ b/t/altid.t @@ -3,7 +3,7 @@ # License: AGPL-3.0+ 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 9e152fc485ea8ea4a7b3431f20e029c6faee5e94..5bd62e136e7730c1f681150e3a4977bc2deee2eb 100644 --- a/t/altid_v2.t +++ b/t/altid_v2.t @@ -3,7 +3,7 @@ # License: AGPL-3.0+ 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 62cea49967d7fe0f9866eac0b15a803e929e614e..424b738e2c4c68aceaa7a97f42ecc07d86871358 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/common.perl b/lib/PublicInbox/TestCommon.pm rename from t/common.perl rename to lib/PublicInbox/TestCommon.pm index 288a0a1928b6c62f34aa1c15f37f023f6508c0fc..45306a5a7f56722891fea6be5e91fec82b8a902c 100644 --- a/t/common.perl +++ b/lib/PublicInbox/TestCommon.pm @@ -1,11 +1,15 @@ # Copyright (C) 2015-2019 all contributors # License: AGPL-3.0+ +# 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 @@ my $req_int = ($req_maj << 24) | ($req_min << 16); 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 @@ exec(key2script($key), @argv); 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 @@ -275,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; diff --git a/t/config.t b/t/config.t index ade2e796abe9f4209b3b30a1897512a5f7fb3c2d..db3f9b2aa5ec6c6873ce7c7953db58a06e838ab8 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 b8dc5ed515e844dd488e9405edeea6c95f00e4f5..c6da64eaa69daf0ab0bf9f3b1c1ce654c2b06ea4 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 122aa19f0b745d6d1dcd50632b57f718300553b8..9a78b45d3d95c9adef49f4817f914c7b112d7554 100644 --- a/t/edit.t +++ b/t/edit.t @@ -4,7 +4,7 @@ # edit frontend behavior test (t/replace.t for backend) 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 d6c7b6d588b1eac2d3e87c244c20f02a7bc3fe19..1cb1098d40bf73a730c8904849cc9505e7defdee 100644 --- a/t/emergency.t +++ b/t/emergency.t @@ -3,7 +3,7 @@ # License: AGPL-3.0+ 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 daf97a7253a5b37afa3e8fc3019213cb78aaf910..97468c730f0dc242cf06484cecb72adc70c1cdef 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 337539254fd841b166cff1be73d6ef71c108c39c..576cbdeb61883fc5b2439c01aaf019a80f9909d4 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 cc4fc59146c73b6c6171ce2ec1791321e1c253e0..d4694f44c2d98393458a856c7b7dabe502c9acdf 100644 --- a/t/git.t +++ b/t/git.t @@ -3,7 +3,7 @@ # License: AGPL-3.0+ 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 51ea9a25fb4ed6bb876154b80b416ea43d55a33f..55aa6dc7f3a034fd4f8f70a9dccc262621853e22 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 a8cdb2e97ae8d43c40557a81eda97f4b46797d8f..fb3ffcf1fba6abaadd38ca95ea754a8c2e56d947 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 de74c20ee331e3b61cfc0db6da4100f5d068e97e..1d2e4d5c25e0aa51da150d5985808b9277865c1c 100644 --- a/t/httpd-https.t +++ b/t/httpd-https.t @@ -17,7 +17,7 @@ "certs/ missing for $0, run $^X ./create-certs.perl in certs/"; } 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 2c8f8d6b2a6b0457a02cd0e83e7188b7faa5c6a5..bd4ee12eeb6869101763f9bef05eaa54d49facab 100644 --- a/t/httpd-unix.t +++ b/t/httpd-unix.t @@ -4,7 +4,7 @@ # Tests for binding Unix domain sockets 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 f0b4efb41a525dc7afb902f21f20be78cdcb3ff0..517329fbc5a37db2863479a6f46975c3c17a143a 100644 --- a/t/httpd.t +++ b/t/httpd.t @@ -9,7 +9,7 @@ eval "require $mod"; 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 2f5b08a522fb64f67cb67ffc80ffcf2c368c1560..3cf7e2d2e4ea4e1e6168c7caae797ba945645785 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 aae42510491d2d9759ce2fda2c58c0e1f5cfe9de..876abd2c133edfacf6c6989a06f290c2e66c5499 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 165508683690cd5b717b360baec8e14fc625a788..f70d1c2036f9d5ab2776764efa04d109d5e588eb 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 3686a97bbe42977b23cbbba428ec16f830cc8fdf..4556e3234e9c7adfc6682aa7cff6bde9ba8f7563 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 ce17d5a96ee29f7291690f7a42f2e6844d3625a5..a5b6af3c011ded71d540b4451de762de24a53e48 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 7fcd131afd8889d866844b74180b7821ec093fd5..6edeed5645fcef62dcaa92a991e2861dc72df990 100644 --- a/t/msgmap.t +++ b/t/msgmap.t @@ -3,7 +3,7 @@ # License: AGPL-3.0+ 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 c6dceaaa660793b8f6ce67fa1b8f57cd081f26fc..25b7bd1c0913d7bf91a6b41167ca862b9041a6b2 100644 --- a/t/nntpd-tls.t +++ b/t/nntpd-tls.t @@ -24,7 +24,7 @@ } 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 5b697344952f5f9889113de6afaccf7e5d644074..30f3fb9c761863b20760b0557c590b87e1ea480a 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 617997c02308e397ef6be97a2344bc9b9de2ca4d..45f95a9e5f97485a691278c8d2ae5444f2deee44 100644 --- a/t/nulsubject.t +++ b/t/nulsubject.t @@ -3,7 +3,7 @@ # License: AGPL-3.0+ 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 27168a33d49ed7156254b8b9faedf321c5f1ed81..5e33a0b0dc20aa5cc097923da91fc1d72f2b60aa 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 6023a419d0716ad169a670ee1451f9d1fbd33acb..c9a2cf79521fbedf35befa20002778c100f69f79 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 45f05bacd404f2017921017f80c31b07a828d3c1..5a7129f91ba35bc38f7299c663a2e5c0d4f88300 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 0e8fa114ac0bfcc131ebdacf6dc535545382927a..b22f36523fa75cb70de42dca267191307ee52f03 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 ca573e1e633d3da60e722b9acf82c2f6133f32e4..a2621a2ad3a1931e280d01a7436d4b69d8743c6a 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 d3489f2d8ff5228677759d031588bd303f1fdfde..9384d14a29ecf1ff630f4dd2813048b836965422 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 5d4cc263a093dabd9b86d7780f96210562c8bb83..fa636d324cbfd8888f99e7649d8495adfad6d0a5 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 0c430aeafd8bce6fcec2cfeaf2e2c302496de800..d1050437b232cc5e70f03c7072f37671e46af99c 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 b956418165dbbb393631f9353f3f654fce07dc1c..ee4d9f1478076df0b9c14195988a4ca550f8d5ed 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 1163e2bf89f73c9bd400b23f5fbe2d275086ce94..8e81e89b4b71e4328268051c7a558e7b368aafd8 100644 --- a/t/psgi_v2.t +++ b/t/psgi_v2.t @@ -3,7 +3,7 @@ # License: AGPL-3.0+ 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 db09b731f9cf871d717f6088e7240386c100975a..0262f79153db1c5ac97edce4b61562e787b0cc4f 100644 --- a/t/purge.t +++ b/t/purge.t @@ -3,7 +3,7 @@ # License: AGPL-3.0+ 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 57290f96edccef4e17db2be2b93a74dfb9e74058..2346c3a19d1103cbee1d00f4f5d1512bebd51c84 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 4f7936579776b11d5401708c04d1049b5ca165f6..47454fe7c868af566fed10048b35c9bd4049416a 100644 --- a/t/search-thr-index.t +++ b/t/search-thr-index.t @@ -13,7 +13,7 @@ plan skip_all => "missing $mod for $0" if $@; } 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 586841383c479478d6974564b899116aaa9a40de..33a7596e625c681f21364c18443a2dad283bc1f3 100644 --- a/t/search.t +++ b/t/search.t @@ -10,7 +10,7 @@ plan skip_all => "missing $mod for $0" if $@; }; 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 88f83bdb7ae28525b75c7e97bb3a374817930dc2..99ee9b5ea2337ed0bfd73788ed63c269de003e71 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 a4a01a8b98ce929cfca434fa3b6cda84b68a2a65..92b4fd409d801d56a612c22b52a737f60e4078ab 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 13e9f29ce95eb68b900e1aa044605e62f67a3180..aabb2fa53ef648b3e08fddd62836f3ca77c82247 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 c0e21a56b6ce7a8aca36ffbf12e6d9b5eaa7b390..321b3b21e7b47eb7510491bf212afc871265abb4 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 c0dec30045b821d92b4aa9933a54c4d0e01581de..7cce249376ea1a5a320af59d0de3b38c98de4398 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 11a517e4bd677fd13bc79032a32adea1954d2884..4b1249ea14f0bc00e45fc78e273637a11e7e7ef3 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 213a5f1534d47e139840bf75920a93a9a7bfdb15..e3c384fa77a1f546741e153a59492d2d96b49c20 100644 --- a/t/v2mirror.t +++ b/t/v2mirror.t @@ -3,7 +3,7 @@ # License: AGPL-3.0+ 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 e222d0f101a4e71ad11622bf199d99aa45662bc7..a14bf798d6f6c67a8e92532ba0d26460c63a7354 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 8bbcd45aad808e3701953bf7e5e7057173cd7185..bf2064d0055905525f1645cca4c832bbe94b5630 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 c407887953795176f2bf80f20db86d718b43f96f..0ea680eef853cdecbde0b40b7c09e6006becd666 100644 --- a/t/watch_filter_rubylang.t +++ b/t/watch_filter_rubylang.t @@ -2,7 +2,7 @@ # Copyright (C) 2019 all contributors # License: AGPL-3.0+ 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 d2e6fecdd095d1bbbf3fd52d0312983c7eba7164..38297043d9b7199d9fde8a6baa85fed5a00fdfa6 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 53f1bdfc8128c1effa29ae812ce104f7ecac0871..77e4b981f83515dbd4e107fc1029aac8fac97159 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 e1263360c68f1d21d2ad325dfbaa6bc033881e9a..75698ee53c2ee744f37175d361aa28c6db5e32a7 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 a4ab35d6c7a10f386f36c1830564a93e6d55dca4..0d78d2b200b3e58136a9d5e997f4de788c114f42 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 a927d89ee272b63a22b4eb937e67479b58d0694e..5f96369f0f02adf21b40289d8d7aaaa88b906efc 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 39108639ab9edfe793c5b9de7d7546c926544299..c82d46e27ef156a1499aaadee3ef406655e83dcb 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 22d8ce209fd01de79792fb0d89c86e478fd3117b..11bd3a5d64657ff8d476e1273fd38d5f71490265 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 5a176e08eeb01960b4fbfeba74900e8a6da69137..df5ecb412a14e00592ca8ac0ca8598182ea00878 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);