diff options
Diffstat (limited to '')
-rw-r--r-- | spec/fs_spec.lua | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/spec/fs_spec.lua b/spec/fs_spec.lua index eb8425e2..66453404 100644 --- a/spec/fs_spec.lua +++ b/spec/fs_spec.lua | |||
@@ -161,11 +161,19 @@ describe("Luarocks fs test #unit", function() | |||
161 | it("does nothing if the argument is a file", function() | 161 | it("does nothing if the argument is a file", function() |
162 | tmpfile1 = get_tmp_path() | 162 | tmpfile1 = get_tmp_path() |
163 | create_file(tmpfile1) | 163 | create_file(tmpfile1) |
164 | assert.falsy(pcall(fs.dir_iterator, tmpfile1)) | 164 | local crt = coroutine.create(fs.dir_iterator) |
165 | while coroutine.status(crt) ~= "dead" do | ||
166 | local ok, val = coroutine.resume(crt, tmpfile1) | ||
167 | assert.falsy(ok and res) | ||
168 | end | ||
165 | end) | 169 | end) |
166 | 170 | ||
167 | it("does nothing if the argument is invalid", function() | 171 | it("does nothing if the argument is invalid", function() |
168 | assert.falsy(pcall(fs.dir_iterator, "/nonexistent")) | 172 | local crt = coroutine.create(fs.dir_iterator) |
173 | while coroutine.status(crt) ~= "dead" do | ||
174 | local ok, val = coroutine.resume(crt, "/nonexistent") | ||
175 | assert.falsy(ok and res) | ||
176 | end | ||
169 | end) | 177 | end) |
170 | end) | 178 | end) |
171 | 179 | ||
@@ -530,11 +538,13 @@ describe("Luarocks fs test #unit", function() | |||
530 | tmpdir = get_tmp_path() | 538 | tmpdir = get_tmp_path() |
531 | lfs.mkdir(tmpdir) | 539 | lfs.mkdir(tmpdir) |
532 | assert.truthy(fs.change_dir(tmpdir)) | 540 | assert.truthy(fs.change_dir(tmpdir)) |
533 | local success = fs.change_dir_to_root() | 541 | assert.truthy(fs.change_dir_to_root()) |
534 | if not is_win then | 542 | if is_win then |
535 | assert.truthy(success) | 543 | local curr_dir = fs.current_dir() |
544 | assert.truthy(curr_dir == "C:\\" or curr_dir == "/") | ||
545 | else | ||
546 | assert.same("/", fs.current_dir()) | ||
536 | end | 547 | end |
537 | assert.same("/", fs.current_dir()) | ||
538 | end) | 548 | end) |
539 | 549 | ||
540 | it("returns false and does nothing if the current directory is not valid #unix", function() | 550 | it("returns false and does nothing if the current directory is not valid #unix", function() |
@@ -749,18 +759,14 @@ describe("Luarocks fs test #unit", function() | |||
749 | end) | 759 | end) |
750 | 760 | ||
751 | it("does nothing if the argument is nonexistent", function() | 761 | it("does nothing if the argument is nonexistent", function() |
752 | assert.falsy(pcall(fs.list_dir("/nonexistent"))) | 762 | assert.same(fs.list_dir("/nonexistent"), {}) |
753 | end) | 763 | end) |
754 | 764 | ||
755 | it("does nothing if the argument doesn't have the proper permissions", function() | 765 | it("does nothing if the argument doesn't have the proper permissions", function() |
756 | tmpdir = get_tmp_path() | 766 | tmpdir = get_tmp_path() |
757 | lfs.mkdir(tmpdir) | 767 | lfs.mkdir(tmpdir) |
758 | make_unreadable(tmpdir) | 768 | make_unreadable(tmpdir) |
759 | if is_win then | 769 | assert.same(fs.list_dir(tmpdir), {}) |
760 | assert.same(fs.list_dir(tmpdir), {}) | ||
761 | else | ||
762 | assert.falsy(pcall(fs.list_dir, tmpdir)) | ||
763 | end | ||
764 | end) | 770 | end) |
765 | end) | 771 | end) |
766 | 772 | ||
@@ -1024,11 +1030,7 @@ describe("Luarocks fs test #unit", function() | |||
1024 | tmpdir = get_tmp_path() | 1030 | tmpdir = get_tmp_path() |
1025 | lfs.mkdir(tmpdir) | 1031 | lfs.mkdir(tmpdir) |
1026 | make_unreadable(tmpdir) | 1032 | make_unreadable(tmpdir) |
1027 | if is_win then | 1033 | assert.same(fs.find(tmpdir), {}) |
1028 | assert.same(fs.find(tmpdir), {}) | ||
1029 | else | ||
1030 | assert.falsy(pcall(fs.find, tmpdir)) | ||
1031 | end | ||
1032 | end) | 1034 | end) |
1033 | end) | 1035 | end) |
1034 | 1036 | ||