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
i.close
status = t.value
o.flush
e.flush
sleep(0.1)
status
end
end
......@@ -100,11 +96,17 @@ module Pod
begin
loop do
buf << input.readpartial(4096)
string, separator, buf = buf.rpartition(/[\r\n]/)
output << string << separator
loop do
string, separator, buf = buf.partition(/[\r\n]/)
if separator.empty?
buf = string
break
end
output << (string << separator)
end
end
rescue EOFError
output << buf << $/ unless buf.empty?
output << (buf << $/) unless buf.empty?
end
end
end
......@@ -141,8 +143,7 @@ module Pod
#
def <<(value)
super
ensure
@io << "#{ indent }#{ value }" if @io
io << "#{ indent }#{ value }" if io
end
end
end
......
......@@ -60,6 +60,18 @@ module Pod
Executable.execute_command('ruby', cmd, true).should == "foo\rbar\nbaz\r"
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
it 'indents any appended strings' do
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