From 95640413e64c4a857bcfcf7a4dcf0ce79189f894 Mon Sep 17 00:00:00 2001 From: James Edwards-Jones Date: Fri, 3 Nov 2017 14:31:18 +0000 Subject: Gitlab::Git::Popen can lazily hand output to a block This allows input to start processing immediately without waiting for the process to complete. This also allows long or infinite inputs to be partially processed, which will termiate the process when reading stops with SIGPIPE. --- spec/lib/gitlab/git/popen_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'spec') diff --git a/spec/lib/gitlab/git/popen_spec.rb b/spec/lib/gitlab/git/popen_spec.rb index 2b65bc1cf15..b033ede9062 100644 --- a/spec/lib/gitlab/git/popen_spec.rb +++ b/spec/lib/gitlab/git/popen_spec.rb @@ -53,6 +53,23 @@ describe 'Gitlab::Git::Popen' do it { expect(status).to be_zero } it { expect(output).to eq('hello') } end + + context 'with lazy block' do + it 'yields a lazy io' do + expect_lazy_io = lambda do |io| + expect(io).to be_a Enumerator::Lazy + expect(io.inspect).to include('#(io) {}) + end + end + end end context 'popen_with_timeout' do -- cgit v1.2.3