aboutsummaryrefslogtreecommitdiff
path: root/tests/test.lua
diff options
context:
space:
mode:
authorcarregal <carregal>2007-05-17 23:08:20 +0000
committercarregal <carregal>2007-05-17 23:08:20 +0000
commit4e23cb01d902c2e43ed1e2df96f67042962146c2 (patch)
treec295551ea11652df22a7e0b71030bdc32c233e86 /tests/test.lua
parent7ee2d8e1b24a0ae3f671fc852e42301c017f0576 (diff)
downloadluafilesystem-4e23cb01d902c2e43ed1e2df96f67042962146c2.tar.gz
luafilesystem-4e23cb01d902c2e43ed1e2df96f67042962146c2.tar.bz2
luafilesystem-4e23cb01d902c2e43ed1e2df96f67042962146c2.zip
Corrected 1 of 2 bugs on the test script found by Shmuel Zeigerman: the use of /tmp as a necessary directory.
Corrected a bug on the test script on slow fliesystems due to the reliance on close times
Diffstat (limited to 'tests/test.lua')
-rw-r--r--tests/test.lua17
1 files changed, 9 insertions, 8 deletions
diff --git a/tests/test.lua b/tests/test.lua
index 70f90d5..cf1e573 100644
--- a/tests/test.lua
+++ b/tests/test.lua
@@ -34,7 +34,7 @@ assert (lfs.currentdir() == current, "error trying to change directories")
34assert (lfs.chdir ("this couldn't be an actual directory") == nil, "could change to a non-existent directory") 34assert (lfs.chdir ("this couldn't be an actual directory") == nil, "could change to a non-existent directory")
35 35
36-- Changing creating and removing directories 36-- Changing creating and removing directories
37local tmpdir = tmp..sep.."lfs_tmp_dir" 37local tmpdir = current..sep.."lfs_tmp_dir"
38local tmpfile = tmpdir..sep.."tmp_file" 38local tmpfile = tmpdir..sep.."tmp_file"
39assert (lfs.mkdir (tmpdir), "could not make a new directory") 39assert (lfs.mkdir (tmpdir), "could not make a new directory")
40local attrib, errmsg = lfs.attributes (tmpdir) 40local attrib, errmsg = lfs.attributes (tmpdir)
@@ -45,19 +45,20 @@ local f = io.open(tmpfile, "w")
45f:close() 45f:close()
46 46
47-- Change access time 47-- Change access time
48assert (lfs.touch (tmpfile, 86401)) 48local testdate = os.time({ year = 2007, day = 10, month = 2})
49assert (lfs.touch (tmpfile, testdate))
49local new_att = assert (lfs.attributes (tmpfile)) 50local new_att = assert (lfs.attributes (tmpfile))
50assert (new_att.access == 86401, "could not set access time") 51assert (new_att.access == testdate, "could not set access time")
51assert (new_att.modification == 86401, "could not set modification time") 52assert (new_att.modification == testdate, "could not set modification time")
52 53
53-- Change access and modification time 54-- Change access and modification time
54assert (lfs.touch (tmpfile, 86403, 86402)) 55assert (lfs.touch (tmpfile, testdate + 2, testdate + 1))
55local new_att = assert (lfs.attributes (tmpfile)) 56local new_att = assert (lfs.attributes (tmpfile))
56assert (new_att.access == 86403, "could not set access time") 57assert (new_att.access == testdate + 2, "could not set access time")
57assert (new_att.modification == 86402, "could not set modification time") 58assert (new_att.modification == testdate + 1, "could not set modification time")
58 59
59-- Restore access time to current value 60-- Restore access time to current value
60assert (lfs.touch (tmpfile)) 61assert (lfs.touch (tmpfile, attrib.access, attrib.modification))
61new_att = assert (lfs.attributes (tmpfile)) 62new_att = assert (lfs.attributes (tmpfile))
62assert (new_att.access == attrib.access) 63assert (new_att.access == attrib.access)
63assert (new_att.modification == attrib.modification) 64assert (new_att.modification == attrib.modification)