Permalink
Browse files

split lines better so that trailing and leading linebreaks are accoun…

…ted for
  • Loading branch information...
1 parent 59a97b4 commit 3e4a8f42c06ff4d76fa18a6efff02b8762cf96da @benfoxall benfoxall committed Mar 25, 2011
Showing with 16 additions and 3 deletions.
  1. +3 −3 lib/big_tuna/runner/output.rb
  2. +13 −0 test/unit/output_test.rb
@@ -50,10 +50,10 @@ def append stream, txt
return if txt.nil?
- lines = txt.split /\r?\n/
+ lines = txt.split /\r?\n/, -1
- # continue from where we left off
- if @output != [] && @output.last[0] == stream
+ # continue from where we left off?
+ unless @output.empty? || @output.last[0] != stream
@output.last[1] << lines.shift
end
@@ -37,4 +37,17 @@ class OutputTest < ActiveSupport::TestCase
end
+ test 'trailing linebreaks are seperated' do
+
+ @output.append_stdout "a\n"
+ @output.append_stdout "b"
+ @output.append_stderr 'c'
+
+ result = @output.finish 0
+
+ assert_equal result, [[OUT, 'a'],[OUT, 'b'],[ERR,'c']]
+
+ end
+
+
end

0 comments on commit 3e4a8f4

Please sign in to comment.