test(unit): use file:close() properly (#21505)

This commit is contained in:
zeertzjq 2022-12-22 22:17:01 +08:00 committed by GitHub
parent 843ad837c6
commit b2d984558b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions

View File

@ -28,9 +28,9 @@ describe('buffer functions', function()
setup(function() setup(function()
-- create the files -- create the files
io.open(path1, 'w').close() io.open(path1, 'w'):close()
io.open(path2, 'w').close() io.open(path2, 'w'):close()
io.open(path3, 'w').close() io.open(path3, 'w'):close()
end) end)
teardown(function() teardown(function()

View File

@ -72,9 +72,9 @@ describe('fs.c', function()
before_each(function() before_each(function()
lfs.mkdir('unit-test-directory'); lfs.mkdir('unit-test-directory');
io.open('unit-test-directory/test.file', 'w').close() io.open('unit-test-directory/test.file', 'w'):close()
io.open('unit-test-directory/test_2.file', 'w').close() io.open('unit-test-directory/test_2.file', 'w'):close()
lfs.link('test.file', 'unit-test-directory/test_link.file', true) lfs.link('test.file', 'unit-test-directory/test_link.file', true)
lfs.link('non_existing_file.file', 'unit-test-directory/test_broken_link.file', true) lfs.link('non_existing_file.file', 'unit-test-directory/test_broken_link.file', true)
@ -472,7 +472,7 @@ describe('fs.c', function()
describe('os_remove', function() describe('os_remove', function()
before_each(function() before_each(function()
io.open('unit-test-directory/test_remove.file', 'w').close() io.open('unit-test-directory/test_remove.file', 'w'):close()
end) end)
after_each(function() after_each(function()

View File

@ -82,8 +82,8 @@ describe('path.c', function()
local f2 = 'f2.o' local f2 = 'f2.o'
before_each(function() before_each(function()
-- create the three files that will be used in this spec -- create the three files that will be used in this spec
io.open(f1, 'w').close() io.open(f1, 'w'):close()
io.open(f2, 'w').close() io.open(f2, 'w'):close()
end) end)
after_each(function() after_each(function()
@ -355,7 +355,7 @@ end)
describe('path.c', function() describe('path.c', function()
setup(function() setup(function()
lfs.mkdir('unit-test-directory'); lfs.mkdir('unit-test-directory');
io.open('unit-test-directory/test.file', 'w').close() io.open('unit-test-directory/test.file', 'w'):close()
-- Since the tests are executed, they are called by an executable. We use -- Since the tests are executed, they are called by an executable. We use
-- that executable for several asserts. -- that executable for several asserts.