diff options
author | uid20006 <uid20006> | 2005-08-16 22:24:28 +0400 |
---|---|---|
committer | uid20006 <uid20006> | 2005-08-16 22:24:28 +0400 |
commit | 87b373b3d80e234c482e6276a20be2d329d4b795 (patch) | |
tree | 33134667befda49d88bfd0f013d609e07941cad0 /tests | |
parent | e7ced7f8af5f3316cf4508478a13dc51cff28773 (diff) |
touch does not work with directories in windows.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test.lua | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/tests/test.lua b/tests/test.lua index a152bbb..3522bee 100644 --- a/tests/test.lua +++ b/tests/test.lua @@ -1,4 +1,4 @@ -#!/usr/local/bin/lua +#!/usr/local/bin/lua50 local tmp = "/tmp" local sep = "/" @@ -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") @@ -31,34 +31,45 @@ assert (lfs.chdir (upper), "could not change to upper directory") 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" +local tmpfile = tmpdir..sep.."tmp_file" assert (lfs.mkdir (tmpdir), "could not make a new directory") local attrib, errmsg = lfs.attributes (tmpdir) if not attrib then error ("could not get attributes of file `"..tmpdir.."':\n"..errmsg) end +local f = io.open(tmpfile, "w") +f:close() + -- Change access time -assert (lfs.touch (tmpdir, 11)) -local new_att = assert (lfs.attributes (tmpdir)) +assert (lfs.touch (tmpfile, 11)) +local new_att = assert (lfs.attributes (tmpfile)) assert (new_att.access == 11, "could not set access time") 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) --- Remove new directory + +-- Remove new file and directory +assert (os.remove (tmpfile), "could not remove new file") assert (lfs.rmdir (tmpdir), "could not remove new directory") -assert (lfs.mkdir (tmpdir.."/lfs_tmp_dir") == false, "could create a directory inside a non-existent one") +assert (lfs.mkdir (tmpdir..sep.."lfs_tmp_dir") == false, "could create a directory inside a non-existent one") + -- Trying to get attributes of a non-existent file 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") + -- Stressing directory iterator count = 0 for i = 1, 4000 do |