about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-08-26 12:33:31 +0000
committerEric Wong <e@80x24.org>2021-08-28 10:36:58 +0000
commit5c8909925072804901e9c3b45bbf25446d379e7b (patch)
tree32b55b97dc531395284dc9458634c9f5b8c4d5b8 /t
parent26c635060dcae35feae836b02a18a6a11e408312 (diff)
downloadpublic-inbox-5c8909925072804901e9c3b45bbf25446d379e7b.tar.gz
The only place where we could return wide characters with -httpd
was the raw $INBOX_DIR/description text, which is now converted
to octets.

All daemon (HTTP/NNTP/IMAP) sockets are opened in binary mode,
so length() and bytes::length() are equivalent on reads.  For
socket writes, any non-octet data would warn about wide characters
and we are strict in warnings with test_httpd.

All gzipped buffers are also octets, as is PublicInbox::Eml->body,
and anything from PerlIO objects ("git cat-file --batch" output,
filesystems), so bytes::length was unnecessary in all those places.
Diffstat (limited to 't')
-rw-r--r--t/psgi_search.t1
-rw-r--r--t/search-thr-index.t8
-rw-r--r--t/www_listing.t19
3 files changed, 19 insertions, 9 deletions
diff --git a/t/psgi_search.t b/t/psgi_search.t
index 5bdd66ed..3da93eda 100644
--- a/t/psgi_search.t
+++ b/t/psgi_search.t
@@ -8,7 +8,6 @@ use IO::Uncompress::Gunzip qw(gunzip);
 use PublicInbox::Eml;
 use PublicInbox::Config;
 use PublicInbox::Inbox;
-use bytes (); # only for bytes::length
 my @mods = qw(DBD::SQLite Search::Xapian HTTP::Request::Common Plack::Test
                 URI::Escape Plack::Builder);
 require_mods(@mods);
diff --git a/t/search-thr-index.t b/t/search-thr-index.t
index fc1b666a..62745dbc 100644
--- a/t/search-thr-index.t
+++ b/t/search-thr-index.t
@@ -1,8 +1,8 @@
+#!perl -w
 # Copyright (C) 2017-2021 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict;
-use warnings;
-use bytes (); # only for bytes::length
+use v5.10.1;
 use Test::More;
 use PublicInbox::TestCommon;
 use PublicInbox::MID qw(mids);
@@ -45,7 +45,7 @@ foreach (reverse split(/\n\n/, $data)) {
         my $mime = PublicInbox::Eml->new(\$_);
         $mime->header_set('From' => 'bw@g');
         $mime->header_set('To' => 'git@vger.kernel.org');
-        my $bytes = bytes::length($mime->as_string);
+        my $bytes = length($mime->as_string);
         my $mid = mids($mime->header_obj)->[0];
         my $smsg = bless {
                 bytes => $bytes,
@@ -92,7 +92,7 @@ To: git@vger.kernel.org
         my $tid0 = $dbh->selectrow_array(<<'', undef, $num);
 SELECT tid FROM over WHERE num = ? LIMIT 1
 
-        my $bytes = bytes::length($mime->as_string);
+        my $bytes = length($mime->as_string);
         my $mid = mids($mime->header_obj)->[0];
         my $smsg = bless {
                 bytes => $bytes,
diff --git a/t/www_listing.t b/t/www_listing.t
index 6b3b408f..7ea12eea 100644
--- a/t/www_listing.t
+++ b/t/www_listing.t
@@ -55,7 +55,7 @@ sub tiny_test {
         ok(my $clone = $manifest->{'/alt'}, '/alt in manifest');
         is($clone->{owner}, "lorelei \x{100}", 'owner set');
         is($clone->{reference}, '/bare', 'reference detected');
-        is($clone->{description}, "we're all clones", 'description read');
+        is($clone->{description}, "we're \x{100}ll clones", 'description read');
         ok(my $bare = $manifest->{'/bare'}, '/bare in manifest');
         is($bare->{description}, 'Unnamed repository',
                 'missing $GIT_DIR/description fallback');
@@ -72,6 +72,10 @@ sub tiny_test {
         ok(my $v2epoch1 = $manifest->{'/v2/git/1.git'}, 'v2 epoch 1 appeared');
         like($v2epoch1->{description}, qr/ \[epoch 1\]\z/,
                 'epoch 1 in description');
+
+        $res = $http->get("http://$host:$port/alt/description");
+        is($res->{content}, "we're \xc4\x80ll clones\n", 'UTF-8 description')
+                or diag explain($res);
 }
 
 my $td;
@@ -91,9 +95,9 @@ SKIP: {
                 is(xsys(@clone, $alt, "$v2/git/$i.git"), 0, "clone epoch $i")
         }
         ok(open(my $fh, '>', "$v2/inbox.lock"), 'mock a v2 inbox');
-        open $fh, '>', "$alt/description" or die;
-        print $fh "we're all clones\n" or die;
-        close $fh or die;
+        open $fh, '>', "$alt/description" or xbail "open $alt/description $!";
+        print $fh "we're \xc4\x80ll clones\n" or xbail "print $!";
+        close $fh or xbail "write: $alt/description $!";
         is(xsys('git', "--git-dir=$alt", qw(config gitweb.owner),
                 "lorelei \xc4\x80"), 0,
                 'set gitweb user');
@@ -178,6 +182,13 @@ manifest = \${site}/v2/manifest.js.gz
         for (qw(v2/git/0.git v2/git/1.git v2/git/2.git)) {
                 ok(-d "$tmpdir/per-inbox/$_", "grok-pull created $_");
         }
+        $td->kill;
+        $td->join;
+        is($?, 0, 'no error in exited process');
+        open $fh, '<', $err or BAIL_OUT("open $err failed: $!");
+        my $eout = do { local $/; <$fh> };
+        unlike($eout, qr/wide/i, 'no Wide character warnings');
+        unlike($eout, qr/uninitialized/i, 'no uninitialized warnings');
 }
 
 done_testing();