Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keplerproject/luafilesystem.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authortuler <tuler>2005-06-04 01:50:59 +0400
committertuler <tuler>2005-06-04 01:50:59 +0400
commit97abe2139e6eb67ed03da94dfd23dfb0c259a504 (patch)
treed118b7af2cfbefd63f23d4d9fc12b32a409da7e1 /tests
parent197032fa7ba679c62c0e8ebc2157e225edd181a0 (diff)
new function lfs.rmdir
Diffstat (limited to 'tests')
-rw-r--r--tests/test.lua30
1 files changed, 17 insertions, 13 deletions
diff --git a/tests/test.lua b/tests/test.lua
index 7f981e5..d0018cd 100644
--- a/tests/test.lua
+++ b/tests/test.lua
@@ -9,7 +9,7 @@ require"lfs"
function attrdir (path)
for file in lfs.dir(path) do
if file ~= "." and file ~= ".." then
- local f = path..'/'..file
+ local f = path..sep..file
print ("\t=> "..f.." <=")
local attr = lfs.attributes (f)
assert (type(attr) == "table")
@@ -32,30 +32,34 @@ assert (lfs.chdir (reldir), "could not change back to current directory")
assert (lfs.currentdir() == current, "error trying to change directories")
assert (lfs.chdir ("this couldn't be an actual directory") == nil, "could change to a non-existent directory")
-- Changing creating and removing directories
-local tmpdir = tmp.."/lfs_tmp_dir"
+local tmpdir = tmp..sep.."lfs_tmp_dir"
assert (lfs.mkdir (tmpdir), "could not make a new directory")
-local attrib, errmsg = lfs.attributes (tmpdir)
+-- create a new file
+local tmpfile = tmpdir..sep.."lfs_tmp_file"
+assert (io.open(tmpfile, "w"), "could not make a new file")
+local attrib, errmsg = lfs.attributes (tmpfile)
if not attrib then
- error ("could not get attributes of file `"..tmpdir.."':\n"..errmsg)
+ error ("could not get attributes of file `"..tmpfile.."':\n"..errmsg)
else
-- Change access time
- assert (lfs.touch (tmpdir, 11))
- local new_att = assert (lfs.attributes (tmpdir))
- assert (new_att.access == 11, "could not set access time")
+ assert (lfs.touch (tmpfile, 11))
+ local new_att = assert (lfs.attributes (tmpfile))
+ assert (new_att.access == 11, string.format("could not set access time: %s", tostring(new_att.access)))
assert (new_att.modification == 11, "could not set modification time")
-- Change access and modification time
- assert (lfs.touch (tmpdir, 33, 22))
- local new_att = assert (lfs.attributes (tmpdir))
+ assert (lfs.touch (tmpfile, 33, 22))
+ local new_att = assert (lfs.attributes (tmpfile))
assert (new_att.access == 33, "could not set access time")
assert (new_att.modification == 22, "could not set modification time")
-- Restore access time to current value
- assert (lfs.touch (tmpdir))
- new_att = assert (lfs.attributes (tmpdir))
+ assert (lfs.touch (tmpfile))
+ new_att = assert (lfs.attributes (tmpfile))
assert (new_att.access == attrib.access)
assert (new_att.modification == attrib.modification)
end
-assert (os.remove (tmpdir), "could not remove new directory")
-assert (lfs.mkdir (tmpdir.."/lfs_tmp_dir") == false, "could create a directory inside a non-existent one")
+assert (os.remove (tmpfile), "could not remove file")
+assert (lfs.rmdir (tmpdir), "could not remove new directory")
+assert (lfs.mkdir (tmpdir..sep.."lfs_tmp_dir") == false, "could create a directory inside a non-existent one")
--
assert (lfs.attributes ("this couldn't be an actual file") == nil, "could get attributes of a non-existent file")
assert (type(lfs.attributes (upper)) == "table", "couldn't get attributes of upper directory")