diff options
author | carregal <carregal> | 2007-05-18 18:04:46 +0000 |
---|---|---|
committer | carregal <carregal> | 2007-05-18 18:04:46 +0000 |
commit | d3e7a0ed127cd81c057ed174615361f518056d28 (patch) | |
tree | 22f55b0aca22c423cffd15030a2626c81882d4dd /tests/test.lua | |
parent | 6a22c3e728e3421c446625dd98444968f2cdd9fa (diff) | |
download | luafilesystem-d3e7a0ed127cd81c057ed174615361f518056d28.tar.gz luafilesystem-d3e7a0ed127cd81c057ed174615361f518056d28.tar.bz2 luafilesystem-d3e7a0ed127cd81c057ed174615361f518056d28.zip |
Corrected the second of 2 bugs on the test script found by Shmuel Zeigerman involving the access and update time on lfs.touch()
Diffstat (limited to 'tests/test.lua')
-rw-r--r-- | tests/test.lua | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/tests/test.lua b/tests/test.lua index cf1e573..94338b0 100644 --- a/tests/test.lua +++ b/tests/test.lua | |||
@@ -36,6 +36,15 @@ assert (lfs.chdir ("this couldn't be an actual directory") == nil, "could change | |||
36 | -- Changing creating and removing directories | 36 | -- Changing creating and removing directories |
37 | local tmpdir = current..sep.."lfs_tmp_dir" | 37 | local tmpdir = current..sep.."lfs_tmp_dir" |
38 | local tmpfile = tmpdir..sep.."tmp_file" | 38 | local tmpfile = tmpdir..sep.."tmp_file" |
39 | -- Test for existence of a previous lfs_tmp_dir | ||
40 | -- that may have resulted from an interrupted test execution and remove it | ||
41 | if lfs.chdir (tmpdir) then | ||
42 | assert (lfs.chdir (upper), "could not change to upper directory") | ||
43 | assert (os.remove (tmpfile), "could not remove file from previous test") | ||
44 | assert (lfs.rmdir (tmpdir), "could not remove directory from previous test") | ||
45 | end | ||
46 | |||
47 | -- tries to create a directory | ||
39 | assert (lfs.mkdir (tmpdir), "could not make a new directory") | 48 | assert (lfs.mkdir (tmpdir), "could not make a new directory") |
40 | local attrib, errmsg = lfs.attributes (tmpdir) | 49 | local attrib, errmsg = lfs.attributes (tmpdir) |
41 | if not attrib then | 50 | if not attrib then |
@@ -45,17 +54,20 @@ local f = io.open(tmpfile, "w") | |||
45 | f:close() | 54 | f:close() |
46 | 55 | ||
47 | -- Change access time | 56 | -- Change access time |
48 | local testdate = os.time({ year = 2007, day = 10, month = 2}) | 57 | local testdate = os.time({ year = 2007, day = 10, month = 2, hour=0}) |
49 | assert (lfs.touch (tmpfile, testdate)) | 58 | assert (lfs.touch (tmpfile, testdate)) |
50 | local new_att = assert (lfs.attributes (tmpfile)) | 59 | local new_att = assert (lfs.attributes (tmpfile)) |
51 | assert (new_att.access == testdate, "could not set access time") | 60 | assert (new_att.access == testdate, "could not set access time") |
52 | assert (new_att.modification == testdate, "could not set modification time") | 61 | assert (new_att.modification == testdate, "could not set modification time") |
53 | 62 | ||
54 | -- Change access and modification time | 63 | -- Change access and modification time |
55 | assert (lfs.touch (tmpfile, testdate + 2, testdate + 1)) | 64 | local testdate1 = os.time({ year = 2007, day = 10, month = 2, hour=0}) |
65 | local testdate2 = os.time({ year = 2007, day = 11, month = 2, hour=0}) | ||
66 | |||
67 | assert (lfs.touch (tmpfile, testdate2, testdate1)) | ||
56 | local new_att = assert (lfs.attributes (tmpfile)) | 68 | local new_att = assert (lfs.attributes (tmpfile)) |
57 | assert (new_att.access == testdate + 2, "could not set access time") | 69 | assert (new_att.access == testdate2, "could not set access time") |
58 | assert (new_att.modification == testdate + 1, "could not set modification time") | 70 | assert (new_att.modification == testdate1, "could not set modification time") |
59 | 71 | ||
60 | -- Restore access time to current value | 72 | -- Restore access time to current value |
61 | assert (lfs.touch (tmpfile, attrib.access, attrib.modification)) | 73 | assert (lfs.touch (tmpfile, attrib.access, attrib.modification)) |