2 # Copyright (C) 2020 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
6 use PublicInbox::TestCommon;
7 use PublicInbox::Config; # this relies on PI_CONFIG // ~/.public-inbox/config
8 my @psgi = qw(HTTP::Request::Common Plack::Test URI::Escape Plack::Builder);
9 require_mods(qw(DBD::SQLite Search::Xapian), @psgi);
11 use_ok 'PublicInbox::WWW';
12 my $cfg = PublicInbox::Config->new;
13 my $www = PublicInbox::WWW->new($cfg);
16 $env->{'psgi.errors'} = \*STDERR;
20 # TODO: convert these to self-contained test cases
23 '9e9048b02bd04d287461543d85db0bb715b89f8c'
24 .'/s/?b=t%2Ft3420%2Fremove-ids.sed',
25 'eebf7a8/s/?b=t%2Ftest-lib.sh',
26 'eb580ca513/s/?b=remote-odb.c',
27 '776fa90f7f/s/?b=contrib/git-jump/git-jump',
28 '5cd8845/s/?b=submodule.c',
29 '81c1164ae5/s/?b=builtin/log.c',
30 '6aa8857a11/s/?b=protocol.c',
31 '96f1c7f/s/', # TODO: b=contrib/completion/git-completion.bash
32 'b76f2c0/s/?b=po/zh_CN.po',
36 my ($ibx_name, $urls, @gone);
40 my $url = "/$ibx_name/$_";
41 my $res = $cb->(GET($url));
42 is($res->code, 200, $url);
43 next if $res->code == 200;
50 while (($ibx_name, $urls) = each %$todo) {
52 if (!$cfg->lookup_name($ibx_name)) {
53 push @gone, $ibx_name;
54 skip("$ibx_name not configured", scalar(@$urls));
56 test_psgi($app, $client);
62 require_mods(qw(Plack::Test::ExternalServer), $nr);
65 my $sock = tcp_server() or BAIL_OUT $!;
66 my ($tmpdir, $for_destroy) = tmpdir();
67 my ($out, $err) = map { "$tmpdir/std$_.log" } qw(out err);
68 my $cmd = [ qw(-httpd -W0), "--stdout=$out", "--stderr=$err" ];
69 my $td = start_script($cmd, undef, { 3 => $sock });
70 my ($h, $p) = ($sock->sockhost, $sock->sockport);
72 local $ENV{PLACK_TEST_EXTERNALSERVER_URI} = "http://$h:$p";
73 while (($ibx_name, $urls) = each %$todo) {
74 Plack::Test::ExternalServer::test_psgi(client => $client);