diff options
author | George Roman <george.roman.99@gmail.com> | 2018-07-07 18:49:41 +0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-07-16 20:34:30 -0300 |
commit | 4b3ee931cd8ecc5937811cd8e9316d79c0c9c00e (patch) | |
tree | 9b5f36a8f75df296b1bace3413eb4967d9325729 /spec | |
parent | 1b3b6525a4313404af84fce0fbbc29695e664f73 (diff) | |
download | luarocks-4b3ee931cd8ecc5937811cd8e9316d79c0c9c00e.tar.gz luarocks-4b3ee931cd8ecc5937811cd8e9316d79c0c9c00e.tar.bz2 luarocks-4b3ee931cd8ecc5937811cd8e9316d79c0c9c00e.zip |
Add general improvements to the fs module
Diffstat (limited to 'spec')
-rw-r--r-- | spec/fs_spec.lua | 36 | ||||
-rw-r--r-- | spec/remove_spec.lua | 34 |
2 files changed, 36 insertions, 34 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 | ||
diff --git a/spec/remove_spec.lua b/spec/remove_spec.lua index 55264a75..f43b55c6 100644 --- a/spec/remove_spec.lua +++ b/spec/remove_spec.lua | |||
@@ -7,9 +7,9 @@ test_env.unload_luarocks() | |||
7 | 7 | ||
8 | local extra_rocks = { | 8 | local extra_rocks = { |
9 | "/abelhas-1.1-1.rockspec", | 9 | "/abelhas-1.1-1.rockspec", |
10 | "/lualogging-1.3.0-1.src.rock", | 10 | "/copas-2.0.1-1.src.rock", |
11 | "/luasocket-3.0rc1-2.src.rock", | 11 | "/coxpcall-1.16.0-1.src.rock", |
12 | "/luasocket-3.0rc1-2.rockspec" | 12 | "/coxpcall-1.16.0-1.rockspec" |
13 | } | 13 | } |
14 | 14 | ||
15 | describe("LuaRocks remove tests #integration", function() | 15 | describe("LuaRocks remove tests #integration", function() |
@@ -52,38 +52,38 @@ describe("LuaRocks remove tests #integration", function() | |||
52 | 52 | ||
53 | describe("LuaRocks remove more complex tests", function() | 53 | describe("LuaRocks remove more complex tests", function() |
54 | before_each(function() | 54 | before_each(function() |
55 | assert.is.truthy(test_env.need_rock("luasocket")) | 55 | assert.is.truthy(test_env.need_rock("coxpcall")) |
56 | end) | 56 | end) |
57 | 57 | ||
58 | it("LuaRocks remove fail, break dependencies", function() | 58 | it("LuaRocks remove fail, break dependencies", function() |
59 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasocket")) | 59 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/coxpcall")) |
60 | assert.is_true(run.luarocks_bool("build lualogging")) | 60 | assert.is_true(run.luarocks_bool("build copas")) |
61 | 61 | ||
62 | assert.is_false(run.luarocks_bool("remove luasocket")) | 62 | assert.is_false(run.luarocks_bool("remove coxpcall")) |
63 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasocket")) | 63 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/coxpcall")) |
64 | end) | 64 | end) |
65 | 65 | ||
66 | it("LuaRocks remove force", function() | 66 | it("LuaRocks remove force", function() |
67 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasocket")) | 67 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/coxpcall")) |
68 | assert.is_true(run.luarocks_bool("build lualogging")) | 68 | assert.is_true(run.luarocks_bool("build copas")) |
69 | 69 | ||
70 | local output = run.luarocks("remove --force luasocket") | 70 | local output = run.luarocks("remove --force coxpcall") |
71 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasocket")) | 71 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/coxpcall")) |
72 | assert.is.truthy(output:find("Checking stability of dependencies")) | 72 | assert.is.truthy(output:find("Checking stability of dependencies")) |
73 | end) | 73 | end) |
74 | 74 | ||
75 | it("LuaRocks remove force fast", function() | 75 | it("LuaRocks remove force fast", function() |
76 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasocket")) | 76 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/coxpcall")) |
77 | assert.is_true(run.luarocks_bool("build lualogging")) | 77 | assert.is_true(run.luarocks_bool("build copas")) |
78 | 78 | ||
79 | local output = run.luarocks("remove --force-fast luasocket") | 79 | local output = run.luarocks("remove --force-fast coxpcall") |
80 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasocket")) | 80 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/coxpcall")) |
81 | assert.is.falsy(output:find("Checking stability of dependencies")) | 81 | assert.is.falsy(output:find("Checking stability of dependencies")) |
82 | end) | 82 | end) |
83 | end) | 83 | end) |
84 | 84 | ||
85 | it("#admin remove #ssh", function() | 85 | it("#admin remove #ssh", function() |
86 | assert.is_true(run.luarocks_admin_bool("--server=testing remove luasocket-3.0rc1-2.src.rock")) | 86 | assert.is_true(run.luarocks_admin_bool("--server=testing remove coxpcall-1.16.0-1.src.rock")) |
87 | end) | 87 | end) |
88 | 88 | ||
89 | it("#admin remove missing", function() | 89 | it("#admin remove missing", function() |