Skip to content

Commit

Permalink
Merge pull request #1289 from fluent/testing-with-windows-binary-mode
Browse files Browse the repository at this point in the history
make sure to set binary mode on #open, and to wait write operation
  • Loading branch information
tagomoris authored Oct 24, 2016
2 parents de27433 + d6c7d00 commit df5ce96
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/fluent/command/binlog_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def initialize(argv = ARGV)
def call
@formatter = lookup_formatter(@options[:format], @options[:config_params])

File.open(@path, 'r') do |io|
File.open(@path, 'rb') do |io|
i = 1
Fluent::MessagePackFactory.unpacker(io).each do |(time, record)|
print @formatter.format(@path, time, record) # path is used for tag
Expand Down
6 changes: 5 additions & 1 deletion test/command/test_binlog_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,13 @@ class TestBaseCommand < ::Test::Unit::TestCase
def create_message_packed_file(path, times = [event_time], records = [{ 'message' => 'dummy' }])
es = Fluent::MultiEventStream.new(times, records)
v = es.to_msgpack_stream
File.open("#{TMP_DIR}/#{path}", 'w') do |f|
out_path = "#{TMP_DIR}/#{path}"
File.open(out_path, 'wb') do |f|
f.print(v)
end
waiting(5) do
sleep 0.5 until File.size(out_path) == v.bytesize
end
end

def setup
Expand Down

0 comments on commit df5ce96

Please sign in to comment.