diff options
| author | William Boman <william@redwill.se> | 2026-05-30 15:57:13 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-30 15:57:13 +0200 |
| commit | 93e99ea2da7b8a10ecc6dc189b0ca3dd71e81e1c (patch) | |
| tree | a397cfc1b387aee108951c4fb3c5e305ab59bc94 /tests/mason-core | |
| parent | refactor(fs): implement mkdirp natively via libuv (#2100) (diff) | |
| download | mason-93e99ea2da7b8a10ecc6dc189b0ca3dd71e81e1c.tar mason-93e99ea2da7b8a10ecc6dc189b0ca3dd71e81e1c.tar.gz mason-93e99ea2da7b8a10ecc6dc189b0ca3dd71e81e1c.tar.bz2 mason-93e99ea2da7b8a10ecc6dc189b0ca3dd71e81e1c.tar.lz mason-93e99ea2da7b8a10ecc6dc189b0ca3dd71e81e1c.tar.xz mason-93e99ea2da7b8a10ecc6dc189b0ca3dd71e81e1c.tar.zst mason-93e99ea2da7b8a10ecc6dc189b0ca3dd71e81e1c.zip | |
refactor(fs): use fs.ls in readdir implementation, prefer fs_stat over fs_fstat (#2101)
Diffstat (limited to 'tests/mason-core')
| -rw-r--r-- | tests/mason-core/fs_spec.lua | 24 | ||||
| -rw-r--r-- | tests/mason-core/installer/compiler/link_spec.lua | 16 |
2 files changed, 32 insertions, 8 deletions
diff --git a/tests/mason-core/fs_spec.lua b/tests/mason-core/fs_spec.lua index 3962b8cd..22a467fe 100644 --- a/tests/mason-core/fs_spec.lua +++ b/tests/mason-core/fs_spec.lua @@ -31,4 +31,28 @@ describe("fs", function() local stat = assert(vim.uv.fs_stat(nested), "fs_stat returned no value") assert.equals("directory", stat.type) end) + + it("should check if file_exists", function() + local temp = vim.fn.tempname() + + assert.is_false(fs.sync.file_exists(temp)) + fs.sync.write_file(temp, "") + assert.is_true(fs.sync.file_exists(temp)) + + local temp_dir = vim.fn.tempname() + fs.sync.mkdir(temp_dir) + assert.is_false(fs.sync.file_exists(temp_dir)) + end) + + it("should check if dir_exists", function() + local temp = vim.fn.tempname() + + assert.is_false(fs.sync.dir_exists(temp)) + fs.sync.mkdir(temp) + assert.is_true(fs.sync.dir_exists(temp)) + + local temp_file = vim.fn.tempname() + fs.sync.write_file(temp_file, "") + assert.is_false(fs.sync.dir_exists(temp_file)) + end) end) diff --git a/tests/mason-core/installer/compiler/link_spec.lua b/tests/mason-core/installer/compiler/link_spec.lua index 62777bc9..6c77bbc6 100644 --- a/tests/mason-core/installer/compiler/link_spec.lua +++ b/tests/mason-core/installer/compiler/link_spec.lua @@ -22,10 +22,10 @@ describe("registry linker", function() local ctx = test_helpers.create_context() stub(ctx.fs, "file_exists") stub(ctx.fs, "chmod") - stub(ctx.fs, "fstat") + stub(ctx.fs, "stat") ctx.fs.file_exists.on_call_with(match.is_ref(ctx.fs), "exec.sh").returns(true) - ctx.fs.fstat.on_call_with(match.is_ref(ctx.fs), "exec.sh").returns { + ctx.fs.stat.on_call_with(match.is_ref(ctx.fs), "exec.sh").returns { mode = 493, -- 0755 } @@ -59,10 +59,10 @@ describe("registry linker", function() local ctx = test_helpers.create_context() stub(ctx.fs, "file_exists") stub(ctx.fs, "chmod") - stub(ctx.fs, "fstat") + stub(ctx.fs, "stat") ctx.fs.file_exists.on_call_with(match.is_ref(ctx.fs), "exec.sh").returns(true) - ctx.fs.fstat.on_call_with(match.is_ref(ctx.fs), "exec.sh").returns { + ctx.fs.stat.on_call_with(match.is_ref(ctx.fs), "exec.sh").returns { mode = 420, -- 0644 } @@ -88,10 +88,10 @@ describe("registry linker", function() local ctx = test_helpers.create_context() stub(ctx.fs, "file_exists") stub(ctx.fs, "chmod") - stub(ctx.fs, "fstat") + stub(ctx.fs, "stat") ctx.fs.file_exists.on_call_with(match.is_ref(ctx.fs), "v1.0.0-exec.sh").returns(true) - ctx.fs.fstat.on_call_with(match.is_ref(ctx.fs), "v1.0.0-exec.sh").returns { + ctx.fs.stat.on_call_with(match.is_ref(ctx.fs), "v1.0.0-exec.sh").returns { mode = 493, -- 0755 } @@ -120,7 +120,7 @@ describe("registry linker", function() local ctx = test_helpers.create_context() stub(ctx.fs, "file_exists") stub(ctx.fs, "chmod") - stub(ctx.fs, "fstat") + stub(ctx.fs, "stat") local matrix = { ["cargo:executable"] = "bin/executable", @@ -135,7 +135,7 @@ describe("registry linker", function() for bin, path in pairs(matrix) do ctx.fs.file_exists.on_call_with(match.is_ref(ctx.fs), path).returns(true) - ctx.fs.fstat.on_call_with(match.is_ref(ctx.fs), path).returns { + ctx.fs.stat.on_call_with(match.is_ref(ctx.fs), path).returns { mode = 493, -- 0755 } |
