From 9dfc0d359b5d1a2230a9bae2ed5980300e9cda42 Mon Sep 17 00:00:00 2001 From: Takuro Ashie Date: Wed, 1 Jun 2022 14:07:45 +0900 Subject: [PATCH] test_in_tail: Make sure to clean up pos file In addition, show a message when fails to remove temp files. Signed-off-by: Takuro Ashie --- test/plugin/test_in_tail.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/plugin/test_in_tail.rb b/test/plugin/test_in_tail.rb index 14961d0c45..c4830a4e82 100644 --- a/test/plugin/test_in_tail.rb +++ b/test/plugin/test_in_tail.rb @@ -34,8 +34,9 @@ def cleanup_directory(path) Dir.glob("*", base: path).each do |name| begin cleanup_file(File.join(path, name)) - rescue + rescue => e # expect test driver block release already owned file handle. + puts "Failed to clean up #{File.join(path, name)}: #{e}" end end else @@ -978,6 +979,7 @@ def test_rotate_file_with_write_old_and_no_new_file(data) end def sub_test_rotate_file(config = nil, expect_emits: nil, expect_records: nil, timeout: 5) + File.open("#{TMP_DIR}/tail.pos", "wb") { |f| } file = Fluent::FileWrapper.open("#{TMP_DIR}/tail.txt", "wb") file.puts "test1" file.puts "test2"