From 62f28026e624ed30d620063a0fa92cbedb7f6673 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 10 Jan 2020 08:49:31 +0000 Subject: make Plack optional for non-WWW and non-httpd users Some users just want to run -mda, -watch, and/or -nntpd. Let them run just those without forcing them to pull in a bunch of dependencies. --- t/cgi.t | 1 + t/httpd-https.t | 2 +- t/psgi_attach.t | 6 ++---- t/psgi_bad_mids.t | 4 ++-- t/psgi_mount.t | 17 ++++++++--------- t/psgi_multipart_not.t | 2 +- t/psgi_search.t | 2 +- t/psgi_text.t | 5 ++--- t/psgi_v2.t | 2 +- t/solver_git.t | 2 +- t/view.t | 3 ++- 11 files changed, 22 insertions(+), 24 deletions(-) (limited to 't') diff --git a/t/cgi.t b/t/cgi.t index 9f67d5c0..5760596c 100644 --- a/t/cgi.t +++ b/t/cgi.t @@ -7,6 +7,7 @@ use warnings; use Test::More; use Email::MIME; use PublicInbox::TestCommon; +require_mods(qw(Plack::Handler::CGI Plack::Util)); my ($tmpdir, $for_destroy) = tmpdir(); my $home = "$tmpdir/pi-home"; my $pi_home = "$home/.public-inbox"; diff --git a/t/httpd-https.t b/t/httpd-https.t index 265febe5..9ce060c8 100644 --- a/t/httpd-https.t +++ b/t/httpd-https.t @@ -6,7 +6,7 @@ use Test::More; use Socket qw(SOCK_STREAM IPPROTO_TCP SOL_SOCKET); use PublicInbox::TestCommon; # IO::Poll is part of the standard library, but distros may split them off... -require_mods(qw(IO::Socket::SSL IO::Poll)); +require_mods(qw(IO::Socket::SSL IO::Poll Plack::Util)); my $cert = 'certs/server-cert.pem'; my $key = 'certs/server-key.pem'; unless (-r $key && -r $cert) { diff --git a/t/psgi_attach.t b/t/psgi_attach.t index 0c3174bc..1ef5318c 100644 --- a/t/psgi_attach.t +++ b/t/psgi_attach.t @@ -9,15 +9,14 @@ my ($tmpdir, $for_destroy) = tmpdir(); my $maindir = "$tmpdir/main.git"; my $addr = 'test-public@example.com'; my $cfgpfx = "publicinbox.test"; -my @mods = qw(HTTP::Request::Common Plack::Test URI::Escape); +my @mods = qw(HTTP::Request::Common Plack::Builder Plack::Test URI::Escape); require_mods(@mods); use_ok $_ foreach @mods; +use_ok 'PublicInbox::WWW'; use PublicInbox::Import; use PublicInbox::Git; use PublicInbox::Config; -use PublicInbox::WWW; use_ok 'PublicInbox::WwwAttach'; -use Plack::Builder; my $config = PublicInbox::Config->new(\<new($git, 'test', $addr); ok(length($dot_res) >= length($dot), 'dot almost matches'); $res = $cb->(GET('/test/Z%40B/4-any-filename.txt')); is($res->content, $dot_res, 'user-specified filename is OK'); - }); } done_testing(); diff --git a/t/psgi_bad_mids.t b/t/psgi_bad_mids.t index 5cdd249e..b568786d 100644 --- a/t/psgi_bad_mids.t +++ b/t/psgi_bad_mids.t @@ -5,12 +5,12 @@ use warnings; use Test::More; use PublicInbox::MIME; use PublicInbox::Config; -use PublicInbox::WWW; use PublicInbox::TestCommon; my @mods = qw(DBD::SQLite HTTP::Request::Common Plack::Test - URI::Escape Plack::Builder); + URI::Escape Plack::Builder PublicInbox::WWW); require_mods(@mods); use_ok($_) for @mods; +use_ok 'PublicInbox::WWW'; use_ok 'PublicInbox::V2Writable'; my ($inboxdir, $for_destroy) = tmpdir(); my $cfgpfx = "publicinbox.bad-mids"; diff --git a/t/psgi_mount.t b/t/psgi_mount.t index 751c13b7..d29df054 100644 --- a/t/psgi_mount.t +++ b/t/psgi_mount.t @@ -9,15 +9,14 @@ my ($tmpdir, $for_destroy) = tmpdir(); my $maindir = "$tmpdir/main.git"; my $addr = 'test-public@example.com'; my $cfgpfx = "publicinbox.test"; -my @mods = qw(HTTP::Request::Common Plack::Test URI::Escape); +my @mods = qw(HTTP::Request::Common Plack::Test URI::Escape + Plack::Builder Plack::App::URLMap); require_mods(@mods); use_ok $_ foreach @mods; +use_ok 'PublicInbox::WWW'; use PublicInbox::Import; use PublicInbox::Git; use PublicInbox::Config; -use PublicInbox::WWW; -use Plack::Builder; -use Plack::App::URLMap; my $config = PublicInbox::Config->new(\<new($config); -my $app = builder { - enable 'Head'; - mount '/a' => builder { sub { $www->call(@_) } }; - mount '/b' => builder { sub { $www->call(@_) } }; -}; +my $app = builder(sub { + enable('Head'); + mount('/a' => builder(sub { sub { $www->call(@_) } })); + mount('/b' => builder(sub { sub { $www->call(@_) } })); +}); test_psgi($app, sub { my ($cb) = @_; diff --git a/t/psgi_multipart_not.t b/t/psgi_multipart_not.t index 606151c4..47a691f6 100644 --- a/t/psgi_multipart_not.t +++ b/t/psgi_multipart_not.t @@ -5,12 +5,12 @@ use warnings; use Test::More; use Email::MIME; use PublicInbox::Config; -use PublicInbox::WWW; use PublicInbox::TestCommon; my @mods = qw(DBD::SQLite Search::Xapian HTTP::Request::Common Plack::Test URI::Escape Plack::Builder Plack::Test); require_mods(@mods); use_ok($_) for (qw(HTTP::Request::Common Plack::Test)); +use_ok 'PublicInbox::WWW'; use_ok 'PublicInbox::V2Writable'; my ($repo, $for_destroy) = tmpdir(); my $ibx = PublicInbox::Inbox->new({ diff --git a/t/psgi_search.t b/t/psgi_search.t index 534063f8..5310e5ab 100644 --- a/t/psgi_search.t +++ b/t/psgi_search.t @@ -7,13 +7,13 @@ use Email::MIME; use PublicInbox::Config; use PublicInbox::Inbox; use PublicInbox::InboxWritable; -use PublicInbox::WWW; use bytes (); # only for bytes::length use PublicInbox::TestCommon; my @mods = qw(DBD::SQLite Search::Xapian HTTP::Request::Common Plack::Test URI::Escape Plack::Builder); require_mods(@mods); use_ok($_) for (qw(HTTP::Request::Common Plack::Test)); +use_ok 'PublicInbox::WWW'; my ($tmpdir, $for_destroy) = tmpdir(); my $ibx = PublicInbox::Inbox->new({ diff --git a/t/psgi_text.t b/t/psgi_text.t index 757a1294..7cb7a165 100644 --- a/t/psgi_text.t +++ b/t/psgi_text.t @@ -9,15 +9,14 @@ my ($tmpdir, $for_destroy) = tmpdir(); my $maindir = "$tmpdir/main.git"; my $addr = 'test-public@example.com'; my $cfgpfx = "publicinbox.test"; -my @mods = qw(HTTP::Request::Common Plack::Test URI::Escape); +my @mods = qw(HTTP::Request::Common Plack::Test URI::Escape Plack::Builder); require_mods(@mods); use_ok $_ foreach @mods; use PublicInbox::Import; use PublicInbox::Git; use PublicInbox::Config; -use PublicInbox::WWW; +use_ok 'PublicInbox::WWW'; use_ok 'PublicInbox::WwwText'; -use Plack::Builder; my $config = PublicInbox::Config->new(\</dev/null`); plan skip_all => "$0 must be run from a git working tree" if $?; diff --git a/t/view.t b/t/view.t index 92962b15..38c12fcc 100644 --- a/t/view.t +++ b/t/view.t @@ -3,8 +3,9 @@ use strict; use warnings; use Test::More; +use PublicInbox::TestCommon; use Email::MIME; -use Plack::Util; +require_mods('Plack::Util'); use_ok 'PublicInbox::View'; use_ok 'PublicInbox::Config'; -- cgit v1.2.3-24-ge0c7