Skip to content

Commit

Permalink
WindowsFile: Allow Fluentd to respect DeletePending
Browse files Browse the repository at this point in the history
I think I found a way to add testing for the changeset f61c08c.

 1. Create a test file with FILE_SHARE_DELETE mode.
 2. Call DeleteFile() on that file.
 3. Call stat() on that file.
 4. Check if ENOENT is raised in step 3.

Confirmed to work fine on GitHub Action:

    WindowsFile exceptions:
     test: ERROR_SHARING_VIOLATION raised:        .: (0.001220)
     test: Errno::ENOENT raised:                  .: (0.000633)
     test: Errno::ENOENT raised on DeletePending: .: (0.000717)
     test: nothing raised:                        .: (0.000835)

Signed-off-by: Fujimoto Seiji <fujimoto@ceptord.net>
  • Loading branch information
fujimotos committed Jul 16, 2021
1 parent 63e6e53 commit a1ebeea
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/plugin/test_file_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@ def teardown
end
end

test 'Errno::ENOENT raised on DeletePending' do
path = "#{TMP_DIR}/deletepending.txt"
file = Fluent::WindowsFile.new(path, mode='w')
File.delete(path)
assert_raise(Errno::ENOENT) do
file.stat
ensure
file.close if file
end
end

test 'ERROR_SHARING_VIOLATION raised' do
begin
path = "#{TMP_DIR}/test_windows_file.txt"
Expand Down

0 comments on commit a1ebeea

Please sign in to comment.