Commit 14f891c4 authored by Samuel E. Giddins's avatar Samuel E. Giddins

[Executable] Fix multiline executable output

parent 2edbe20e
...@@ -86,10 +86,6 @@ module Pod ...@@ -86,10 +86,6 @@ module Pod
i.close i.close
status = t.value status = t.value
o.flush
e.flush
sleep(0.1)
status status
end end
end end
...@@ -100,11 +96,17 @@ module Pod ...@@ -100,11 +96,17 @@ module Pod
begin begin
loop do loop do
buf << input.readpartial(4096) buf << input.readpartial(4096)
string, separator, buf = buf.rpartition(/[\r\n]/) loop do
output << string << separator string, separator, buf = buf.partition(/[\r\n]/)
if separator.empty?
buf = string
break
end
output << (string << separator)
end
end end
rescue EOFError rescue EOFError
output << buf << $/ unless buf.empty? output << (buf << $/) unless buf.empty?
end end
end end
end end
...@@ -141,8 +143,7 @@ module Pod ...@@ -141,8 +143,7 @@ module Pod
# #
def <<(value) def <<(value)
super super
ensure io << "#{ indent }#{ value }" if io
@io << "#{ indent }#{ value }" if @io
end end
end end
end end
......
...@@ -60,6 +60,18 @@ module Pod ...@@ -60,6 +60,18 @@ module Pod
Executable.execute_command('ruby', cmd, true).should == "foo\rbar\nbaz\r" Executable.execute_command('ruby', cmd, true).should == "foo\rbar\nbaz\r"
end end
it 'prints the correct output to the console' do
io = ''
UI.indentation_level = 1
config.verbose = true
Executable::Indenter.any_instance.stubs(:io).returns(io)
cmd = ['-e', <<-RB]
3.times { |i| puts i }
RB
Executable.execute_command('ruby', cmd, true)
io.should == " 0\n 1\n 2\n"
end
describe Executable::Indenter do describe Executable::Indenter do
it 'indents any appended strings' do it 'indents any appended strings' do
UI.indentation_level = 4 UI.indentation_level = 4
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment