Skip to content

Commit

Permalink
test_in_tail: Fix some omitted tests on Windows
Browse files Browse the repository at this point in the history
Signed-off-by: Takuro Ashie <[email protected]>
  • Loading branch information
ashie committed Jun 1, 2022
1 parent 4f3b7f3 commit e041b61
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions test/plugin/test_in_tail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1011,8 +1011,6 @@ def sub_test_rotate_file(config = nil, expect_emits: nil, expect_records: nil, t
end

def test_truncate_file
omit "Permission denied error happen on Windows. Need fix" if Fluent.windows?

config = SINGLE_LINE_CONFIG
File.open("#{@tmp_dir}/tail.txt", "wb") {|f|
f.puts "test1"
Expand All @@ -1028,7 +1026,13 @@ def test_truncate_file
f.flush
}
waiting(2) { sleep 0.1 until d.events.length == 2 }
File.truncate("#{@tmp_dir}/tail.txt", 6)
if Fluent.windows?
Fluent::FileWrapper.open("#{@tmp_dir}/tail.txt", "wb") { |f|
f.puts("test1");
}
else
File.truncate("#{@tmp_dir}/tail.txt", 6)
end
end

expected = {
Expand All @@ -1047,8 +1051,6 @@ def test_truncate_file
end

def test_move_truncate_move_back
omit "Permission denied error happen on Windows. Need fix" if Fluent.windows?

config = SINGLE_LINE_CONFIG
File.open("#{@tmp_dir}/tail.txt", "wb") {|f|
f.puts "test1"
Expand All @@ -1064,7 +1066,13 @@ def test_move_truncate_move_back
FileUtils.mv("#{@tmp_dir}/tail.txt", "#{@tmp_dir}/tail2.txt")
end
sleep(1)
File.truncate("#{@tmp_dir}/tail2.txt", 6)
if Fluent.windows?
Fluent::FileWrapper.open("#{@tmp_dir}/tail2.txt", "wb") { |f|
f.puts("test1");
}
else
File.truncate("#{@tmp_dir}/tail2.txt", 6)
end
sleep(1)
if Fluent.windows?
FileUtils.mv("#{@tmp_dir}/tail2.txt", "#{@tmp_dir}/tail.txt", force: true)
Expand Down

0 comments on commit e041b61

Please sign in to comment.