From 4e23cb01d902c2e43ed1e2df96f67042962146c2 Mon Sep 17 00:00:00 2001 From: carregal Date: Thu, 17 May 2007 23:08:20 +0000 Subject: 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 --- tests/test.lua | 17 +++++++++-------- 1 file 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") 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..sep.."lfs_tmp_dir" +local tmpdir = current..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) @@ -45,19 +45,20 @@ local f = io.open(tmpfile, "w") f:close() -- Change access time -assert (lfs.touch (tmpfile, 86401)) +local testdate = os.time({ year = 2007, day = 10, month = 2}) +assert (lfs.touch (tmpfile, testdate)) local new_att = assert (lfs.attributes (tmpfile)) -assert (new_att.access == 86401, "could not set access time") -assert (new_att.modification == 86401, "could not set modification time") +assert (new_att.access == testdate, "could not set access time") +assert (new_att.modification == testdate, "could not set modification time") -- Change access and modification time -assert (lfs.touch (tmpfile, 86403, 86402)) +assert (lfs.touch (tmpfile, testdate + 2, testdate + 1)) local new_att = assert (lfs.attributes (tmpfile)) -assert (new_att.access == 86403, "could not set access time") -assert (new_att.modification == 86402, "could not set modification time") +assert (new_att.access == testdate + 2, "could not set access time") +assert (new_att.modification == testdate + 1, "could not set modification time") -- Restore access time to current value -assert (lfs.touch (tmpfile)) +assert (lfs.touch (tmpfile, attrib.access, attrib.modification)) new_att = assert (lfs.attributes (tmpfile)) assert (new_att.access == attrib.access) assert (new_att.modification == attrib.modification) -- cgit v1.2.3-55-g6feb