diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test.lua | 35 |
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 | ||
3 | local tmp = "/tmp" | 3 | local tmp = "/tmp" |
4 | local sep = "/" | 4 | local sep = string.match (package.config, "[^\n]+") |
5 | local upper = ".." | 5 | local upper = ".." |
6 | 6 | ||
7 | require"lfs" | 7 | require"lfs" |
@@ -69,24 +69,23 @@ local new_att = assert (lfs.attributes (tmpfile)) | |||
69 | assert (new_att.access == testdate2, "could not set access time") | 69 | assert (new_att.access == testdate2, "could not set access time") |
70 | assert (new_att.modification == testdate1, "could not set modification time") | 70 | assert (new_att.modification == testdate1, "could not set modification time") |
71 | 71 | ||
72 | local res, err = lfs.symlinkattributes(tmpfile) | 72 | -- Checking link (does not work on Windows) |
73 | if err ~= "symlinkattributes not supported on this platform" then | 73 | if 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_") | ||
79 | end | 80 | end |
80 | 81 | ||
81 | if lfs.setmode then | 82 | -- Checking text/binary modes (only has an effect in Windows) |
82 | -- Checking text/binary modes (works only in Windows) | 83 | local f = io.open(tmpfile, "w") |
83 | local f = io.open(tmpfile, "w") | 84 | local result, mode = lfs.setmode(f, "binary") |
84 | local result, mode = lfs.setmode(f, "binary") | 85 | assert(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")) | 86 | result, mode = lfs.setmode(f, "text") |
86 | result, mode = lfs.setmode(f, "text") | 87 | assert(result and mode == "binary") |
87 | assert((result and mode == "binary") or (not result and mode == "setmode not supported on this platform")) | 88 | f:close() |
88 | f:close() | ||
89 | end | ||
90 | 89 | ||
91 | -- Restore access time to current value | 90 | -- Restore access time to current value |
92 | assert (lfs.touch (tmpfile, attrib.access, attrib.modification)) | 91 | assert (lfs.touch (tmpfile, attrib.access, attrib.modification)) |