Add tempdir support

This commit is contained in:
2025-06-27 03:53:08 +10:00
parent 0c4639c3e9
commit cdfb2522ac
4 changed files with 64 additions and 1 deletions

17
crates/lb/tests/fs.lua Normal file
View File

@@ -0,0 +1,17 @@
local ok, fs = pcall(require, "lb:fs")
if not ok then return end
describe("temp files", function()
test("temp_dir cleans itself", function()
local path
do
local dir = fs:temp_dir()
path = dir:path()
assert(path and path ~= "")
fs:write(path .. "/test.txt", "test file")
assert(fs:read(path .. "/test.txt") == "test file")
end
collectgarbage()
assert(not pcall(fs.read, fs, path .. "/test.txt"))
end)
end)