aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test.lua35
1 files changed, 17 insertions, 18 deletions
diff --git a/tests/test.lua b/tests/test.lua
index 7111074..c4911c9 100644
--- a/tests/test.lua
+++ b/tests/test.lua
@@ -1,7 +1,7 @@
1#!/usr/local/bin/lua5.1 1#!/usr/bin/env lua5.1
2 2
3local tmp = "/tmp" 3local tmp = "/tmp"
4local sep = "/" 4local sep = string.match (package.config, "[^\n]+")
5local upper = ".." 5local upper = ".."
6 6
7require"lfs" 7require"lfs"
@@ -69,24 +69,23 @@ local new_att = assert (lfs.attributes (tmpfile))
69assert (new_att.access == testdate2, "could not set access time") 69assert (new_att.access == testdate2, "could not set access time")
70assert (new_att.modification == testdate1, "could not set modification time") 70assert (new_att.modification == testdate1, "could not set modification time")
71 71
72local res, err = lfs.symlinkattributes(tmpfile) 72-- Checking link (does not work on Windows)
73if err ~= "symlinkattributes not supported on this platform" then 73if lfs.link (tmpfile, "_a_link_for_test_", true) then
74 -- Checking symbolic link information (does not work in Windows) 74 assert (lfs.attributes"_a_link_for_test_".mode == "file")
75 assert (os.execute ("ln -s "..tmpfile.." _a_link_for_test_")) 75 assert (lfs.symlinkattributes"_a_link_for_test_".mode == "link")
76 assert (lfs.attributes"_a_link_for_test_".mode == "file") 76 assert (lfs.link (tmpfile, "_a_hard_link_for_test_"))
77 assert (lfs.symlinkattributes"_a_link_for_test_".mode == "link") 77 assert (lfs.attributes (tmpfile, "nlink") == 2)
78 assert (os.remove"_a_link_for_test_") 78 assert (os.remove"_a_link_for_test_")
79 assert (os.remove"_a_hard_link_for_test_")
79end 80end
80 81
81if lfs.setmode then 82-- Checking text/binary modes (only has an effect in Windows)
82 -- Checking text/binary modes (works only in Windows) 83local f = io.open(tmpfile, "w")
83 local f = io.open(tmpfile, "w") 84local result, mode = lfs.setmode(f, "binary")
84 local result, mode = lfs.setmode(f, "binary") 85assert(result) -- on non-Windows platforms, mode is always returned as "binary"
85 assert((result and mode == "text") or (not result and mode == "setmode not supported on this platform")) 86result, mode = lfs.setmode(f, "text")
86 result, mode = lfs.setmode(f, "text") 87assert(result and mode == "binary")
87 assert((result and mode == "binary") or (not result and mode == "setmode not supported on this platform")) 88f:close()
88 f:close()
89end
90 89
91-- Restore access time to current value 90-- Restore access time to current value
92assert (lfs.touch (tmpfile, attrib.access, attrib.modification)) 91assert (lfs.touch (tmpfile, attrib.access, attrib.modification))