From e041b618fd9527b964c8546e80ffe1f39d57050f Mon Sep 17 00:00:00 2001 From: Takuro Ashie Date: Thu, 2 Jun 2022 08:59:44 +0900 Subject: [PATCH] test_in_tail: Fix some omitted tests on Windows Signed-off-by: Takuro Ashie --- test/plugin/test_in_tail.rb | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/test/plugin/test_in_tail.rb b/test/plugin/test_in_tail.rb index fecf3cab69..17b9d022a9 100644 --- a/test/plugin/test_in_tail.rb +++ b/test/plugin/test_in_tail.rb @@ -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" @@ -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 = { @@ -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" @@ -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)