about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-06-13 08:10:02 +0000
committerEric Wong <e@80x24.org>2019-06-14 01:01:02 +0000
commit19629ff99de0eb43a26963b8c276eae54f1247c8 (patch)
tree4d6a06b93888e9d488a25b6f4e889dde300f80df /t
parent541103582a3f60a3c6df0383382cacd782ea1edd (diff)
downloadpublic-inbox-19629ff99de0eb43a26963b8c276eae54f1247c8.tar.gz
We weren't using it, and in retrospect, it makes no sense to use
this API cat_file for giant responses which can't read quickly
with minimal context-switching (or sanely fit into memory for
Email::Simple/Email::MIME).

For giant blobs which we don't want slurped in memory, we'll
spawn a short-lived git-cat-file process like we do in ViewVCS.

Otherwise, monopolizing a git-cat-file process for a giant
blob is harmful to other PSGI/NNTP users.

A better interface is coming which will be more suitable for
for batch processing of "small" objects such as commits and
email blobs.
Diffstat (limited to 't')
-rw-r--r--t/git.t58
1 files changed, 0 insertions, 58 deletions
diff --git a/t/git.t b/t/git.t
index 913f6e5e..9bc8900c 100644
--- a/t/git.t
+++ b/t/git.t
@@ -33,33 +33,7 @@ use_ok 'PublicInbox::Git';
         my $raw = $gcf->cat_file($f);
         is($x[2], length($$raw), 'length matches');
 
-        {
-                my $size;
-                my $rv = $gcf->cat_file($f, sub {
-                        my ($in, $left) = @_;
-                        $size = $$left;
-                        'nothing'
-                });
-                is($rv, 'nothing', 'returned from callback without reading');
-                is($size, $x[2], 'set size for callback correctly');
-        }
-
-        eval { $gcf->cat_file($f, sub { die 'OMG' }) };
-        like($@, qr/\bOMG\b/, 'died in callback propagated');
         is(${$gcf->cat_file($f)}, $$raw, 'not broken after failures');
-
-        {
-                my ($buf, $r);
-                my $rv = $gcf->cat_file($f, sub {
-                        my ($in, $left) = @_;
-                        $r = read($in, $buf, 2);
-                        $$left -= $r;
-                        'blah'
-                });
-                is($r, 2, 'only read 2 bytes');
-                is($buf, '--', 'partial read succeeded');
-                is($rv, 'blah', 'return value propagated');
-        }
         is(${$gcf->cat_file($f)}, $$raw, 'not broken after partial read');
 }
 
@@ -79,44 +53,12 @@ if (1) {
 
         my $gcf = PublicInbox::Git->new($dir);
         my $rsize;
-        is($gcf->cat_file($buf, sub {
-                $rsize = ${$_[1]};
-                'x';
-        }), 'x', 'checked input');
-        is($rsize, $size, 'got correct size on big file');
-
         my $x = $gcf->cat_file($buf, \$rsize);
         is($rsize, $size, 'got correct size ref on big file');
         is(length($$x), $size, 'read correct number of bytes');
 
-        my $rline;
-        $gcf->cat_file($buf, sub {
-                my ($in, $left) = @_;
-                $rline = <$in>;
-                $$left -= length($rline);
-        });
-        {
-                open my $fh, '<', $big_data or die "open failed: $!\n";
-                is($rline, <$fh>, 'first line matches');
-        };
-
-        my $all;
-        $gcf->cat_file($buf, sub {
-                my ($in, $left) = @_;
-                my $x = read($in, $all, $$left);
-                $$left -= $x;
-        });
-        {
-                open my $fh, '<', $big_data or die "open failed: $!\n";
-                local $/;
-                is($all, <$fh>, 'entire read matches');
-        };
-
         my $ref = $gcf->qx(qw(cat-file blob), $buf);
-        is($all, $ref, 'qx read giant single string');
-
         my @ref = $gcf->qx(qw(cat-file blob), $buf);
-        is($all, join('', @ref), 'qx returned array when wanted');
         my $nl = scalar @ref;
         ok($nl > 1, "qx returned array length of $nl");