aboutsummaryrefslogtreecommitdiff
path: root/test/unit/os/fileio_spec.lua
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2024-01-12 12:03:25 +0000
committerLewis Russell <lewis6991@gmail.com>2024-01-12 12:04:20 +0000
commit284e0ad26dd9de90c3a813dd1b357a425eca6bad (patch)
tree55b60f82154a6aadbd3c53e6441e0b2c590f11f6 /test/unit/os/fileio_spec.lua
parent56a2ec5c79d49421758319f1a8822cf30f1f8a5e (diff)
downloadrneovim-284e0ad26dd9de90c3a813dd1b357a425eca6bad.tar.gz
rneovim-284e0ad26dd9de90c3a813dd1b357a425eca6bad.tar.bz2
rneovim-284e0ad26dd9de90c3a813dd1b357a425eca6bad.zip
test: use vim.mpack and vim.uv directly
Diffstat (limited to 'test/unit/os/fileio_spec.lua')
-rw-r--r--test/unit/os/fileio_spec.lua58
1 files changed, 29 insertions, 29 deletions
diff --git a/test/unit/os/fileio_spec.lua b/test/unit/os/fileio_spec.lua
index 30e4fad88f..385f4fa4b0 100644
--- a/test/unit/os/fileio_spec.lua
+++ b/test/unit/os/fileio_spec.lua
@@ -1,4 +1,4 @@
-local luv = require('luv')
+local uv = vim.uv
local helpers = require('test.unit.helpers')(after_each)
local itp = helpers.gen_itp(it)
@@ -36,8 +36,8 @@ before_each(function()
f2:write(fcontents)
f2:close()
- luv.fs_symlink('file1.dat', linkf)
- luv.fs_symlink('broken.dat', linkb)
+ uv.fs_symlink('file1.dat', linkf)
+ uv.fs_symlink('broken.dat', linkb)
end)
after_each(function()
@@ -46,7 +46,7 @@ after_each(function()
os.remove(linkf)
os.remove(linkb)
os.remove(filec)
- luv.fs_rmdir(dir)
+ uv.fs_rmdir(dir)
end)
local function file_open(fname, flags, mode)
@@ -120,13 +120,13 @@ describe('file_open_fd', function()
eq(0, m.file_close(fp, false))
end)
itp('can use file descriptor returned by os_open for writing', function()
- eq(nil, luv.fs_stat(filec))
+ eq(nil, uv.fs_stat(filec))
local fd = m.os_open(filec, m.kO_WRONLY + m.kO_CREAT, 384)
local err, fp = file_open_fd(fd, m.kFileWriteOnly)
eq(0, err)
eq(4, file_write(fp, 'test'))
eq(0, m.file_close(fp, false))
- eq(4, luv.fs_stat(filec).size)
+ eq(4, uv.fs_stat(filec).size)
eq('test', io.open(filec):read('*a'))
end)
end)
@@ -140,13 +140,13 @@ describe('file_open_fd_new', function()
eq(0, m.file_free(fp, false))
end)
itp('can use file descriptor returned by os_open for writing', function()
- eq(nil, luv.fs_stat(filec))
+ eq(nil, uv.fs_stat(filec))
local fd = m.os_open(filec, m.kO_WRONLY + m.kO_CREAT, 384)
local err, fp = file_open_fd_new(fd, m.kFileWriteOnly)
eq(0, err)
eq(4, file_write(fp, 'test'))
eq(0, m.file_free(fp, false))
- eq(4, luv.fs_stat(filec).size)
+ eq(4, uv.fs_stat(filec).size)
eq('test', io.open(filec):read('*a'))
end)
end)
@@ -155,7 +155,7 @@ describe('file_open', function()
itp('can create a rwx------ file with kFileCreate', function()
local err, fp = file_open(filec, m.kFileCreate, 448)
eq(0, err)
- local attrs = luv.fs_stat(filec)
+ local attrs = uv.fs_stat(filec)
eq(33216, attrs.mode)
eq(0, m.file_close(fp, false))
end)
@@ -163,7 +163,7 @@ describe('file_open', function()
itp('can create a rw------- file with kFileCreate', function()
local err, fp = file_open(filec, m.kFileCreate, 384)
eq(0, err)
- local attrs = luv.fs_stat(filec)
+ local attrs = uv.fs_stat(filec)
eq(33152, attrs.mode)
eq(0, m.file_close(fp, false))
end)
@@ -171,7 +171,7 @@ describe('file_open', function()
itp('can create a rwx------ file with kFileCreateOnly', function()
local err, fp = file_open(filec, m.kFileCreateOnly, 448)
eq(0, err)
- local attrs = luv.fs_stat(filec)
+ local attrs = uv.fs_stat(filec)
eq(33216, attrs.mode)
eq(0, m.file_close(fp, false))
end)
@@ -179,7 +179,7 @@ describe('file_open', function()
itp('can create a rw------- file with kFileCreateOnly', function()
local err, fp = file_open(filec, m.kFileCreateOnly, 384)
eq(0, err)
- local attrs = luv.fs_stat(filec)
+ local attrs = uv.fs_stat(filec)
eq(33152, attrs.mode)
eq(0, m.file_close(fp, false))
end)
@@ -231,7 +231,7 @@ describe('file_open', function()
eq(0, err)
eq(true, fp.wr)
eq(0, m.file_close(fp, false))
- local attrs = luv.fs_stat(file1)
+ local attrs = uv.fs_stat(file1)
eq(0, attrs.size)
end)
@@ -240,14 +240,14 @@ describe('file_open', function()
eq(0, err)
eq(true, fp.wr)
eq(0, m.file_close(fp, false))
- local attrs = luv.fs_stat(file1)
+ local attrs = uv.fs_stat(file1)
eq(4096, attrs.size)
end)
itp('fails to create a file with just kFileWriteOnly', function()
local err, _ = file_open(filec, m.kFileWriteOnly, 384)
eq(m.UV_ENOENT, err)
- local attrs = luv.fs_stat(filec)
+ local attrs = uv.fs_stat(filec)
eq(nil, attrs)
end)
@@ -256,7 +256,7 @@ describe('file_open', function()
eq(0, err)
eq(true, fp.wr)
eq(0, m.file_close(fp, false))
- local attrs = luv.fs_stat(file1)
+ local attrs = uv.fs_stat(file1)
eq(0, attrs.size)
end)
@@ -297,9 +297,9 @@ describe('file_close', function()
eq(0, err)
local wsize = file_write(fp, 'test')
eq(4, wsize)
- eq(0, luv.fs_stat(filec).size)
+ eq(0, uv.fs_stat(filec).size)
eq(0, m.file_close(fp, true))
- eq(wsize, luv.fs_stat(filec).size)
+ eq(wsize, uv.fs_stat(filec).size)
end)
end)
@@ -309,9 +309,9 @@ describe('file_free', function()
eq(0, err)
local wsize = file_write(fp, 'test')
eq(4, wsize)
- eq(0, luv.fs_stat(filec).size)
+ eq(0, uv.fs_stat(filec).size)
eq(0, m.file_free(fp, true))
- eq(wsize, luv.fs_stat(filec).size)
+ eq(wsize, uv.fs_stat(filec).size)
end)
end)
@@ -320,12 +320,12 @@ describe('file_fsync', function()
local err, fp = file_open(filec, m.kFileCreateOnly, 384)
eq(0, file_fsync(fp))
eq(0, err)
- eq(0, luv.fs_stat(filec).size)
+ eq(0, uv.fs_stat(filec).size)
local wsize = file_write(fp, 'test')
eq(4, wsize)
- eq(0, luv.fs_stat(filec).size)
+ eq(0, uv.fs_stat(filec).size)
eq(0, file_fsync(fp))
- eq(wsize, luv.fs_stat(filec).size)
+ eq(wsize, uv.fs_stat(filec).size)
eq(0, m.file_close(fp, false))
end)
end)
@@ -335,12 +335,12 @@ describe('file_flush', function()
local err, fp = file_open(filec, m.kFileCreateOnly, 384)
eq(0, file_flush(fp))
eq(0, err)
- eq(0, luv.fs_stat(filec).size)
+ eq(0, uv.fs_stat(filec).size)
local wsize = file_write(fp, 'test')
eq(4, wsize)
- eq(0, luv.fs_stat(filec).size)
+ eq(0, uv.fs_stat(filec).size)
eq(0, file_flush(fp))
- eq(wsize, luv.fs_stat(filec).size)
+ eq(wsize, uv.fs_stat(filec).size)
eq(0, m.file_close(fp, false))
end)
end)
@@ -411,7 +411,7 @@ describe('file_write', function()
local wr = file_write(fp, fcontents)
eq(#fcontents, wr)
eq(0, m.file_close(fp, false))
- eq(wr, luv.fs_stat(filec).size)
+ eq(wr, uv.fs_stat(filec).size)
eq(fcontents, io.open(filec):read('*a'))
end)
@@ -428,7 +428,7 @@ describe('file_write', function()
shift = shift + size
end
eq(0, m.file_close(fp, false))
- eq(#fcontents, luv.fs_stat(filec).size)
+ eq(#fcontents, uv.fs_stat(filec).size)
eq(fcontents, io.open(filec):read('*a'))
end)
@@ -445,7 +445,7 @@ describe('file_write', function()
shift = shift + size
end
eq(0, m.file_close(fp, false))
- eq(#fcontents, luv.fs_stat(filec).size)
+ eq(#fcontents, uv.fs_stat(filec).size)
eq(fcontents, io.open(filec):read('*a'))
end)
end)