Skip to content

Commit 1a68fcf

Browse files
committed
test(fs): fix macOS path and cwd issues
1 parent c20cf3d commit 1a68fcf

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

tests/fs.test.lua

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ describe("mods.fs", function()
2020
local readme_file = join(cwd, "README.md")
2121
local spec_file = join(cwd, "tests", "_types.lua")
2222

23+
after_each(function()
24+
fs.cd(cwd)
25+
end)
26+
2327
for _, fname in ipairs({ "getsize", "getatime", "getmtime", "getctime" }) do
2428
it(fmt("%s() returns a number for an existing path", fname), function()
2529
assert.is_number(fs[fname](readme_file))
@@ -81,8 +85,15 @@ describe("mods.fs", function()
8185

8286
it("changes the current working directory", function()
8387
local root = make_tmp_dir()
88+
local canonical_root = root
89+
local tmp = lfs.currentdir()
90+
if tmp and lfs.chdir(root) then
91+
canonical_root = lfs.currentdir()
92+
lfs.chdir(tmp)
93+
end
94+
8495
assert.is_true(fs.cd(root))
85-
assert.are_equal(root, path.cwd())
96+
assert.are_equal(canonical_root, path.cwd())
8697
assert.is_true(fs.cd(cwd))
8798
assert.is_true(fs.rm(root, true))
8899
end)

0 commit comments

Comments
 (0)