diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test.lua | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/tests/test.lua b/tests/test.lua index 25a3fd3..7f981e5 100644 --- a/tests/test.lua +++ b/tests/test.lua | |||
@@ -32,9 +32,31 @@ assert (lfs.chdir (reldir), "could not change back to current directory") | |||
32 | assert (lfs.currentdir() == current, "error trying to change directories") | 32 | assert (lfs.currentdir() == current, "error trying to change directories") |
33 | assert (lfs.chdir ("this couldn't be an actual directory") == nil, "could change to a non-existent directory") | 33 | assert (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 |
35 | assert (lfs.mkdir (tmp.."/lfs_tmp_dir"), "could not make a new directory") | 35 | local tmpdir = tmp.."/lfs_tmp_dir" |
36 | assert (os.remove (tmp.."/lfs_tmp_dir"), "could not remove new directory") | 36 | assert (lfs.mkdir (tmpdir), "could not make a new directory") |
37 | assert (lfs.mkdir (tmp.."/lfs_tmp_dir/lfs_tmp_dir") == false, "could create a directory inside a non-existent one") | 37 | local attrib, errmsg = lfs.attributes (tmpdir) |
38 | if not attrib then | ||
39 | error ("could not get attributes of file `"..tmpdir.."':\n"..errmsg) | ||
40 | else | ||
41 | -- Change access time | ||
42 | assert (lfs.touch (tmpdir, 11)) | ||
43 | local new_att = assert (lfs.attributes (tmpdir)) | ||
44 | assert (new_att.access == 11, "could not set access time") | ||
45 | assert (new_att.modification == 11, "could not set modification time") | ||
46 | -- Change access and modification time | ||
47 | assert (lfs.touch (tmpdir, 33, 22)) | ||
48 | local new_att = assert (lfs.attributes (tmpdir)) | ||
49 | assert (new_att.access == 33, "could not set access time") | ||
50 | assert (new_att.modification == 22, "could not set modification time") | ||
51 | -- Restore access time to current value | ||
52 | assert (lfs.touch (tmpdir)) | ||
53 | new_att = assert (lfs.attributes (tmpdir)) | ||
54 | assert (new_att.access == attrib.access) | ||
55 | assert (new_att.modification == attrib.modification) | ||
56 | end | ||
57 | assert (os.remove (tmpdir), "could not remove new directory") | ||
58 | assert (lfs.mkdir (tmpdir.."/lfs_tmp_dir") == false, "could create a directory inside a non-existent one") | ||
38 | -- | 59 | -- |
39 | assert (lfs.attributes ("this couldn't be an actual file") == nil, "could get attributes of a non-existent file") | 60 | assert (lfs.attributes ("this couldn't be an actual file") == nil, "could get attributes of a non-existent file") |
40 | assert (type(lfs.attributes (upper)) == "table", "couldn't get attributes of upper directory") | 61 | assert (type(lfs.attributes (upper)) == "table", "couldn't get attributes of upper directory") |
62 | print"Ok!" | ||