mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-06-25 22:53:22 +00:00
Add Check to delete.lua (#236)
This commit is contained in:
parent
d8e1c73d26
commit
00c395f689
|
@ -9,7 +9,10 @@ for i = 1, args.n do
|
||||||
local files = fs.find(shell.resolve(args[i]))
|
local files = fs.find(shell.resolve(args[i]))
|
||||||
if #files > 0 then
|
if #files > 0 then
|
||||||
for n, file in ipairs(files) do
|
for n, file in ipairs(files) do
|
||||||
fs.delete(file)
|
local ok, err = pcall(fs.delete, file)
|
||||||
|
if not ok then
|
||||||
|
printError((err:gsub("^pcall: ", "")))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
printError(args[i] .. ": No matching files")
|
printError(args[i] .. ": No matching files")
|
||||||
|
|
|
@ -39,6 +39,11 @@ describe("The rm program", function()
|
||||||
expect(capture(stub, "rm"))
|
expect(capture(stub, "rm"))
|
||||||
:matches { ok = true, output = "Usage: rm <paths>\n", error = "" }
|
:matches { ok = true, output = "Usage: rm <paths>\n", error = "" }
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it("errors when trying to delete a read-only file", function()
|
||||||
|
expect(capture(stub, "rm /rom/startup.lua"))
|
||||||
|
:matches { ok = true, output = "", error = "/rom/startup.lua: Access denied\n" }
|
||||||
|
end)
|
||||||
|
|
||||||
it("errors when a glob fails to match", function()
|
it("errors when a glob fails to match", function()
|
||||||
expect(capture(stub, "rm", "never-existed"))
|
expect(capture(stub, "rm", "never-existed"))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user