+my $cfgpath = "$inboxdir/$$.config";
+SKIP: {
+ require_mods(qw(Plack::Test::ExternalServer), 1);
+ open my $fh, '>', $cfgpath or BAIL_OUT $!;
+ print $fh <<EOF or BAIL_OUT $!;
+[publicinbox "v2test"]
+ inboxdir = $inboxdir
+ address = test\@example.com
+EOF
+ close $fh or BAIL_OUT $!;
+}
+
+my $run_httpd = sub {
+ my ($client, $skip) = @_;
+ SKIP: {
+ require_mods(qw(Plack::Test::ExternalServer), $skip);
+ my $env = { PI_CONFIG => $cfgpath };
+ my $sock = tcp_server() or die;
+ my ($out, $err) = map { "$inboxdir/std$_.log" } qw(out err);
+ my $cmd = [ qw(-httpd -W0), "--stdout=$out", "--stderr=$err" ];
+ my $td = start_script($cmd, $env, { 3 => $sock });
+ my ($h, $p) = ($sock->sockhost, $sock->sockport);
+ local $ENV{PLACK_TEST_EXTERNALSERVER_URI} = "http://$h:$p";
+ Plack::Test::ExternalServer::test_psgi(client => $client);
+ $td->join('TERM');
+ open my $fh, '<', $err or BAIL_OUT $!;
+ is(do { local $/; <$fh> }, '', 'no errors');
+ }
+};
+