From 8a3fc4a2f027b36f27225ceee5908c571c8f4f47 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 4 Mar 2017 03:52:29 +0000 Subject: repoobrowse: explicit EOF handling for git async callback We need to ensure we've fully-drained the pipe before signalling EOF to the callback, since pipelining may not be the best choice with detachable processes in the future. --- t/git_async.t | 4 ++++ 1 file changed, 4 insertions(+) (limited to 't') diff --git a/t/git_async.t b/t/git_async.t index 4f7e4ebe..ffe2b1a2 100644 --- a/t/git_async.t +++ b/t/git_async.t @@ -117,6 +117,7 @@ my $dir = "$tmpdir/git.git"; } my @info; my $str = ''; + my $eof_seen = 0; $git->cat_async_compat('HEAD:foo.txt', sub { my $ref = $_[0]; my $t = ref $ref; @@ -124,10 +125,13 @@ my $dir = "$tmpdir/git.git"; push @info, $ref; } elsif ($t eq 'SCALAR') { $str .= $$ref; + } elsif ($ref == 0) { + $eof_seen++; } else { fail "fail type: $t"; } }); + is($eof_seen, 1, 'EOF seen once'); is_deeply(\@info, [ [ 'bf4f17855632367a160bef055fc8ba4675d10e6b', 'blob', 18 ]], 'info matches compat'); is($str, "-----\nhello\nworld\n", 'data matches compat'); -- cgit v1.2.3-24-ge0c7