diff options
author | robooo <robo.karasek@gmail.com> | 2016-07-07 21:58:19 +0200 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2016-07-07 16:58:19 -0300 |
commit | 5af7e0d7c2dcf65e41ae8523f3771e9528be32a7 (patch) | |
tree | bcd14624e0566a23da2e708675197d212cecf35d /spec | |
parent | b5b285a678fe78b80d452cc9eb7565b8bf087b81 (diff) | |
download | luarocks-5af7e0d7c2dcf65e41ae8523f3771e9528be32a7.tar.gz luarocks-5af7e0d7c2dcf65e41ae8523f3771e9528be32a7.tar.bz2 luarocks-5af7e0d7c2dcf65e41ae8523f3771e9528be32a7.zip |
New test-suite for LuaRocks (#581)
First version of new test-suite, using Busted framework based on Google Summer of Code project:
https://summerofcode.withgoogle.com/projects/#5695811874717696
* Rewritten from Bash to Lua
* Tests now check if they did what they were supposed to, beyond only checking success or failure of the `luarocks` command
* Support for black-box (launching `luarocks` as an external command) and white-box (testing functions in modules directly) testing
Diffstat (limited to 'spec')
-rw-r--r-- | spec/add_spec.lua | 46 | ||||
-rw-r--r-- | spec/build_spec.lua | 182 | ||||
-rw-r--r-- | spec/config_spec.lua | 90 | ||||
-rw-r--r-- | spec/deps_spec.lua | 115 | ||||
-rw-r--r-- | spec/doc_spec.lua | 57 | ||||
-rw-r--r-- | spec/download_spec.lua | 37 | ||||
-rw-r--r-- | spec/fetch_spec.lua | 16 | ||||
-rw-r--r-- | spec/help_spec.lua | 29 | ||||
-rw-r--r-- | spec/install_spec.lua | 130 | ||||
-rw-r--r-- | spec/lint_spec.lua | 51 | ||||
-rw-r--r-- | spec/list_spec.lua | 41 | ||||
-rw-r--r-- | spec/make_manifest_spec.lua | 19 | ||||
-rw-r--r-- | spec/make_spec.lua | 99 | ||||
-rw-r--r-- | spec/new_version_spec.lua | 53 | ||||
-rw-r--r-- | spec/pack_spec.lua | 35 | ||||
-rw-r--r-- | spec/path_spec.lua | 28 | ||||
-rw-r--r-- | spec/purge_spec.lua | 30 | ||||
-rw-r--r-- | spec/refresh_cache_spec.lua | 19 | ||||
-rw-r--r-- | spec/remove_spec.lua | 85 | ||||
-rw-r--r-- | spec/search_spec.lua | 42 | ||||
-rw-r--r-- | spec/show_spec.lua | 56 | ||||
-rw-r--r-- | spec/unpack_spec.lua | 61 | ||||
-rw-r--r-- | spec/upload_spec.lua | 41 | ||||
-rw-r--r-- | spec/util_spec.lua | 96 | ||||
-rw-r--r-- | spec/write_rockspec_spec.lua | 74 |
25 files changed, 1532 insertions, 0 deletions
diff --git a/spec/add_spec.lua b/spec/add_spec.lua new file mode 100644 index 00000000..e417f974 --- /dev/null +++ b/spec/add_spec.lua | |||
@@ -0,0 +1,46 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local lfs = require("lfs") | ||
3 | |||
4 | test_env.unload_luarocks() | ||
5 | local add = require("luarocks.add") | ||
6 | |||
7 | local extra_rocks = { | ||
8 | "/luasocket-3.0rc1-1.src.rock", | ||
9 | "/luasocket-3.0rc1-1.rockspec" | ||
10 | } | ||
11 | |||
12 | expose("LuaRocks add tests #blackbox #b_add", function() | ||
13 | |||
14 | before_each(function() | ||
15 | test_env.setup_specs(extra_rocks) | ||
16 | testing_paths = test_env.testing_paths | ||
17 | run = test_env.run | ||
18 | end) | ||
19 | |||
20 | describe("LuaRocks-admin add tests", function() | ||
21 | it("LuaRocks-admin add invalid rock #ssh", function() | ||
22 | assert.is_false(run.luarocks_admin_bool("--server=testing add invalid")) | ||
23 | end) | ||
24 | |||
25 | it("LuaRocks-admin add missing argument", function() | ||
26 | assert.is_false(run.luarocks_admin_bool("--server=testing add")) | ||
27 | end) | ||
28 | |||
29 | it("LuaRocks-admin add invalid server", function() | ||
30 | assert.is_false(run.luarocks_admin_bool("--server=invalid add " .. testing_paths.testing_server .. "/luasocket-3.0rc1-1.src.rock")) | ||
31 | end) | ||
32 | |||
33 | it("LuaRocks-admin add invalid server #ssh", function() | ||
34 | assert.is_true(run.luarocks_admin_bool("--server=testing add " .. testing_paths.testing_server .. "/luasocket-3.0rc1-1.src.rock")) | ||
35 | end) | ||
36 | |||
37 | --TODO This test fails, sftp not implemented | ||
38 | it("LuaRocks-admin add invalid server", function() --? | ||
39 | assert.is_false(run.luarocks_admin_bool("--server=testing add luasocket-3.0rc1-1.src.rock", { LUAROCKS_CONFIG = testing_paths.testing_dir .. "/testing_config_sftp.lua" } )) | ||
40 | end) | ||
41 | |||
42 | it("LuaRocks-admin add, split server url", function() | ||
43 | assert.is_false(run.luarocks_admin_bool("--server=\"localhost@/tmp/luarocks_testing\" add " .. testing_paths.testing_server .. "luasocket-3.0rc1-1.src.rock")) | ||
44 | end) | ||
45 | end) | ||
46 | end) \ No newline at end of file | ||
diff --git a/spec/build_spec.lua b/spec/build_spec.lua new file mode 100644 index 00000000..6665de0b --- /dev/null +++ b/spec/build_spec.lua | |||
@@ -0,0 +1,182 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local lfs = require("lfs") | ||
3 | |||
4 | test_env.unload_luarocks() | ||
5 | local build = require("luarocks.build") | ||
6 | |||
7 | local extra_rocks = { | ||
8 | "/lmathx-20120430.51-1.src.rock", | ||
9 | "/lmathx-20120430.51-1.rockspec", | ||
10 | "/lmathx-20120430.52-1.src.rock", | ||
11 | "/lmathx-20120430.52-1.rockspec", | ||
12 | "/lmathx-20150505-1.src.rock", | ||
13 | "/lmathx-20150505-1.rockspec", | ||
14 | "/lpeg-0.12-1.src.rock", | ||
15 | "/lpty-1.0.1-1.src.rock", | ||
16 | "/luadoc-3.0.1-1.src.rock", | ||
17 | "/luafilesystem-1.6.3-1.src.rock", | ||
18 | "/lualogging-1.3.0-1.src.rock", | ||
19 | "/luarepl-0.4-1.src.rock", | ||
20 | "/luasec-0.6-1.rockspec", | ||
21 | "/luasocket-3.0rc1-1.src.rock", | ||
22 | "/luasocket-3.0rc1-1.rockspec", | ||
23 | "/lxsh-0.8.6-2.src.rock", | ||
24 | "/lxsh-0.8.6-2.rockspec", | ||
25 | "/stdlib-41.0.0-1.src.rock", | ||
26 | "/validate-args-1.5.4-1.rockspec" | ||
27 | } | ||
28 | |||
29 | expose("LuaRocks build tests #blackbox #b_build", function() | ||
30 | |||
31 | before_each(function() | ||
32 | test_env.setup_specs(extra_rocks) | ||
33 | testing_paths = test_env.testing_paths | ||
34 | run = test_env.run | ||
35 | end) | ||
36 | |||
37 | describe("LuaRocks build - basic testing set", function() | ||
38 | it("LuaRocks build with no flags/arguments", function() | ||
39 | assert.is_false(run.luarocks_bool("build")) | ||
40 | end) | ||
41 | |||
42 | it("LuaRocks build invalid", function() | ||
43 | assert.is_false(run.luarocks_bool("build invalid")) | ||
44 | end) | ||
45 | end) | ||
46 | |||
47 | describe("LuaRocks build - building lpeg with flags", function() | ||
48 | it("LuaRocks build fail build permissions", function() | ||
49 | if test_env.TEST_TARGET_OS == "osx" or test_env.TEST_TARGET_OS == "linux" then | ||
50 | assert.is_false(run.luarocks_bool("build --tree=/usr lpeg")) | ||
51 | end | ||
52 | end) | ||
53 | |||
54 | it("LuaRocks build fail build permissions parent", function() | ||
55 | if test_env.TEST_TARGET_OS == "osx" or test_env.TEST_TARGET_OS == "linux" then | ||
56 | assert.is_false(run.luarocks_bool("build --tree=/usr/invalid lpeg")) | ||
57 | end | ||
58 | end) | ||
59 | |||
60 | it("LuaRocks build lpeg verbose", function() | ||
61 | assert.is_true(run.luarocks_bool("build --verbose lpeg")) | ||
62 | end) | ||
63 | |||
64 | it("LuaRocks build lpeg branch=master", function() | ||
65 | assert.is_true(run.luarocks_bool("build --branch=master lpeg")) | ||
66 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | ||
67 | end) | ||
68 | |||
69 | it("LuaRocks build lpeg deps-mode=123", function() | ||
70 | assert.is_false(run.luarocks_bool("build --deps-mode=123 lpeg")) | ||
71 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | ||
72 | end) | ||
73 | |||
74 | it("LuaRocks build lpeg only-sources example", function() | ||
75 | assert.is_true(run.luarocks_bool("build --only-sources=\"http://example.com\" lpeg")) | ||
76 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | ||
77 | end) | ||
78 | |||
79 | it("LuaRocks build lpeg with empty tree", function() | ||
80 | assert.is_false(run.luarocks_bool("build --tree=\"\" lpeg")) | ||
81 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | ||
82 | end) | ||
83 | end) | ||
84 | |||
85 | describe("LuaRocks build - basic builds", function() | ||
86 | |||
87 | it("LuaRocks build luadoc", function() | ||
88 | assert.is_true(run.luarocks_bool("build luadoc")) | ||
89 | end) | ||
90 | |||
91 | it("LuaRocks build luacov diff version", function() | ||
92 | assert.is_true(run.luarocks_bool("build luacov 0.11.0-1")) | ||
93 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luacov")) | ||
94 | end) | ||
95 | |||
96 | it("LuaRocks build command stdlib", function() | ||
97 | assert.is_true(run.luarocks_bool("build stdlib")) | ||
98 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/stdlib")) | ||
99 | end) | ||
100 | |||
101 | it("LuaRocks build install bin luarepl", function() | ||
102 | assert.is_true(run.luarocks_bool("build luarepl")) | ||
103 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luarepl")) | ||
104 | end) | ||
105 | |||
106 | it("LuaRocks build supported platforms lpty", function() | ||
107 | assert.is_true(run.luarocks_bool("build lpty")) | ||
108 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpty")) | ||
109 | end) | ||
110 | |||
111 | it("LuaRocks build luasec with skipping dependency checks", function() | ||
112 | assert.is_true(run.luarocks_bool("build luasec --nodeps")) | ||
113 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec")) | ||
114 | end) | ||
115 | |||
116 | it("LuaRocks build lmathx deps partial match", function() | ||
117 | assert.is_true(run.luarocks_bool("build lmathx")) | ||
118 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lmathx")) | ||
119 | end) | ||
120 | end) | ||
121 | |||
122 | describe("LuaRocks build - more complex tests", function() | ||
123 | |||
124 | it("LuaRocks build luacheck show downloads test_config", function() | ||
125 | local out = run.luarocks("build luacheck", { LUAROCKS_CONFIG = testing_paths.testing_dir .. "/testing_config_show_downloads.lua"} ) | ||
126 | print(out) | ||
127 | end) | ||
128 | |||
129 | it("LuaRocks build luasec only deps", function() | ||
130 | assert.is_true(run.luarocks_bool("build luasec --only-deps")) | ||
131 | assert.is_false(run.luarocks_bool("show luasec")) | ||
132 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec")) | ||
133 | end) | ||
134 | |||
135 | it("LuaRocks build only deps of downloaded rockspec of lxsh", function() | ||
136 | assert.is_true(run.luarocks_bool("download --rockspec lxsh 0.8.6-2")) | ||
137 | assert.is_true(run.luarocks_bool("build lxsh-0.8.6-2.rockspec --only-deps")) | ||
138 | assert.is_false(run.luarocks_bool("show lxsh")) | ||
139 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
140 | assert.is_true(os.remove("lxsh-0.8.6-2.rockspec")) | ||
141 | end) | ||
142 | |||
143 | it("LuaRocks build only deps of downloaded rock of lxsh", function() | ||
144 | assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6-2")) | ||
145 | assert.is_true(run.luarocks_bool("build lxsh-0.8.6-2.src.rock --only-deps")) | ||
146 | assert.is_false(run.luarocks_bool("show lxsh")) | ||
147 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
148 | assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) | ||
149 | end) | ||
150 | |||
151 | it("LuaRocks build no https", function() | ||
152 | assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1")) | ||
153 | assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec")) | ||
154 | |||
155 | assert.is_true(run.luarocks_bool("show validate-args")) | ||
156 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/validate-args")) | ||
157 | |||
158 | assert.is_true(os.remove("validate-args-1.5.4-1.rockspec")) | ||
159 | end) | ||
160 | |||
161 | it("LuaRocks build with https", function() | ||
162 | assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1")) | ||
163 | assert.is_true(run.luarocks_bool("install luasec")) | ||
164 | assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec")) | ||
165 | |||
166 | assert.is_true(run.luarocks_bool("show validate-args")) | ||
167 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/validate-args")) | ||
168 | |||
169 | assert.is_true(os.remove("validate-args-1.5.4-1.rockspec")) | ||
170 | end) | ||
171 | |||
172 | it("LuaRocks build missing external", function() | ||
173 | assert.is_true(test_env.need_luasocket()) | ||
174 | assert.is_false(run.luarocks_bool("build " .. testing_paths.testing_dir .. "/testfiles/missing_external-0.1-1.rockspec INEXISTENT_INCDIR=\"/invalid/dir\"")) | ||
175 | end) | ||
176 | |||
177 | it("LuaRocks build invalid patch", function() | ||
178 | assert.is_true(test_env.need_luasocket()) | ||
179 | assert.is_false(run.luarocks_bool("build " .. testing_paths.testing_dir .. "/testfiles/invalid_patch-0.1-1.rockspec")) | ||
180 | end) | ||
181 | end) | ||
182 | end) | ||
diff --git a/spec/config_spec.lua b/spec/config_spec.lua new file mode 100644 index 00000000..f6cabd8c --- /dev/null +++ b/spec/config_spec.lua | |||
@@ -0,0 +1,90 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local lfs = require("lfs") | ||
3 | |||
4 | test_env.unload_luarocks() | ||
5 | local cfg = require("luarocks.cfg") | ||
6 | |||
7 | expose("LuaRocks config tests #blackbox #b_config", function() | ||
8 | |||
9 | before_each(function() | ||
10 | test_env.setup_specs(extra_rocks) | ||
11 | test_env.unload_luarocks() -- need to be required here, because site_config is created after first loading of specs | ||
12 | site_config = require("luarocks.site_config") | ||
13 | testing_paths = test_env.testing_paths | ||
14 | run = test_env.run | ||
15 | end) | ||
16 | |||
17 | describe("LuaRocks config - basic tests", function() | ||
18 | it("LuaRocks config with no flags/arguments", function() | ||
19 | assert.is_false(run.luarocks_bool("config")) | ||
20 | end) | ||
21 | |||
22 | it("LuaRocks config include dir", function() | ||
23 | local output = run.luarocks("config --lua-incdir") | ||
24 | assert.are.same(output, site_config.LUA_INCDIR) | ||
25 | end) | ||
26 | |||
27 | it("LuaRocks config library dir", function() | ||
28 | local output = run.luarocks("config --lua-libdir") | ||
29 | assert.are.same(output, site_config.LUA_LIBDIR) | ||
30 | end) | ||
31 | |||
32 | it("LuaRocks config lua version", function() | ||
33 | local output = run.luarocks("config --lua-ver") | ||
34 | local lua_version = _VERSION:gsub("Lua ", "") | ||
35 | if test_env.LUAJIT_V then | ||
36 | lua_version = "5.1" | ||
37 | end | ||
38 | assert.are.same(output, lua_version) | ||
39 | end) | ||
40 | |||
41 | it("LuaRocks config rock trees", function() | ||
42 | assert.is_true(run.luarocks_bool("config --rock-trees")) | ||
43 | end) | ||
44 | |||
45 | it("LuaRocks config user config", function() | ||
46 | local user_config_path = run.luarocks("config --user-config") | ||
47 | assert.is.truthy(lfs.attributes(user_config_path)) | ||
48 | end) | ||
49 | |||
50 | it("LuaRocks config missing user config", function() | ||
51 | assert.is_false(run.luarocks_bool("config --user-config", {LUAROCKS_CONFIG = "missing_file.lua"})) | ||
52 | end) | ||
53 | end) | ||
54 | |||
55 | describe("LuaRocks config - more complex tests", function() | ||
56 | it("LuaRocks fail system config", function() | ||
57 | os.remove(testing_paths.testing_lrprefix .. "/etc/luarocks/config.lua") | ||
58 | assert.is_false(run.luarocks_bool("config --system-config;")) | ||
59 | end) | ||
60 | |||
61 | it("LuaRocks system config", function() | ||
62 | local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" | ||
63 | lfs.mkdir(testing_paths.testing_lrprefix) | ||
64 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") | ||
65 | lfs.mkdir(scdir) | ||
66 | |||
67 | local sysconfig = io.open(scdir .. "/config.lua", "w+") | ||
68 | sysconfig:write(" ") | ||
69 | sysconfig:close() | ||
70 | |||
71 | local output = run.luarocks("config --system-config;") | ||
72 | assert.are.same(output, scdir .. "/config.lua") | ||
73 | test_env.remove_dir(testing_paths.testing_lrprefix) | ||
74 | end) | ||
75 | |||
76 | it("LuaRocks fail system config invalid", function() | ||
77 | local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" | ||
78 | lfs.mkdir(testing_paths.testing_lrprefix) | ||
79 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") | ||
80 | lfs.mkdir(scdir) | ||
81 | |||
82 | local sysconfig = io.open(scdir .. "/config.lua", "w+") | ||
83 | sysconfig:write("if if if") | ||
84 | sysconfig:close() | ||
85 | |||
86 | assert.is_false(run.luarocks_bool("config --system-config;")) | ||
87 | test_env.remove_dir(testing_paths.testing_lrprefix) | ||
88 | end) | ||
89 | end) | ||
90 | end) \ No newline at end of file | ||
diff --git a/spec/deps_spec.lua b/spec/deps_spec.lua new file mode 100644 index 00000000..ce784080 --- /dev/null +++ b/spec/deps_spec.lua | |||
@@ -0,0 +1,115 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local lfs = require("lfs") | ||
3 | |||
4 | test_env.unload_luarocks() | ||
5 | local deps = require("luarocks.deps") | ||
6 | |||
7 | local extra_rocks = { | ||
8 | "/lxsh-0.8.6-2.src.rock", | ||
9 | "/lxsh-0.8.6-2.rockspec", | ||
10 | "/luasocket-3.0rc1-1.src.rock", | ||
11 | "/luasocket-3.0rc1-1.rockspec", | ||
12 | "/lpeg-0.12-1.src.rock" | ||
13 | } | ||
14 | |||
15 | expose("LuaRocks deps tests #blackbox #b_deps", function() | ||
16 | |||
17 | before_each(function() | ||
18 | test_env.setup_specs(extra_rocks) | ||
19 | testing_paths = test_env.testing_paths | ||
20 | run = test_env.run | ||
21 | end) | ||
22 | |||
23 | it("LuaRocks deps mode one", function() | ||
24 | assert.is_true(run.luarocks_bool("build --tree=system lpeg")) | ||
25 | assert.is_true(run.luarocks_bool("build --deps-mode=one --tree=" .. testing_paths.testing_tree .. " lxsh")) | ||
26 | |||
27 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) | ||
28 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | ||
29 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) | ||
30 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
31 | end) | ||
32 | |||
33 | it("LuaRocks deps mode order", function() | ||
34 | assert.is_true(run.luarocks_bool("build --tree=system lpeg")) | ||
35 | assert.is_true(run.luarocks_bool("build --deps-mode=order --tree=" .. testing_paths.testing_tree .. " lxsh")) | ||
36 | |||
37 | assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) | ||
38 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | ||
39 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) | ||
40 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
41 | end) | ||
42 | |||
43 | it("LuaRocks deps mode order sys", function() | ||
44 | assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg")) | ||
45 | assert.is_true(run.luarocks_bool("build --deps-mode=order --tree=" .. testing_paths.testing_sys_tree .. " lxsh")) | ||
46 | |||
47 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) | ||
48 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | ||
49 | assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) | ||
50 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
51 | end) | ||
52 | |||
53 | it("LuaRocks deps mode all sys", function() | ||
54 | assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg")) | ||
55 | assert.is_true(run.luarocks_bool("build --deps-mode=all --tree=" .. testing_paths.testing_sys_tree .. " lxsh")) | ||
56 | |||
57 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) | ||
58 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | ||
59 | assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) | ||
60 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
61 | end) | ||
62 | |||
63 | it("LuaRocks deps mode none", function() | ||
64 | assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg")) | ||
65 | assert.is_true(run.luarocks_bool("build --deps-mode=none lxsh")) | ||
66 | |||
67 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) | ||
68 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | ||
69 | assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) | ||
70 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
71 | end) | ||
72 | |||
73 | it("LuaRocks nodeps alias", function() | ||
74 | assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " --nodeps lxsh")) | ||
75 | |||
76 | assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) | ||
77 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | ||
78 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) | ||
79 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
80 | end) | ||
81 | |||
82 | it("LuaRocks deps mode make order", function() | ||
83 | assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_sys_tree .. " lpeg")) | ||
84 | assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6")) | ||
85 | assert.is_true(run.luarocks_bool("unpack lxsh-0.8.6-2.src.rock")) | ||
86 | lfs.chdir("lxsh-0.8.6-2/lxsh-0.8.6-1/") | ||
87 | assert.is_true(run.luarocks_bool("make --tree=" .. testing_paths.testing_tree .. " --deps-mode=order")) | ||
88 | |||
89 | lfs.chdir(testing_paths.luarocks_dir) | ||
90 | test_env.remove_dir("lxsh-0.8.6-2") | ||
91 | assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) | ||
92 | |||
93 | assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) | ||
94 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | ||
95 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) | ||
96 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
97 | end) | ||
98 | |||
99 | it("LuaRocks deps mode make order sys", function() | ||
100 | assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg")) | ||
101 | assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6")) | ||
102 | assert.is_true(run.luarocks_bool("unpack lxsh-0.8.6-2.src.rock")) | ||
103 | lfs.chdir("lxsh-0.8.6-2/lxsh-0.8.6-1/") | ||
104 | assert.is_true(run.luarocks_bool("make --tree=" .. testing_paths.testing_sys_tree .. " --deps-mode=order")) | ||
105 | |||
106 | lfs.chdir(testing_paths.luarocks_dir) | ||
107 | test_env.remove_dir("lxsh-0.8.6-2") | ||
108 | assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) | ||
109 | |||
110 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) | ||
111 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | ||
112 | assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) | ||
113 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
114 | end) | ||
115 | end) \ No newline at end of file | ||
diff --git a/spec/doc_spec.lua b/spec/doc_spec.lua new file mode 100644 index 00000000..476b8ea8 --- /dev/null +++ b/spec/doc_spec.lua | |||
@@ -0,0 +1,57 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local lfs = require("lfs") | ||
3 | |||
4 | test_env.unload_luarocks() | ||
5 | local doc = require("luarocks.doc") | ||
6 | |||
7 | local extra_rocks = { | ||
8 | "/luarepl-0.4-1.src.rock" | ||
9 | } | ||
10 | |||
11 | expose("LuaRocks doc tests #blackbox #b_doc", function() | ||
12 | |||
13 | before_each(function() | ||
14 | test_env.setup_specs(extra_rocks) | ||
15 | testing_paths = test_env.testing_paths | ||
16 | run = test_env.run | ||
17 | end) | ||
18 | |||
19 | describe("LuaRocks doc basic tests", function() | ||
20 | it("LuaRocks doc with no flags/arguments", function() | ||
21 | assert.is_false(run.luarocks_bool("doc")) | ||
22 | end) | ||
23 | it("LuaRocks doc with invalid argument", function() | ||
24 | assert.is_false(run.luarocks_bool("doc invalid")) | ||
25 | end) | ||
26 | end) | ||
27 | |||
28 | describe("LuaRocks doc tests with flags", function() | ||
29 | it("LuaRocks doc of installed luarepl", function() | ||
30 | assert.is_true(run.luarocks_bool("install luarepl")) | ||
31 | assert.is_true(run.luarocks_bool("doc luarepl")) | ||
32 | end) | ||
33 | |||
34 | it("LuaRocks doc of luacov and access its home page", function() | ||
35 | assert.is_true(run.luarocks_bool("install luacov")) | ||
36 | assert.is_true(run.luarocks_bool("doc luacov --home")) | ||
37 | end) | ||
38 | |||
39 | it("LuaRocks doc of luacov and list doc folder", function() | ||
40 | assert.is_true(run.luarocks_bool("install luacov")) | ||
41 | local output = assert.is.truthy(run.luarocks("doc luacov --list")) | ||
42 | assert.is.truthy(output:find("/lib/luarocks/rocks/luacov/0.11.0--1/doc/")) | ||
43 | end) | ||
44 | |||
45 | it("LuaRocks doc of luacov local", function() | ||
46 | assert.is_true(run.luarocks_bool("install luacov")) | ||
47 | assert.is_true(run.luarocks_bool("doc luacov --local")) | ||
48 | end) | ||
49 | |||
50 | it("LuaRocks doc of luacov porcelain", function() | ||
51 | assert.is_true(run.luarocks_bool("install luacov")) | ||
52 | assert.is_true(run.luarocks_bool("doc luacov --porcelain")) | ||
53 | end) | ||
54 | end) | ||
55 | end) | ||
56 | |||
57 | |||
diff --git a/spec/download_spec.lua b/spec/download_spec.lua new file mode 100644 index 00000000..9b5d9e2e --- /dev/null +++ b/spec/download_spec.lua | |||
@@ -0,0 +1,37 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local lfs = require("lfs") | ||
3 | |||
4 | test_env.unload_luarocks() | ||
5 | local download = require("luarocks.download") | ||
6 | |||
7 | local extra_rocks = { | ||
8 | "/validate-args-1.5.4-1.rockspec" | ||
9 | } | ||
10 | |||
11 | expose("LuaRocks download tests #blackbox #b_download", function() | ||
12 | |||
13 | before_each(function() | ||
14 | test_env.setup_specs(extra_rocks) | ||
15 | run = test_env.run | ||
16 | end) | ||
17 | |||
18 | it("LuaRocks download with no flags/arguments", function() | ||
19 | assert.is_false(run.luarocks_bool("download")) | ||
20 | end) | ||
21 | |||
22 | it("LuaRocks download invalid", function() | ||
23 | assert.is_false(run.luarocks_bool("download invalid")) | ||
24 | end) | ||
25 | |||
26 | it("LuaRocks download all with delete downloaded files", function() --TODO maybe download --all more rocks | ||
27 | assert.is_true(run.luarocks_bool("download --all validate-args")) | ||
28 | assert.is.truthy(lfs.attributes("validate-args-1.5.4-1.rockspec")) | ||
29 | test_env.remove_files(lfs.currentdir(), "validate--args--") | ||
30 | end) | ||
31 | |||
32 | it("LuaRocks download rockspec version", function() | ||
33 | assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1")) | ||
34 | assert.is.truthy(lfs.attributes("validate-args-1.5.4-1.rockspec")) | ||
35 | test_env.remove_files(lfs.currentdir(), "validate--args--") | ||
36 | end) | ||
37 | end) | ||
diff --git a/spec/fetch_spec.lua b/spec/fetch_spec.lua new file mode 100644 index 00000000..1f298733 --- /dev/null +++ b/spec/fetch_spec.lua | |||
@@ -0,0 +1,16 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local lfs = require("lfs") | ||
3 | |||
4 | test_env.unload_luarocks() | ||
5 | local fetch = require("luarocks.fetch") | ||
6 | |||
7 | describe("Luarocks fetch test #whitebox #w_fetch", function() | ||
8 | it("Fetch url to base dir", function() | ||
9 | assert.are.same("v0.3", fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2/archive/v0.3.zip")) | ||
10 | assert.are.same("lua-compat-5.2", fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2.zip")) | ||
11 | assert.are.same("lua-compat-5.2", fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2.tar.gz")) | ||
12 | assert.are.same("lua-compat-5.2", fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2.tar.bz2")) | ||
13 | assert.are.same("parser.moon", fetch.url_to_base_dir("git://github.com/Cirru/parser.moon")) | ||
14 | assert.are.same("v0.3", fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2/archive/v0.3")) | ||
15 | end) | ||
16 | end) \ No newline at end of file | ||
diff --git a/spec/help_spec.lua b/spec/help_spec.lua new file mode 100644 index 00000000..0f40dd38 --- /dev/null +++ b/spec/help_spec.lua | |||
@@ -0,0 +1,29 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local lfs = require("lfs") | ||
3 | |||
4 | test_env.unload_luarocks() | ||
5 | local help = require("luarocks.help") | ||
6 | |||
7 | expose("LuaRocks help tests #blackbox #b_help", function() | ||
8 | |||
9 | before_each(function() | ||
10 | test_env.setup_specs(extra_rocks) | ||
11 | run = test_env.run | ||
12 | end) | ||
13 | |||
14 | it("LuaRocks help with no flags/arguments", function() | ||
15 | assert.is_true(run.luarocks_bool("help")) | ||
16 | end) | ||
17 | |||
18 | it("LuaRocks help invalid argument", function() | ||
19 | assert.is_false(run.luarocks_bool("help invalid")) | ||
20 | end) | ||
21 | |||
22 | it("LuaRocks help config", function() | ||
23 | assert.is_true(run.luarocks_bool("help config")) | ||
24 | end) | ||
25 | |||
26 | it("LuaRocks-admin help with no flags/arguments", function() | ||
27 | assert.is_true(run.luarocks_admin_bool("help")) | ||
28 | end) | ||
29 | end) \ No newline at end of file | ||
diff --git a/spec/install_spec.lua b/spec/install_spec.lua new file mode 100644 index 00000000..306bbbc1 --- /dev/null +++ b/spec/install_spec.lua | |||
@@ -0,0 +1,130 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local lfs = require("lfs") | ||
3 | |||
4 | test_env.unload_luarocks() | ||
5 | local install = require("luarocks.install") | ||
6 | |||
7 | local extra_rocks = { | ||
8 | "/cprint-0.1-2.src.rock", | ||
9 | "/cprint-0.1-2.rockspec", | ||
10 | "/lpeg-0.12-1.src.rock", | ||
11 | "/luasec-0.6-1.rockspec", | ||
12 | "/luassert-1.7.0-1.src.rock", | ||
13 | "/luasocket-3.0rc1-1.src.rock", | ||
14 | "/luasocket-3.0rc1-1.rockspec", | ||
15 | "/lxsh-0.8.6-2.src.rock", | ||
16 | "/lxsh-0.8.6-2.rockspec", | ||
17 | "/say-1.2-1.src.rock", | ||
18 | "/say-1.0-1.src.rock", | ||
19 | "/wsapi-1.6-1.src.rock" | ||
20 | } | ||
21 | |||
22 | expose("LuaRocks install tests #blackbox #b_install", function() | ||
23 | |||
24 | before_each(function() | ||
25 | test_env.setup_specs(extra_rocks) | ||
26 | testing_paths = test_env.testing_paths | ||
27 | env_variables = test_env.env_variables | ||
28 | run = test_env.run | ||
29 | platform = test_env.platform | ||
30 | end) | ||
31 | |||
32 | describe("LuaRocks install - basic tests", function() | ||
33 | it("LuaRocks install with no flags/arguments", function() | ||
34 | assert.is_false(run.luarocks_bool("install")) | ||
35 | end) | ||
36 | |||
37 | it("LuaRocks install with invalid argument", function() | ||
38 | assert.is_false(run.luarocks_bool("install invalid")) | ||
39 | end) | ||
40 | |||
41 | it("LuaRocks install invalid patch", function() | ||
42 | assert.is_false(run.luarocks_bool("install " .. testing_paths.testing_dir .. "/testfiles/invalid_patch-0.1-1.rockspec")) | ||
43 | end) | ||
44 | |||
45 | it("LuaRocks install invalid rock", function() | ||
46 | assert.is_false(run.luarocks_bool("install \"invalid.rock\" ")) | ||
47 | end) | ||
48 | |||
49 | it("LuaRocks install with local flag as root", function() | ||
50 | assert.is_false(run.luarocks_bool("install --local luasocket", { USER = "root" } )) | ||
51 | end) | ||
52 | |||
53 | it("LuaRocks install not a zip file", function() | ||
54 | assert.is_false(run.luarocks_bool("install " .. testing_paths.testing_dir .. "/testfiles/not_a_zipfile-1.0-1.src.rock")) | ||
55 | end) | ||
56 | |||
57 | it("LuaRocks install only-deps of lxsh show there is no lxsh", function() | ||
58 | assert.is_true(run.luarocks_bool("install lxsh 0.8.6-2 --only-deps")) | ||
59 | assert.is_false(run.luarocks_bool("show lxsh")) | ||
60 | end) | ||
61 | |||
62 | it("LuaRocks install incompatible architecture", function() | ||
63 | assert.is_false(run.luarocks_bool("install \"foo-1.0-1.impossible-x86.rock\" ")) | ||
64 | end) | ||
65 | |||
66 | it("LuaRocks install wsapi with bin", function() | ||
67 | run.luarocks_bool("install wsapi") | ||
68 | end) | ||
69 | |||
70 | it("LuaRocks install luasec and show luasocket (dependency)", function() | ||
71 | assert.is_true(run.luarocks_bool("install luasec")) | ||
72 | assert.is_true(run.luarocks_bool("show luasocket")) | ||
73 | end) | ||
74 | end) | ||
75 | |||
76 | describe("LuaRocks install - more complex tests", function() | ||
77 | it('LuaRocks install luasec with skipping dependency checks', function() | ||
78 | run.luarocks(" install luasec --nodeps") | ||
79 | assert.is_true(run.luarocks_bool("show luasec")) | ||
80 | if env_variables.TYPE_TEST_ENV == "minimal" then | ||
81 | assert.is_false(run.luarocks_bool("show luasocket")) | ||
82 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) | ||
83 | end | ||
84 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec")) | ||
85 | end) | ||
86 | |||
87 | it("LuaRocks install only-deps of luasocket packed rock", function() | ||
88 | assert.is_true(test_env.need_luasocket()) | ||
89 | local output = run.luarocks("install --only-deps " .. testing_paths.testing_cache .. "/luasocket-3.0rc1-1." .. platform .. ".rock") | ||
90 | assert.are.same(output, "Successfully installed dependencies for luasocket 3.0rc1-1") | ||
91 | end) | ||
92 | |||
93 | it("LuaRocks install binary rock of cprint", function() | ||
94 | assert.is_true(test_env.need_luasocket()) | ||
95 | assert.is_true(run.luarocks_bool("build --pack-binary-rock cprint")) | ||
96 | assert.is_true(run.luarocks_bool("install cprint-0.1-2." .. platform .. ".rock")) | ||
97 | assert.is_true(os.remove("cprint-0.1-2." .. platform .. ".rock")) | ||
98 | end) | ||
99 | |||
100 | it("LuaRocks install reinstall", function() | ||
101 | assert.is_true(test_env.need_luasocket()) | ||
102 | assert.is_true(run.luarocks_bool("install " .. testing_paths.testing_cache .. "/luasocket-3.0rc1-1." .. platform .. ".rock")) | ||
103 | assert.is_true(run.luarocks_bool("install --deps-mode=none " .. testing_paths.testing_cache .. "/luasocket-3.0rc1-1." .. platform .. ".rock")) | ||
104 | end) | ||
105 | end) | ||
106 | |||
107 | describe("New install functionality based on pull request 552", function() | ||
108 | it("LuaRocks install break dependencies warning", function() | ||
109 | assert.is_true(run.luarocks_bool("install say 1.2")) | ||
110 | assert.is_true(run.luarocks_bool("install luassert")) | ||
111 | assert.is_true(run.luarocks_bool("install say 1.0")) | ||
112 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/say/1.2-1")) | ||
113 | end) | ||
114 | it("LuaRocks install break dependencies force", function() | ||
115 | assert.is_true(run.luarocks_bool("install say 1.2")) | ||
116 | assert.is_true(run.luarocks_bool("install luassert")) | ||
117 | local output = run.luarocks("install --force say 1.0") | ||
118 | assert.is.truthy(output:find("Checking stability of dependencies")) | ||
119 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/say/1.2-1")) | ||
120 | end) | ||
121 | it("LuaRocks install break dependencies force fast", function() | ||
122 | assert.is_true(run.luarocks_bool("install say 1.2")) | ||
123 | assert.is_true(run.luarocks_bool("install luassert")) | ||
124 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/say/1.2-1")) | ||
125 | local output = run.luarocks("install --force-fast say 1.0") | ||
126 | assert.is.falsy(output:find("Checking stability of dependencies")) | ||
127 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/say/1.0-1")) | ||
128 | end) | ||
129 | end) | ||
130 | end) \ No newline at end of file | ||
diff --git a/spec/lint_spec.lua b/spec/lint_spec.lua new file mode 100644 index 00000000..cba80a3e --- /dev/null +++ b/spec/lint_spec.lua | |||
@@ -0,0 +1,51 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local lfs = require("lfs") | ||
3 | |||
4 | test_env.unload_luarocks() | ||
5 | local lint = require("luarocks.lint") | ||
6 | |||
7 | local extra_rocks = { | ||
8 | "/validate-args-1.5.4-1.rockspec" | ||
9 | } | ||
10 | |||
11 | expose("LuaRocks lint tests #blackbox #b_lint", function() | ||
12 | |||
13 | before_each(function() | ||
14 | test_env.setup_specs(extra_rocks) | ||
15 | testing_paths = test_env.testing_paths | ||
16 | run = test_env.run | ||
17 | end) | ||
18 | |||
19 | it("LuaRocks lint with no flags/arguments", function() | ||
20 | assert.is_false(run.luarocks_bool("lint")) | ||
21 | end) | ||
22 | |||
23 | it("LuaRocks lint invalid argument", function() | ||
24 | assert.is_false(run.luarocks_bool("lint invalid")) | ||
25 | end) | ||
26 | |||
27 | it("LuaRocks lint OK", function() | ||
28 | assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1")) | ||
29 | local output = run.luarocks("lint validate-args-1.5.4-1.rockspec") | ||
30 | assert.are.same(output, "") | ||
31 | assert.is_true(os.remove("validate-args-1.5.4-1.rockspec")) | ||
32 | end) | ||
33 | |||
34 | describe("LuaRocks lint mismatch set", function() | ||
35 | it("LuaRocks lint mismatch string", function() | ||
36 | assert.is_false(run.luarocks_bool("lint " .. testing_paths.testing_dir .. "/testfiles/type_mismatch_string-1.0-1.rockspec")) | ||
37 | end) | ||
38 | |||
39 | it("LuaRocks lint mismatch version", function() | ||
40 | assert.is_false(run.luarocks_bool("lint " .. testing_paths.testing_dir .. "/testfiles/type_mismatch_version-1.0-1.rockspec")) | ||
41 | end) | ||
42 | |||
43 | it("LuaRocks lint mismatch table", function() | ||
44 | assert.is_false(run.luarocks_bool("lint " .. testing_paths.testing_dir .. "/testfiles/type_mismatch_table-1.0-1.rockspec")) | ||
45 | end) | ||
46 | |||
47 | it("LuaRocks lint mismatch no build table", function() | ||
48 | assert.is_false(run.luarocks_bool("lint " .. testing_paths.testing_dir .. "/testfiles/no_build_table-1.0-1.rockspec")) | ||
49 | end) | ||
50 | end) | ||
51 | end) \ No newline at end of file | ||
diff --git a/spec/list_spec.lua b/spec/list_spec.lua new file mode 100644 index 00000000..545483df --- /dev/null +++ b/spec/list_spec.lua | |||
@@ -0,0 +1,41 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local lfs = require("lfs") | ||
3 | |||
4 | test_env.unload_luarocks() | ||
5 | local list = require("luarocks.list") | ||
6 | |||
7 | local extra_rocks = { | ||
8 | "/say-1.0-1.src.rock", | ||
9 | "/say-1.2-1.src.rock" | ||
10 | } | ||
11 | |||
12 | expose("LuaRocks list tests #blackbox #b_list", function() | ||
13 | |||
14 | before_each(function() | ||
15 | test_env.setup_specs(extra_rocks) | ||
16 | run = test_env.run | ||
17 | testing_paths = test_env.testing_paths | ||
18 | end) | ||
19 | |||
20 | it("LuaRocks list with no flags/arguments", function() | ||
21 | local output = run.luarocks("list") | ||
22 | assert.is.truthy(output:find("luacov")) | ||
23 | end) | ||
24 | |||
25 | it("LuaRocks list porcelain", function() | ||
26 | local output = run.luarocks("list --porcelain") | ||
27 | local path = testing_paths.testing_sys_tree:gsub("-", "--") -- !not sure! why this is good | ||
28 | assert.is.truthy(output:find("luacov\t0.11.0--1\tinstalled\t" .. path .. "/lib/luarocks/rocks" )) | ||
29 | end) | ||
30 | |||
31 | it("LuaRocks install outdated and list it", function() | ||
32 | assert.is_true(run.luarocks_bool("install say 1.0-1")) | ||
33 | local output = run.luarocks("list --outdated") | ||
34 | assert.is.truthy(output:find("say")) | ||
35 | end) | ||
36 | |||
37 | it("LuaRocks list invalid tree", function() | ||
38 | local output = run.luarocks("--tree=/some/invalid/tree list") | ||
39 | assert.are.same(output, "Installed rocks:----------------") | ||
40 | end) | ||
41 | end) | ||
diff --git a/spec/make_manifest_spec.lua b/spec/make_manifest_spec.lua new file mode 100644 index 00000000..c6cb1328 --- /dev/null +++ b/spec/make_manifest_spec.lua | |||
@@ -0,0 +1,19 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local lfs = require("lfs") | ||
3 | |||
4 | test_env.unload_luarocks() | ||
5 | local make_manifest = require("luarocks.make_manifest") | ||
6 | |||
7 | expose("LuaRocks make_manifest tests #blackbox #b_make_manifest", function() | ||
8 | |||
9 | before_each(function() | ||
10 | test_env.setup_specs(extra_rocks) | ||
11 | run = test_env.run | ||
12 | end) | ||
13 | |||
14 | describe("LuaRocks-admin make manifest tests", function() | ||
15 | it("LuaRocks-admin make manifest", function() | ||
16 | assert.is_true(run.luarocks_admin_bool("make_manifest")) | ||
17 | end) | ||
18 | end) | ||
19 | end) \ No newline at end of file | ||
diff --git a/spec/make_spec.lua b/spec/make_spec.lua new file mode 100644 index 00000000..f70bb7e9 --- /dev/null +++ b/spec/make_spec.lua | |||
@@ -0,0 +1,99 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local lfs = require("lfs") | ||
3 | |||
4 | test_env.unload_luarocks() | ||
5 | local make = require("luarocks.make") | ||
6 | |||
7 | local extra_rocks = { | ||
8 | "/lpeg-0.12-1.src.rock", | ||
9 | "/luasocket-3.0rc1-1.src.rock", | ||
10 | "/luasocket-3.0rc1-1.rockspec", | ||
11 | "/lxsh-0.8.6-2.src.rock", | ||
12 | "/lxsh-0.8.6-2.rockspec" | ||
13 | } | ||
14 | |||
15 | expose("LuaRocks make tests #blackbox #b_make", function() | ||
16 | |||
17 | before_each(function() | ||
18 | test_env.setup_specs(extra_rocks) | ||
19 | run = test_env.run | ||
20 | testing_paths = test_env.testing_paths | ||
21 | end) | ||
22 | |||
23 | it("LuaRocks make with no flags/arguments", function() | ||
24 | lfs.chdir("test") | ||
25 | assert.is_false(run.luarocks_bool("make")) | ||
26 | lfs.chdir(testing_paths.luarocks_dir) | ||
27 | end) | ||
28 | |||
29 | it("LuaRocks make with rockspec", function() | ||
30 | -- make luasocket | ||
31 | assert.is_true(run.luarocks_bool("download --source luasocket")) | ||
32 | assert.is_true(run.luarocks_bool("unpack luasocket-3.0rc1-1.src.rock")) | ||
33 | lfs.chdir("luasocket-3.0rc1-1/luasocket-3.0-rc1/") | ||
34 | assert.is_true(run.luarocks_bool("make luasocket-3.0rc1-1.rockspec")) | ||
35 | |||
36 | -- test it | ||
37 | assert.is_true(run.luarocks_bool("show luasocket")) | ||
38 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) | ||
39 | |||
40 | -- delete downloaded and unpacked files | ||
41 | lfs.chdir(testing_paths.luarocks_dir) | ||
42 | test_env.remove_dir("luasocket-3.0rc1-1") | ||
43 | assert.is_true(os.remove("luasocket-3.0rc1-1.src.rock")) | ||
44 | end) | ||
45 | |||
46 | describe("LuaRocks making rockspecs (using lxsh)", function() | ||
47 | --download lxsh and unpack it | ||
48 | before_each(function() | ||
49 | assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6-2")) | ||
50 | assert.is_true(run.luarocks_bool("unpack lxsh-0.8.6-2.src.rock")) | ||
51 | assert.is_true(lfs.chdir("lxsh-0.8.6-2/lxsh-0.8.6-1/")) | ||
52 | end) | ||
53 | |||
54 | -- delete downloaded and unpacked files | ||
55 | after_each(function() | ||
56 | assert.is_true(lfs.chdir(testing_paths.luarocks_dir)) | ||
57 | test_env.remove_dir("lxsh-0.8.6-2") | ||
58 | assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) | ||
59 | end) | ||
60 | |||
61 | it("LuaRocks make default rockspec", function() | ||
62 | assert.is_true(run.luarocks_bool("new_version lxsh-0.8.6-2.rockspec")) | ||
63 | assert.is_true(run.luarocks_bool("make")) | ||
64 | |||
65 | assert.is_true(run.luarocks_bool("show lxsh")) | ||
66 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
67 | end) | ||
68 | |||
69 | it("LuaRocks make unnamed rockspec", function() | ||
70 | os.execute("cp lxsh-0.8.6-2.rockspec rockspec") --rewrite with lfs | ||
71 | assert.is_true(run.luarocks_bool("make")) | ||
72 | |||
73 | assert.is_true(run.luarocks_bool("show lxsh")) | ||
74 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
75 | end) | ||
76 | |||
77 | it("LuaRocks make ambiguous rockspec", function() | ||
78 | assert.is.truthy(os.rename("lxsh-0.8.6-2.rockspec", "lxsh2-0.8.6-2.rockspec")) | ||
79 | assert.is_false(run.luarocks_bool("make")) | ||
80 | |||
81 | assert.is_false(run.luarocks_bool("show lxsh")) | ||
82 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
83 | end) | ||
84 | |||
85 | it("LuaRocks make ambiguous unnamed rockspec", function() | ||
86 | assert.is.truthy(os.rename("lxsh-0.8.6-2.rockspec", "1_rockspec")) | ||
87 | os.execute("cp 1_rockspec 2_rockspec") --rewrite with lfs | ||
88 | assert.is_false(run.luarocks_bool("make")) | ||
89 | |||
90 | assert.is_false(run.luarocks_bool("show lxsh")) | ||
91 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
92 | end) | ||
93 | |||
94 | it("LuaRocks make pack binary rock", function() | ||
95 | assert.is_true(run.luarocks_bool("make --deps-mode=none --pack-binary-rock")) | ||
96 | assert.is.truthy(lfs.attributes("lxsh-0.8.6-2.all.rock")) | ||
97 | end) | ||
98 | end) | ||
99 | end) \ No newline at end of file | ||
diff --git a/spec/new_version_spec.lua b/spec/new_version_spec.lua new file mode 100644 index 00000000..57014226 --- /dev/null +++ b/spec/new_version_spec.lua | |||
@@ -0,0 +1,53 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local lfs = require("lfs") | ||
3 | |||
4 | test_env.unload_luarocks() | ||
5 | local new_version = require("luarocks.new_version") | ||
6 | |||
7 | local extra_rocks = { | ||
8 | "/abelhas-1.0-1.rockspec" | ||
9 | } | ||
10 | |||
11 | expose("LuaRocks new_version tests #blackbox #b_new_version", function() | ||
12 | |||
13 | before_each(function() | ||
14 | test_env.setup_specs(extra_rocks) | ||
15 | testing_paths = test_env.testing_paths | ||
16 | run = test_env.run | ||
17 | end) | ||
18 | |||
19 | describe("LuaRocks new_version basic tests", function() | ||
20 | it("LuaRocks new version with no flags/arguments", function() | ||
21 | lfs.chdir("test") | ||
22 | assert.is_false(run.luarocks_bool("new_version")) | ||
23 | lfs.chdir(testing_paths.luarocks_dir) | ||
24 | end) | ||
25 | |||
26 | it("LuaRocks new version invalid", function() | ||
27 | assert.is_false(run.luarocks_bool("new_version invalid")) | ||
28 | end) | ||
29 | end) | ||
30 | |||
31 | describe("LuaRocks new_version more complex tests", function() | ||
32 | it("LuaRocks new_version of luacov", function() | ||
33 | assert.is_true(run.luarocks_bool("download --rockspec luacov 0.11.0")) | ||
34 | assert.is_true(run.luarocks_bool("new_version luacov-0.11.0-1.rockspec 0.2")) | ||
35 | assert.is.truthy(lfs.attributes("luacov-0.2-1.rockspec")) | ||
36 | test_env.remove_files(lfs.currentdir(), "luacov--") | ||
37 | end) | ||
38 | |||
39 | it("LuaRocks new_version url of abelhas", function() | ||
40 | assert.is_true(run.luarocks_bool("download --rockspec abelhas 1.0")) | ||
41 | assert.is_true(run.luarocks_bool("new_version abelhas-1.0-1.rockspec 1.1 http://luaforge.net/frs/download.php/2658/abelhas-1.0.tar.gz")) | ||
42 | assert.is.truthy(lfs.attributes("abelhas-1.1-1.rockspec")) | ||
43 | test_env.remove_files(lfs.currentdir(), "abelhas--") | ||
44 | end) | ||
45 | |||
46 | it("LuaRocks new_version of luacov with tag", function() | ||
47 | assert.is_true(run.luarocks_bool("download --rockspec luacov 0.11.0")) | ||
48 | assert.is_true(run.luarocks_bool("new_version luacov-0.11.0-1.rockspec --tag v0.3")) | ||
49 | assert.is.truthy(lfs.attributes("luacov-0.3-1.rockspec")) | ||
50 | test_env.remove_files(lfs.currentdir(), "luacov--") | ||
51 | end) | ||
52 | end) | ||
53 | end) \ No newline at end of file | ||
diff --git a/spec/pack_spec.lua b/spec/pack_spec.lua new file mode 100644 index 00000000..a07e7ed2 --- /dev/null +++ b/spec/pack_spec.lua | |||
@@ -0,0 +1,35 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local lfs = require("lfs") | ||
3 | |||
4 | test_env.unload_luarocks() | ||
5 | local pack = require("luarocks.pack") | ||
6 | |||
7 | local extra_rocks = { | ||
8 | "/luasec-0.6-1.rockspec", | ||
9 | "/luasocket-3.0rc1-1.src.rock", | ||
10 | "/luasocket-3.0rc1-1.rockspec" | ||
11 | } | ||
12 | |||
13 | expose("LuaRocks pack tests #blackbox #b_pack", function() | ||
14 | |||
15 | before_each(function() | ||
16 | test_env.setup_specs(extra_rocks) | ||
17 | testing_paths = test_env.testing_paths | ||
18 | run = test_env.run | ||
19 | end) | ||
20 | |||
21 | it("LuaRocks pack basic", function() | ||
22 | assert.is_true(run.luarocks_bool("list")) | ||
23 | assert.is_true(run.luarocks_bool("pack luacov")) | ||
24 | assert.is_true(test_env.remove_files(lfs.currentdir(), "luacov-")) | ||
25 | end) | ||
26 | |||
27 | it("LuaRocks pack src", function() | ||
28 | assert.is_true(run.luarocks_bool("install luasec")) | ||
29 | assert.is_true(run.luarocks_bool("download --rockspec luasocket")) | ||
30 | assert.is_true(run.luarocks_bool("pack luasocket-3.0rc1-1.rockspec")) | ||
31 | assert.is_true(test_env.remove_files(lfs.currentdir(), "luasocket-")) | ||
32 | end) | ||
33 | end) | ||
34 | |||
35 | |||
diff --git a/spec/path_spec.lua b/spec/path_spec.lua new file mode 100644 index 00000000..266ada89 --- /dev/null +++ b/spec/path_spec.lua | |||
@@ -0,0 +1,28 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local lfs = require("lfs") | ||
3 | |||
4 | test_env.unload_luarocks() | ||
5 | local path = require("luarocks.path") | ||
6 | |||
7 | expose("LuaRocks path tests #blackbox #b_path", function() | ||
8 | before_each(function() | ||
9 | test_env.setup_specs(extra_rocks) | ||
10 | run = test_env.run | ||
11 | end) | ||
12 | |||
13 | it("LuaRocks path bin", function() | ||
14 | assert.is_true(run.luarocks_bool("path --bin")) | ||
15 | end) | ||
16 | |||
17 | it("LuaRocks path lr-path", function() | ||
18 | assert.is_true(run.luarocks_bool("path --lr-path")) | ||
19 | end) | ||
20 | |||
21 | it("LuaRocks path lr-cpath", function() | ||
22 | assert.is_true(run.luarocks_bool("path --lr-cpath")) | ||
23 | end) | ||
24 | |||
25 | it("LuaRocks path with tree", function() | ||
26 | assert.is_true(run.luarocks_bool("path --tree=lua_modules")) | ||
27 | end) | ||
28 | end) | ||
diff --git a/spec/purge_spec.lua b/spec/purge_spec.lua new file mode 100644 index 00000000..639f96f3 --- /dev/null +++ b/spec/purge_spec.lua | |||
@@ -0,0 +1,30 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local lfs = require("lfs") | ||
3 | |||
4 | test_env.unload_luarocks() | ||
5 | local purge = require("luarocks.purge") | ||
6 | |||
7 | expose("LuaRocks purge tests #blackbox #b_purge", function() | ||
8 | before_each(function() | ||
9 | test_env.setup_specs(extra_rocks) | ||
10 | testing_paths = test_env.testing_paths | ||
11 | run = test_env.run | ||
12 | end) | ||
13 | |||
14 | describe("LuaRocks purge basic tests", function() | ||
15 | it("LuaRocks purge missing tree", function() | ||
16 | assert.is_false(run.luarocks_bool("purge --tree=" .. testing_paths.testing_tree)) | ||
17 | end) | ||
18 | it("LuaRocks purge tree with no string", function() | ||
19 | assert.is_false(run.luarocks_bool("purge --tree=1")) | ||
20 | end) | ||
21 | it("LuaRocks purge tree with no string", function() | ||
22 | assert.is_true(run.luarocks_bool("purge --tree=" .. testing_paths.testing_sys_tree)) | ||
23 | end) | ||
24 | it("LuaRocks purge old versions tree", function() | ||
25 | assert.is_true(run.luarocks_bool("purge --old-versions --tree=" .. testing_paths.testing_sys_tree)) | ||
26 | end) | ||
27 | end) | ||
28 | end) | ||
29 | |||
30 | |||
diff --git a/spec/refresh_cache_spec.lua b/spec/refresh_cache_spec.lua new file mode 100644 index 00000000..27a95e5c --- /dev/null +++ b/spec/refresh_cache_spec.lua | |||
@@ -0,0 +1,19 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local lfs = require("lfs") | ||
3 | |||
4 | test_env.unload_luarocks() | ||
5 | local refresh_cache = require("luarocks.refresh_cache") | ||
6 | |||
7 | expose("LuaRocks refresh_cache tests #blackbox #b_refresh_cache", function() | ||
8 | |||
9 | before_each(function() | ||
10 | test_env.setup_specs(extra_rocks) | ||
11 | run = test_env.run | ||
12 | end) | ||
13 | |||
14 | describe("LuaRocks-admin refresh cache tests #ssh", function() | ||
15 | it("LuaRocks-admin refresh cache", function() | ||
16 | assert.is_true(run.luarocks_admin_bool("--server=testing refresh_cache")) | ||
17 | end) | ||
18 | end) | ||
19 | end) \ No newline at end of file | ||
diff --git a/spec/remove_spec.lua b/spec/remove_spec.lua new file mode 100644 index 00000000..a94673a8 --- /dev/null +++ b/spec/remove_spec.lua | |||
@@ -0,0 +1,85 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local lfs = require("lfs") | ||
3 | |||
4 | test_env.unload_luarocks() | ||
5 | local remove = require("luarocks.remove") | ||
6 | |||
7 | local extra_rocks = { | ||
8 | "/abelhas-1.0-1.rockspec", | ||
9 | "/lualogging-1.3.0-1.src.rock", | ||
10 | "/luasocket-3.0rc1-1.src.rock", | ||
11 | "/luasocket-3.0rc1-1.rockspec" | ||
12 | } | ||
13 | |||
14 | expose("LuaRocks remove tests #blackbox #b_remove", function() | ||
15 | |||
16 | before_each(function() | ||
17 | test_env.setup_specs(extra_rocks) | ||
18 | testing_paths = test_env.testing_paths | ||
19 | run = test_env.run | ||
20 | end) | ||
21 | |||
22 | describe("LuaRocks remove basic tests", function() | ||
23 | it("LuaRocks remove with no flags/arguments", function() | ||
24 | assert.is_false(run.luarocks_bool("remove")) | ||
25 | end) | ||
26 | |||
27 | it("LuaRocks remove invalid rock", function() | ||
28 | assert.is_false(run.luarocks_bool("remove invalid.rock")) | ||
29 | end) | ||
30 | |||
31 | it("LuaRocks remove missing rock", function() | ||
32 | assert.is_false(run.luarocks_bool("remove missing_rock")) | ||
33 | end) | ||
34 | |||
35 | it("LuaRocks remove invalid argument", function() | ||
36 | assert.is_false(run.luarocks_bool("remove luacov --deps-mode")) | ||
37 | end) | ||
38 | |||
39 | it("LuaRocks remove builded abelhas", function() | ||
40 | assert.is_true(run.luarocks_bool("build abelhas 1.0")) | ||
41 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/abelhas")) | ||
42 | assert.is_true(run.luarocks_bool("remove abelhas 1.0")) | ||
43 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/abelhas")) | ||
44 | end) | ||
45 | end) | ||
46 | |||
47 | describe("LuaRocks remove more complex tests", function() | ||
48 | it("LuaRocks remove fail, break dependencies", function() | ||
49 | assert.is_true(test_env.need_luasocket()) | ||
50 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) | ||
51 | assert.is_true(run.luarocks_bool("build lualogging")) | ||
52 | |||
53 | assert.is_false(run.luarocks_bool("remove luasocket")) | ||
54 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) | ||
55 | end) | ||
56 | |||
57 | it("LuaRocks remove force", function() | ||
58 | assert.is_true(test_env.need_luasocket()) | ||
59 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) | ||
60 | assert.is_true(run.luarocks_bool("build lualogging")) | ||
61 | |||
62 | local output = run.luarocks("remove --force luasocket") | ||
63 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) | ||
64 | assert.is.truthy(output:find("Checking stability of dependencies")) | ||
65 | end) | ||
66 | |||
67 | it("LuaRocks remove force fast", function() | ||
68 | assert.is_true(test_env.need_luasocket()) | ||
69 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) | ||
70 | assert.is_true(run.luarocks_bool("build lualogging")) | ||
71 | |||
72 | local output = run.luarocks("remove --force-fast luasocket") | ||
73 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) | ||
74 | assert.is.falsy(output:find("Checking stability of dependencies")) | ||
75 | end) | ||
76 | end) | ||
77 | |||
78 | it("LuaRocks-admin remove #ssh", function() | ||
79 | assert.is_true(run.luarocks_admin_bool("--server=testing remove luasocket-3.0rc1-1.src.rock")) | ||
80 | end) | ||
81 | |||
82 | it("LuaRocks-admin remove missing", function() | ||
83 | assert.is_false(run.luarocks_admin_bool("--server=testing remove")) | ||
84 | end) | ||
85 | end) \ No newline at end of file | ||
diff --git a/spec/search_spec.lua b/spec/search_spec.lua new file mode 100644 index 00000000..a0258942 --- /dev/null +++ b/spec/search_spec.lua | |||
@@ -0,0 +1,42 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local lfs = require("lfs") | ||
3 | |||
4 | test_env.unload_luarocks() | ||
5 | local search = require("luarocks.search") | ||
6 | |||
7 | local extra_rocks = { | ||
8 | "/lzlib-0.4.1.53-1.src.rock" | ||
9 | } | ||
10 | |||
11 | expose("LuaRocks search tests #blackbox #b_search", function() | ||
12 | |||
13 | before_each(function() | ||
14 | test_env.setup_specs(extra_rocks) | ||
15 | run = test_env.run | ||
16 | end) | ||
17 | |||
18 | it("LuaRocks search with no flags/arguments", function() | ||
19 | assert.is_false(run.luarocks_bool("search")) | ||
20 | end) | ||
21 | |||
22 | it("LuaRocks search zlib", function() | ||
23 | assert.is_true(run.luarocks_bool("search zlib")) | ||
24 | end) | ||
25 | |||
26 | it("LuaRocks search zlib 1.1", function() | ||
27 | assert.is_true(run.luarocks_bool("search zlib 1.1")) | ||
28 | end) | ||
29 | |||
30 | it("LuaRocks search missing rock", function() | ||
31 | assert.is_true(run.luarocks_bool("search missing_rock")) | ||
32 | end) | ||
33 | |||
34 | it("LuaRocks search with flag all", function() | ||
35 | assert.is_true(run.luarocks_bool("search --all")) | ||
36 | end) | ||
37 | |||
38 | it("LuaRocks search zlib", function() | ||
39 | local num = 123 | ||
40 | assert.is_true(run.luarocks_bool("search " .. num)) | ||
41 | end) | ||
42 | end) \ No newline at end of file | ||
diff --git a/spec/show_spec.lua b/spec/show_spec.lua new file mode 100644 index 00000000..85797eb6 --- /dev/null +++ b/spec/show_spec.lua | |||
@@ -0,0 +1,56 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local lfs = require("lfs") | ||
3 | |||
4 | test_env.unload_luarocks() | ||
5 | local show = require("luarocks.show") | ||
6 | |||
7 | expose("LuaRocks show tests #blackbox #b_show", function() | ||
8 | |||
9 | before_each(function() | ||
10 | test_env.setup_specs(extra_rocks) | ||
11 | run = test_env.run | ||
12 | end) | ||
13 | |||
14 | it("LuaRocks show with no flags/arguments", function() | ||
15 | assert.is_false(run.luarocks_bool("show")) | ||
16 | end) | ||
17 | |||
18 | describe("LuaRocks show basic tests with flags", function() | ||
19 | it("LuaRocks show invalid", function() | ||
20 | assert.is_false(run.luarocks_bool("show invalid")) | ||
21 | end) | ||
22 | |||
23 | it("LuaRocks show luacov", function() | ||
24 | local output = run.luarocks("show luacov") | ||
25 | end) | ||
26 | |||
27 | it("LuaRocks show modules of luacov", function() | ||
28 | local output = run.luarocks("show --modules luacov") | ||
29 | end) | ||
30 | |||
31 | it("LuaRocks show dependencies of luacov", function() | ||
32 | local output = run.luarocks("show --deps luacov") | ||
33 | end) | ||
34 | |||
35 | it("LuaRocks show rockspec of luacov", function() | ||
36 | local output = run.luarocks("show --rockspec luacov") | ||
37 | end) | ||
38 | |||
39 | it("LuaRocks show mversion of luacov", function() | ||
40 | local output = run.luarocks("show --mversion luacov") | ||
41 | end) | ||
42 | |||
43 | it("LuaRocks show rock tree of luacov", function() | ||
44 | local output = run.luarocks("show --rock-tree luacov") | ||
45 | end) | ||
46 | |||
47 | it("LuaRocks show rock directory of luacov", function() | ||
48 | local output = run.luarocks("show --rock-dir luacov") | ||
49 | end) | ||
50 | end) | ||
51 | |||
52 | it("LuaRocks show old version of luacov", function() | ||
53 | run.luarocks("install luacov 0.11.0") | ||
54 | run.luarocks("show luacov 0.11.0") | ||
55 | end) | ||
56 | end) | ||
diff --git a/spec/unpack_spec.lua b/spec/unpack_spec.lua new file mode 100644 index 00000000..efe902f5 --- /dev/null +++ b/spec/unpack_spec.lua | |||
@@ -0,0 +1,61 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local lfs = require("lfs") | ||
3 | |||
4 | test_env.unload_luarocks() | ||
5 | local unpack = require("luarocks.unpack") | ||
6 | |||
7 | local extra_rocks = { | ||
8 | "/cprint-0.1-2.src.rock", | ||
9 | "/cprint-0.1-2.rockspec" | ||
10 | } | ||
11 | |||
12 | expose("LuaRocks unpack tests #blackbox #b_unpack", function() | ||
13 | |||
14 | before_each(function() | ||
15 | test_env.setup_specs(extra_rocks) | ||
16 | testing_paths = test_env.testing_paths | ||
17 | run = test_env.run | ||
18 | platform = test_env.platform | ||
19 | end) | ||
20 | |||
21 | describe("LuaRocks unpack basic fail tests", function() | ||
22 | it("LuaRocks unpack with no flags/arguments", function() | ||
23 | assert.is_false(run.luarocks_bool("unpack")) | ||
24 | end) | ||
25 | it("LuaRocks unpack with invalid rockspec", function() | ||
26 | assert.is_false(run.luarocks_bool("unpack invalid.rockspec")) | ||
27 | end) | ||
28 | it("LuaRocks unpack with invalid patch", function() | ||
29 | assert.is_false(run.luarocks_bool("unpack " .. testing_paths.testing_dir .. "/testfiles/invalid_patch-0.1-1.rockspec")) | ||
30 | end) | ||
31 | end) | ||
32 | |||
33 | describe("LuaRocks unpack more complex tests", function() | ||
34 | it("LuaRocks unpack download", function() | ||
35 | assert.is_true(run.luarocks_bool("unpack cprint")) | ||
36 | test_env.remove_dir("cprint-0.1-2") | ||
37 | end) | ||
38 | it("LuaRocks unpack src", function() | ||
39 | assert.is_true(run.luarocks_bool("download --source cprint")) | ||
40 | assert.is_true(run.luarocks_bool("unpack cprint-0.1-2.src.rock")) | ||
41 | os.remove("cprint-0.1-2.src.rock") | ||
42 | test_env.remove_dir("cprint-0.1-2") | ||
43 | end) | ||
44 | it("LuaRocks unpack src", function() | ||
45 | assert.is_true(run.luarocks_bool("download --rockspec cprint")) | ||
46 | assert.is_true(run.luarocks_bool("unpack cprint-0.1-2.rockspec")) | ||
47 | os.remove("cprint-0.1-2.rockspec") | ||
48 | os.remove("lua-cprint") | ||
49 | test_env.remove_dir("cprint-0.1-2") | ||
50 | end) | ||
51 | it("LuaRocks unpack binary", function() | ||
52 | assert.is_true(run.luarocks_bool("build cprint")) | ||
53 | assert.is_true(run.luarocks_bool("pack cprint")) | ||
54 | assert.is_true(run.luarocks_bool("unpack cprint-0.1-2." .. platform .. ".rock")) | ||
55 | test_env.remove_dir("cprint-0.1-2") | ||
56 | os.remove("cprint-0.1-2." .. platform .. ".rock") | ||
57 | end) | ||
58 | end) | ||
59 | end) | ||
60 | |||
61 | |||
diff --git a/spec/upload_spec.lua b/spec/upload_spec.lua new file mode 100644 index 00000000..daf40d61 --- /dev/null +++ b/spec/upload_spec.lua | |||
@@ -0,0 +1,41 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local lfs = require("lfs") | ||
3 | |||
4 | test_env.unload_luarocks() | ||
5 | local upload = require("luarocks.upload") | ||
6 | |||
7 | local extra_rocks = { | ||
8 | "/lua-cjson-2.1.0-1.src.rock" | ||
9 | } | ||
10 | |||
11 | expose("LuaRocks upload tests #blackbox #b_upload", function() | ||
12 | |||
13 | before_each(function() | ||
14 | test_env.setup_specs(extra_rocks) | ||
15 | run = test_env.run | ||
16 | end) | ||
17 | |||
18 | it("LuaRocks upload with no flags/arguments", function() | ||
19 | assert.is_false(run.luarocks_bool("upload")) | ||
20 | end) | ||
21 | |||
22 | it("LuaRocks upload invalid rockspec", function() | ||
23 | assert.is_false(run.luarocks_bool("upload invalid.rockspec")) | ||
24 | end) | ||
25 | |||
26 | it("LuaRocks upload api key invalid", function() | ||
27 | assert.is_false(run.luarocks_bool("upload --api-key=invalid invalid.rockspec")) | ||
28 | end) | ||
29 | |||
30 | it("LuaRocks upload api key invalid and skip-pack", function() | ||
31 | assert.is_false(run.luarocks_bool("upload --api-key=\"invalid\" --skip-pack luacov-0.11.0-1.rockspec")) | ||
32 | end) | ||
33 | |||
34 | it("LuaRocks upload force", function() | ||
35 | assert.is_true(run.luarocks_bool("install lua-cjson")) | ||
36 | assert.is_false(run.luarocks_bool("upload --api-key=\"invalid\" --force luacov-0.11.0-1.rockspec")) | ||
37 | assert.is_true(run.luarocks_bool("install lua-cjson")) | ||
38 | end) | ||
39 | end) | ||
40 | |||
41 | |||
diff --git a/spec/util_spec.lua b/spec/util_spec.lua new file mode 100644 index 00000000..7c22d1cb --- /dev/null +++ b/spec/util_spec.lua | |||
@@ -0,0 +1,96 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local lfs = require("lfs") | ||
3 | |||
4 | expose("Basic tests #blackbox #b_util", function() | ||
5 | |||
6 | before_each(function() | ||
7 | test_env.setup_specs(extra_rocks) | ||
8 | testing_paths = test_env.testing_paths | ||
9 | env_variables = test_env.env_variables | ||
10 | run = test_env.run | ||
11 | end) | ||
12 | |||
13 | it("LuaRocks version", function() | ||
14 | assert.is_true(run.luarocks_bool("--version")) | ||
15 | end) | ||
16 | |||
17 | it("LuaRocks unknown command", function() | ||
18 | assert.is_false(run.luarocks_bool("unknown_command")) | ||
19 | end) | ||
20 | |||
21 | it("LuaRocks arguments fail", function() | ||
22 | assert.is_false(run.luarocks_bool("--porcelain=invalid")) | ||
23 | assert.is_false(run.luarocks_bool("--invalid-flag")) | ||
24 | assert.is_false(run.luarocks_bool("--server")) | ||
25 | assert.is_false(run.luarocks_bool("--server --porcelain")) | ||
26 | assert.is_false(run.luarocks_bool("--invalid-flag=abc")) | ||
27 | assert.is_false(run.luarocks_bool("invalid=5")) | ||
28 | end) | ||
29 | |||
30 | it("LuaRocks execute from not existing directory", function() | ||
31 | local main_path = lfs.currentdir() | ||
32 | assert.is_true(lfs.mkdir("idontexist")) | ||
33 | assert.is_true(lfs.chdir("idontexist")) | ||
34 | local delete_path = lfs.currentdir() | ||
35 | assert.is_true(os.remove(delete_path)) | ||
36 | |||
37 | assert.is_false(run.luarocks_bool(" ")) | ||
38 | assert.is_true(lfs.chdir(main_path)) | ||
39 | assert.is_true(run.luarocks_bool(" ")) | ||
40 | end) | ||
41 | |||
42 | it("LuaRocks timeout", function() | ||
43 | assert.is_true(run.luarocks_bool("--timeout=10")) | ||
44 | end) | ||
45 | |||
46 | it("LuaRocks timeout invalid", function() | ||
47 | assert.is_false(run.luarocks_bool("--timeout=abc")) | ||
48 | end) | ||
49 | |||
50 | it("LuaRocks only server=testing", function() | ||
51 | assert.is_true(run.luarocks_bool("--only-server=testing")) | ||
52 | end) | ||
53 | |||
54 | it("LuaRocks test site config", function() | ||
55 | assert.is.truthy(os.rename("src/luarocks/site_config.lua", "src/luarocks/site_config.lua.tmp")) | ||
56 | assert.is.falsy(lfs.attributes("src/luarocks/site_config.lua")) | ||
57 | assert.is.truthy(lfs.attributes("src/luarocks/site_config.lua.tmp")) | ||
58 | |||
59 | assert.is_true(run.luarocks_bool("")) | ||
60 | |||
61 | assert.is.truthy(os.rename("src/luarocks/site_config.lua.tmp", "src/luarocks/site_config.lua")) | ||
62 | assert.is.falsy(lfs.attributes("src/luarocks/site_config.lua.tmp")) | ||
63 | assert.is.truthy(lfs.attributes("src/luarocks/site_config.lua")) | ||
64 | end) | ||
65 | |||
66 | describe("LuaRocks sysconfig fails", function() | ||
67 | local scdir = "" | ||
68 | |||
69 | before_each(function() | ||
70 | scdir = testing_paths.testing_lrprefix .. "/etc/luarocks/" | ||
71 | lfs.mkdir(testing_paths.testing_lrprefix) | ||
72 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") | ||
73 | lfs.mkdir(scdir) | ||
74 | end) | ||
75 | |||
76 | after_each(function() | ||
77 | test_env.remove_dir(testing_paths.testing_lrprefix) | ||
78 | end) | ||
79 | |||
80 | it("LuaRocks sysconfig fail", function() | ||
81 | local sysconfig = io.open(scdir .. "/config.lua", "w+") | ||
82 | sysconfig:write("aoeui") | ||
83 | sysconfig:close() | ||
84 | |||
85 | assert.is_false(run.luarocks_bool("list")) | ||
86 | end) | ||
87 | |||
88 | it("LuaRocks sysconfig fail", function() | ||
89 | local sysconfig = io.open(scdir .. "/config-" .. env_variables.LUA_VERSION .. ".lua", "w+") | ||
90 | sysconfig:write("aoeui") | ||
91 | sysconfig:close() | ||
92 | |||
93 | assert.is_false(run.luarocks_bool("list")) | ||
94 | end) | ||
95 | end) | ||
96 | end) | ||
diff --git a/spec/write_rockspec_spec.lua b/spec/write_rockspec_spec.lua new file mode 100644 index 00000000..d6e32f15 --- /dev/null +++ b/spec/write_rockspec_spec.lua | |||
@@ -0,0 +1,74 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local lfs = require("lfs") | ||
3 | |||
4 | test_env.unload_luarocks() | ||
5 | local write_rockspec = require("luarocks.write_rockspec") | ||
6 | |||
7 | expose("LuaRocks write_rockspec tests #blackbox #b_write_rockspec", function() | ||
8 | |||
9 | before_each(function() | ||
10 | test_env.setup_specs(extra_rocks) | ||
11 | run = test_env.run | ||
12 | end) | ||
13 | |||
14 | describe("LuaRocks write_rockspec basic tests", function() | ||
15 | it("LuaRocks write_rockspec with no flags/arguments", function() | ||
16 | assert.is_true(run.luarocks_bool("write_rockspec")) | ||
17 | os.remove("luarocks-scm-1.rockspec") | ||
18 | end) | ||
19 | |||
20 | it("LuaRocks write_rockspec with invalid argument", function() | ||
21 | assert.is_false(run.luarocks_bool("write_rockspec invalid")) | ||
22 | end) | ||
23 | |||
24 | it("LuaRocks write_rockspec invalid zip", function() | ||
25 | assert.is_false(run.luarocks_bool("write_rockspec http://example.com/invalid.zip")) | ||
26 | end) | ||
27 | end) | ||
28 | |||
29 | describe("LuaRocks write_rockspec more complex tests", function() | ||
30 | it("LuaRocks write_rockspec git luarocks", function() | ||
31 | assert.is_true(run.luarocks_bool("write_rockspec git://github.com/keplerproject/luarocks")) | ||
32 | assert.is.truthy(lfs.attributes("luarocks-scm-1.rockspec")) | ||
33 | assert.is_true(os.remove("luarocks-scm-1.rockspec")) | ||
34 | end) | ||
35 | |||
36 | it("LuaRocks write_rockspec git luarocks --tag=v2.3.0", function() | ||
37 | assert.is_true(run.luarocks_bool("write_rockspec git://github.com/keplerproject/luarocks --tag=v2.3.0")) | ||
38 | assert.is.truthy(lfs.attributes("luarocks-2.3.0-1.rockspec")) | ||
39 | assert.is_true(os.remove("luarocks-2.3.0-1.rockspec")) | ||
40 | end) | ||
41 | |||
42 | it("LuaRocks write_rockspec git luarocks with format flag", function() | ||
43 | assert.is_true(run.luarocks_bool("write_rockspec git://github.com/mbalmer/luarocks --rockspec-format=1.1 --lua-version=5.1,5.2")) | ||
44 | assert.is.truthy(lfs.attributes("luarocks-scm-1.rockspec")) | ||
45 | assert.is_true(os.remove("luarocks-scm-1.rockspec")) | ||
46 | end) | ||
47 | |||
48 | it("LuaRocks write_rockspec git luarocks with full flags", function() | ||
49 | assert.is_true(run.luarocks_bool("write_rockspec git://github.com/mbalmer/luarocks --lua-version=5.1,5.2 --license=\"MIT/X11\" " | ||
50 | .. " --homepage=\"http://www.luarocks.org\" --summary=\"A package manager for Lua modules\" ")) | ||
51 | assert.is.truthy(lfs.attributes("luarocks-scm-1.rockspec")) | ||
52 | assert.is_true(os.remove("luarocks-scm-1.rockspec")) | ||
53 | end) | ||
54 | |||
55 | it("LuaRocks write_rockspec rockspec via http", function() | ||
56 | assert.is_true(run.luarocks_bool("write_rockspec http://luarocks.org/releases/luarocks-2.1.0.tar.gz --lua-version=5.1")) | ||
57 | assert.is.truthy(lfs.attributes("luarocks-2.1.0-1.rockspec")) | ||
58 | assert.is_true(os.remove("luarocks-2.1.0-1.rockspec")) | ||
59 | end) | ||
60 | |||
61 | it("LuaRocks write_rockspec base dir, luassert.tar.gz via https", function() | ||
62 | assert.is_true(run.luarocks_bool("write_rockspec https://github.com/downloads/Olivine-Labs/luassert/luassert-1.2.tar.gz --lua-version=5.1")) | ||
63 | assert.is.truthy(lfs.attributes("luassert-1.2-1.rockspec")) | ||
64 | assert.is_true(os.remove("luassert-1.2-1.rockspec")) | ||
65 | end) | ||
66 | |||
67 | it("LuaRocks write_rockspec git luafcgi with many flags", function() | ||
68 | assert.is_true(run.luarocks_bool("write_rockspec git://github.com/mbalmer/luafcgi --lib=fcgi --license=\"3-clause BSD\" " | ||
69 | .. "--lua-version=5.1,5.2")) | ||
70 | assert.is.truthy(lfs.attributes("luafcgi-scm-1.rockspec")) -- TODO maybe read it content and find arguments from flags? | ||
71 | assert.is_true(os.remove("luafcgi-scm-1.rockspec")) | ||
72 | end) | ||
73 | end) | ||
74 | end) \ No newline at end of file | ||