aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authortuler <tuler>2005-06-03 21:50:59 +0000
committertuler <tuler>2005-06-03 21:50:59 +0000
commit97abe2139e6eb67ed03da94dfd23dfb0c259a504 (patch)
treed118b7af2cfbefd63f23d4d9fc12b32a409da7e1 /tests
parent197032fa7ba679c62c0e8ebc2157e225edd181a0 (diff)
downloadluafilesystem-97abe2139e6eb67ed03da94dfd23dfb0c259a504.tar.gz
luafilesystem-97abe2139e6eb67ed03da94dfd23dfb0c259a504.tar.bz2
luafilesystem-97abe2139e6eb67ed03da94dfd23dfb0c259a504.zip
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"
9function attrdir (path) 9function attrdir (path)
10 for file in lfs.dir(path) do 10 for file in lfs.dir(path) do
11 if file ~= "." and file ~= ".." then 11 if file ~= "." and file ~= ".." then
12 local f = path..'/'..file 12 local f = path..sep..file
13 print ("\t=> "..f.." <=") 13 print ("\t=> "..f.." <=")
14 local attr = lfs.attributes (f) 14 local attr = lfs.attributes (f)
15 assert (type(attr) == "table") 15 assert (type(attr) == "table")
@@ -32,30 +32,34 @@ assert (lfs.chdir (reldir), "could not change back to current directory")
32assert (lfs.currentdir() == current, "error trying to change directories") 32assert (lfs.currentdir() == current, "error trying to change directories")
33assert (lfs.chdir ("this couldn't be an actual directory") == nil, "could change to a non-existent directory") 33assert (lfs.chdir ("this couldn't be an actual directory") == nil, "could change to a non-existent directory")
34-- Changing creating and removing directories 34-- Changing creating and removing directories
35local tmpdir = tmp.."/lfs_tmp_dir" 35local tmpdir = tmp..sep.."lfs_tmp_dir"
36assert (lfs.mkdir (tmpdir), "could not make a new directory") 36assert (lfs.mkdir (tmpdir), "could not make a new directory")
37local attrib, errmsg = lfs.attributes (tmpdir) 37-- create a new file
38local tmpfile = tmpdir..sep.."lfs_tmp_file"
39assert (io.open(tmpfile, "w"), "could not make a new file")
40local attrib, errmsg = lfs.attributes (tmpfile)
38if not attrib then 41if not attrib then
39 error ("could not get attributes of file `"..tmpdir.."':\n"..errmsg) 42 error ("could not get attributes of file `"..tmpfile.."':\n"..errmsg)
40else 43else
41 -- Change access time 44 -- Change access time
42 assert (lfs.touch (tmpdir, 11)) 45 assert (lfs.touch (tmpfile, 11))
43 local new_att = assert (lfs.attributes (tmpdir)) 46 local new_att = assert (lfs.attributes (tmpfile))
44 assert (new_att.access == 11, "could not set access time") 47 assert (new_att.access == 11, string.format("could not set access time: %s", tostring(new_att.access)))
45 assert (new_att.modification == 11, "could not set modification time") 48 assert (new_att.modification == 11, "could not set modification time")
46 -- Change access and modification time 49 -- Change access and modification time
47 assert (lfs.touch (tmpdir, 33, 22)) 50 assert (lfs.touch (tmpfile, 33, 22))
48 local new_att = assert (lfs.attributes (tmpdir)) 51 local new_att = assert (lfs.attributes (tmpfile))
49 assert (new_att.access == 33, "could not set access time") 52 assert (new_att.access == 33, "could not set access time")
50 assert (new_att.modification == 22, "could not set modification time") 53 assert (new_att.modification == 22, "could not set modification time")
51 -- Restore access time to current value 54 -- Restore access time to current value
52 assert (lfs.touch (tmpdir)) 55 assert (lfs.touch (tmpfile))
53 new_att = assert (lfs.attributes (tmpdir)) 56 new_att = assert (lfs.attributes (tmpfile))
54 assert (new_att.access == attrib.access) 57 assert (new_att.access == attrib.access)
55 assert (new_att.modification == attrib.modification) 58 assert (new_att.modification == attrib.modification)
56end 59end
57assert (os.remove (tmpdir), "could not remove new directory") 60assert (os.remove (tmpfile), "could not remove file")
58assert (lfs.mkdir (tmpdir.."/lfs_tmp_dir") == false, "could create a directory inside a non-existent one") 61assert (lfs.rmdir (tmpdir), "could not remove new directory")
62assert (lfs.mkdir (tmpdir..sep.."lfs_tmp_dir") == false, "could create a directory inside a non-existent one")
59-- 63--
60assert (lfs.attributes ("this couldn't be an actual file") == nil, "could get attributes of a non-existent file") 64assert (lfs.attributes ("this couldn't be an actual file") == nil, "could get attributes of a non-existent file")
61assert (type(lfs.attributes (upper)) == "table", "couldn't get attributes of upper directory") 65assert (type(lfs.attributes (upper)) == "table", "couldn't get attributes of upper directory")