aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorHisham <hisham@gobolinux.org>2016-07-28 17:24:15 -0300
committerHisham <hisham@gobolinux.org>2016-07-28 17:24:15 -0300
commitaccce73cf90bde70baa3d8101b76ca56b0cb0720 (patch)
tree705bb1ba44cd07f9b701cb8d6cf969d7bb48fd72 /spec
parent5f5b26206068ba597091bb6fc22d8d63c0fef408 (diff)
parent67a737310b31eed8d1c38eb0e34ff4b6fc411731 (diff)
downloadluarocks-accce73cf90bde70baa3d8101b76ca56b0cb0720.tar.gz
luarocks-accce73cf90bde70baa3d8101b76ca56b0cb0720.tar.bz2
luarocks-accce73cf90bde70baa3d8101b76ca56b0cb0720.zip
Merge branch 'master' into luarocks-3
Diffstat (limited to 'spec')
-rw-r--r--spec/add_spec.lua44
-rw-r--r--spec/build_spec.lua181
-rw-r--r--spec/config_spec.lua90
-rw-r--r--spec/deps_spec.lua114
-rw-r--r--spec/doc_spec.lua71
-rw-r--r--spec/download_spec.lua36
-rw-r--r--spec/fetch_spec.lua15
-rw-r--r--spec/help_spec.lua27
-rw-r--r--spec/install_spec.lua129
-rw-r--r--spec/lint_spec.lua49
-rw-r--r--spec/list_spec.lua39
-rw-r--r--spec/make_manifest_spec.lua17
-rw-r--r--spec/make_spec.lua98
-rw-r--r--spec/new_version_spec.lua73
-rw-r--r--spec/pack_spec.lua59
-rw-r--r--spec/path_spec.lua26
-rw-r--r--spec/purge_spec.lua28
-rw-r--r--spec/refresh_cache_spec.lua17
-rw-r--r--spec/remove_spec.lua85
-rw-r--r--spec/search_spec.lua36
-rw-r--r--spec/show_spec.lua54
-rw-r--r--spec/unpack_spec.lua67
-rw-r--r--spec/upload_spec.lua74
-rw-r--r--spec/util_spec.lua99
-rw-r--r--spec/write_rockspec_spec.lua72
25 files changed, 1600 insertions, 0 deletions
diff --git a/spec/add_spec.lua b/spec/add_spec.lua
new file mode 100644
index 00000000..dca6f850
--- /dev/null
+++ b/spec/add_spec.lua
@@ -0,0 +1,44 @@
1local test_env = require("test/test_environment")
2local run = test_env.run
3local testing_paths = test_env.testing_paths
4
5test_env.unload_luarocks()
6
7local extra_rocks = {
8 "/luasocket-3.0rc1-1.src.rock",
9 "/luasocket-3.0rc1-1.rockspec"
10}
11
12describe("LuaRocks add tests #blackbox #b_add", function()
13
14 before_each(function()
15 test_env.setup_specs(extra_rocks)
16 end)
17
18 describe("LuaRocks-admin add tests", function()
19 it("LuaRocks-admin add invalid rock #ssh", function()
20 assert.is_false(run.luarocks_admin_bool("--server=testing add invalid"))
21 end)
22
23 it("LuaRocks-admin add missing argument", function()
24 assert.is_false(run.luarocks_admin_bool("--server=testing add"))
25 end)
26
27 it("LuaRocks-admin add invalid server", function()
28 assert.is_false(run.luarocks_admin_bool("--server=invalid add " .. testing_paths.testing_server .. "/luasocket-3.0rc1-1.src.rock"))
29 end)
30
31 it("LuaRocks-admin add invalid server #ssh", function()
32 assert.is_true(run.luarocks_admin_bool("--server=testing add " .. testing_paths.testing_server .. "/luasocket-3.0rc1-1.src.rock"))
33 end)
34
35 --TODO This test fails, sftp not implemented
36 it("LuaRocks-admin add invalid server", function() --?
37 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" } ))
38 end)
39
40 it("LuaRocks-admin add, split server url", function()
41 assert.is_false(run.luarocks_admin_bool("--server=\"localhost@/tmp/luarocks_testing\" add " .. testing_paths.testing_server .. "luasocket-3.0rc1-1.src.rock"))
42 end)
43 end)
44end)
diff --git a/spec/build_spec.lua b/spec/build_spec.lua
new file mode 100644
index 00000000..2ede5211
--- /dev/null
+++ b/spec/build_spec.lua
@@ -0,0 +1,181 @@
1local test_env = require("test/test_environment")
2local lfs = require("lfs")
3local run = test_env.run
4local testing_paths = test_env.testing_paths
5
6test_env.unload_luarocks()
7
8local extra_rocks = {
9 "/lmathx-20120430.51-1.src.rock",
10 "/lmathx-20120430.51-1.rockspec",
11 "/lmathx-20120430.52-1.src.rock",
12 "/lmathx-20120430.52-1.rockspec",
13 "/lmathx-20150505-1.src.rock",
14 "/lmathx-20150505-1.rockspec",
15 "/lpeg-0.12-1.src.rock",
16 "/lpty-1.0.1-1.src.rock",
17 "/luadoc-3.0.1-1.src.rock",
18 "/luafilesystem-1.6.3-1.src.rock",
19 "/lualogging-1.3.0-1.src.rock",
20 "/luarepl-0.4-1.src.rock",
21 "/luasec-0.6-1.rockspec",
22 "/luasocket-3.0rc1-1.src.rock",
23 "/luasocket-3.0rc1-1.rockspec",
24 "/lxsh-0.8.6-2.src.rock",
25 "/lxsh-0.8.6-2.rockspec",
26 "/stdlib-41.0.0-1.src.rock",
27 "/validate-args-1.5.4-1.rockspec"
28}
29
30describe("LuaRocks build tests #blackbox #b_build", function()
31
32 before_each(function()
33 test_env.setup_specs(extra_rocks)
34 end)
35
36 describe("LuaRocks build - basic testing set", function()
37 it("LuaRocks build with no flags/arguments", function()
38 assert.is_false(run.luarocks_bool("build"))
39 end)
40
41 it("LuaRocks build invalid", function()
42 assert.is_false(run.luarocks_bool("build invalid"))
43 end)
44 end)
45
46 describe("LuaRocks build - building lpeg with flags", function()
47 it("LuaRocks build fail build permissions", function()
48 if test_env.TEST_TARGET_OS == "osx" or test_env.TEST_TARGET_OS == "linux" then
49 assert.is_false(run.luarocks_bool("build --tree=/usr lpeg"))
50 end
51 end)
52
53 it("LuaRocks build fail build permissions parent", function()
54 if test_env.TEST_TARGET_OS == "osx" or test_env.TEST_TARGET_OS == "linux" then
55 assert.is_false(run.luarocks_bool("build --tree=/usr/invalid lpeg"))
56 end
57 end)
58
59 it("LuaRocks build lpeg verbose", function()
60 assert.is.truthy(run.luarocks("build --verbose lpeg"))
61 end)
62
63 it("LuaRocks build lpeg branch=master", function()
64 assert.is_true(run.luarocks_bool("build --branch=master lpeg"))
65 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg"))
66 end)
67
68 it("LuaRocks build lpeg deps-mode=123", function()
69 assert.is_false(run.luarocks_bool("build --deps-mode=123 lpeg"))
70 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg"))
71 end)
72
73 it("LuaRocks build lpeg only-sources example", function()
74 assert.is_true(run.luarocks_bool("build --only-sources=\"http://example.com\" lpeg"))
75 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg"))
76 end)
77
78 it("LuaRocks build lpeg with empty tree", function()
79 assert.is_false(run.luarocks_bool("build --tree=\"\" lpeg"))
80 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg"))
81 end)
82 end)
83
84 describe("LuaRocks build - basic builds", function()
85 it("LuaRocks build luadoc", function()
86 assert.is_true(run.luarocks_bool(test_env.quiet("build luadoc")))
87 end)
88
89 it("LuaRocks build luacov diff version", function()
90 assert.is_true(run.luarocks_bool("build luacov 0.11.0-1"))
91 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luacov"))
92 end)
93
94 it("LuaRocks build command stdlib", function()
95 assert.is_true(run.luarocks_bool("build stdlib"))
96 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/stdlib"))
97 end)
98
99 it("LuaRocks build install bin luarepl", function()
100 assert.is_true(run.luarocks_bool("build luarepl"))
101 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luarepl"))
102 end)
103
104 it("LuaRocks build supported platforms lpty", function()
105 assert.is_true(run.luarocks_bool(test_env.quiet("build lpty")))
106 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpty"))
107 end)
108
109 it("LuaRocks build luasec with skipping dependency checks", function()
110 assert.is_true(run.luarocks_bool(test_env.quiet("build luasec --nodeps")))
111 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec"))
112 end)
113
114 it("LuaRocks build lmathx deps partial match", function()
115 assert.is_true(run.luarocks_bool("build lmathx"))
116 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lmathx"))
117 end)
118 end)
119
120 describe("LuaRocks build - more complex tests", function()
121 if test_env.TYPE_TEST_ENV == "full" then
122 it("LuaRocks build luacheck show downloads test_config", function()
123 local output = run.luarocks("build luacheck", { LUAROCKS_CONFIG = testing_paths.testing_dir .. "/testing_config_show_downloads.lua"} )
124 assert.is.truthy(output:match("%.%.%."))
125 end)
126 end
127
128 it("LuaRocks build luasec only deps", function()
129 assert.is_true(run.luarocks_bool(test_env.quiet("build luasec --only-deps")))
130 assert.is_false(run.luarocks_bool("show luasec"))
131 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec"))
132 end)
133
134 it("LuaRocks build only deps of downloaded rockspec of lxsh", function()
135 assert.is_true(run.luarocks_bool("download --rockspec lxsh 0.8.6-2"))
136 assert.is.truthy(run.luarocks("build lxsh-0.8.6-2.rockspec --only-deps"))
137 assert.is_false(run.luarocks_bool("show lxsh"))
138 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh"))
139 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg"))
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.truthy(run.luarocks("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.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg"))
149 assert.is_true(os.remove("lxsh-0.8.6-2.src.rock"))
150 end)
151
152 it("LuaRocks build no https", function()
153 assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1"))
154 assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec"))
155
156 assert.is.truthy(run.luarocks("show validate-args"))
157 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/validate-args"))
158
159 assert.is_true(os.remove("validate-args-1.5.4-1.rockspec"))
160 end)
161
162 it("LuaRocks build with https", function()
163 assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1"))
164 assert.is_true(run.luarocks_bool(test_env.quiet("install luasec")))
165 assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec"))
166
167 assert.is.truthy(run.luarocks("show validate-args"))
168 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/validate-args"))
169
170 assert.is_true(os.remove("validate-args-1.5.4-1.rockspec"))
171 end)
172
173 it("LuaRocks build missing external", function()
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_false(run.luarocks_bool("build " .. testing_paths.testing_dir .. "/testfiles/invalid_patch-0.1-1.rockspec"))
179 end)
180 end)
181end)
diff --git a/spec/config_spec.lua b/spec/config_spec.lua
new file mode 100644
index 00000000..0dee8620
--- /dev/null
+++ b/spec/config_spec.lua
@@ -0,0 +1,90 @@
1local test_env = require("test/test_environment")
2local lfs = require("lfs")
3local run = test_env.run
4local testing_paths = test_env.testing_paths
5local site_config
6
7test_env.unload_luarocks()
8
9describe("LuaRocks config tests #blackbox #b_config", function()
10
11 before_each(function()
12 test_env.setup_specs()
13 test_env.unload_luarocks() -- need to be required here, because site_config is created after first loading of specs
14 site_config = require("luarocks.site_config")
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)
90end)
diff --git a/spec/deps_spec.lua b/spec/deps_spec.lua
new file mode 100644
index 00000000..c1bd404d
--- /dev/null
+++ b/spec/deps_spec.lua
@@ -0,0 +1,114 @@
1local test_env = require("test/test_environment")
2local lfs = require("lfs")
3local run = test_env.run
4local testing_paths = test_env.testing_paths
5
6test_env.unload_luarocks()
7
8local extra_rocks = {
9 "/lxsh-0.8.6-2.src.rock",
10 "/lxsh-0.8.6-2.rockspec",
11 "/luasocket-3.0rc1-1.src.rock",
12 "/luasocket-3.0rc1-1.rockspec",
13 "/lpeg-0.12-1.src.rock"
14}
15
16describe("LuaRocks deps tests #blackbox #b_deps", function()
17
18 before_each(function()
19 test_env.setup_specs(extra_rocks)
20 end)
21
22 it("LuaRocks deps mode one", function()
23 assert.is_true(run.luarocks_bool("build --tree=system lpeg"))
24 assert.is_true(run.luarocks_bool("build --deps-mode=one --tree=" .. testing_paths.testing_tree .. " lxsh"))
25
26 assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg"))
27 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg"))
28 assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh"))
29 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh"))
30 end)
31
32 it("LuaRocks deps mode order", function()
33 assert.is_true(run.luarocks_bool("build --tree=system lpeg"))
34 assert.is_true(run.luarocks_bool("build --deps-mode=order --tree=" .. testing_paths.testing_tree .. " lxsh"))
35
36 assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg"))
37 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg"))
38 assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh"))
39 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh"))
40 end)
41
42 it("LuaRocks deps mode order sys", function()
43 assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg"))
44 assert.is_true(run.luarocks_bool("build --deps-mode=order --tree=" .. testing_paths.testing_sys_tree .. " lxsh"))
45
46 assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg"))
47 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg"))
48 assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh"))
49 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh"))
50 end)
51
52 it("LuaRocks deps mode all sys", function()
53 assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg"))
54 assert.is_true(run.luarocks_bool("build --deps-mode=all --tree=" .. testing_paths.testing_sys_tree .. " lxsh"))
55
56 assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg"))
57 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg"))
58 assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh"))
59 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh"))
60 end)
61
62 it("LuaRocks deps mode none", function()
63 assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg"))
64 assert.is_true(run.luarocks_bool("build --deps-mode=none lxsh"))
65
66 assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg"))
67 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg"))
68 assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh"))
69 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh"))
70 end)
71
72 it("LuaRocks nodeps alias", function()
73 assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " --nodeps lxsh"))
74
75 assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg"))
76 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg"))
77 assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh"))
78 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh"))
79 end)
80
81 it("LuaRocks deps mode make order", function()
82 assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_sys_tree .. " lpeg"))
83 assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6"))
84 assert.is_true(run.luarocks_bool("unpack lxsh-0.8.6-2.src.rock"))
85 lfs.chdir("lxsh-0.8.6-2/lxsh-0.8.6-1/")
86 assert.is_true(run.luarocks_bool("make --tree=" .. testing_paths.testing_tree .. " --deps-mode=order"))
87
88 lfs.chdir(testing_paths.luarocks_dir)
89 test_env.remove_dir("lxsh-0.8.6-2")
90 assert.is_true(os.remove("lxsh-0.8.6-2.src.rock"))
91
92 assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg"))
93 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg"))
94 assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh"))
95 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh"))
96 end)
97
98 it("LuaRocks deps mode make order sys", function()
99 assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg"))
100 assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6"))
101 assert.is_true(run.luarocks_bool("unpack lxsh-0.8.6-2.src.rock"))
102 lfs.chdir("lxsh-0.8.6-2/lxsh-0.8.6-1/")
103 assert.is_true(run.luarocks_bool("make --tree=" .. testing_paths.testing_sys_tree .. " --deps-mode=order"))
104
105 lfs.chdir(testing_paths.luarocks_dir)
106 test_env.remove_dir("lxsh-0.8.6-2")
107 assert.is_true(os.remove("lxsh-0.8.6-2.src.rock"))
108
109 assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg"))
110 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg"))
111 assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh"))
112 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh"))
113 end)
114end)
diff --git a/spec/doc_spec.lua b/spec/doc_spec.lua
new file mode 100644
index 00000000..a04d3c14
--- /dev/null
+++ b/spec/doc_spec.lua
@@ -0,0 +1,71 @@
1local test_env = require("test/test_environment")
2local run = test_env.run
3local testing_paths = test_env.testing_paths
4
5test_env.unload_luarocks()
6
7local extra_rocks = {
8 "/luarepl-0.4-1.src.rock",
9 "/c3-1.0-1.src.rock"
10}
11
12describe("LuaRocks doc tests #blackbox #b_doc", function()
13
14 before_each(function()
15 test_env.setup_specs(extra_rocks)
16 end)
17
18 describe("LuaRocks doc basic tests", function()
19 it("LuaRocks doc with no flags/arguments", function()
20 assert.is_false(run.luarocks_bool("doc"))
21 end)
22 it("LuaRocks doc with invalid argument", function()
23 assert.is_false(run.luarocks_bool("doc invalid"))
24 end)
25 it("LuaRocks doc with no homepage", function()
26 assert.is_true(run.luarocks_bool("install c3"))
27 assert.is_false(run.luarocks_bool("doc c3 --home"))
28 end)
29 it("LuaRocks doc with no home page and no doc folder", function()
30 assert.is_true(run.luarocks_bool("install c3"))
31 test_env.remove_dir(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/c3/1.0-1/doc")
32 assert.is_false(run.luarocks_bool("doc c3"))
33 end)
34 it("LuaRocks doc with no doc folder opening descript.homepage", function()
35 assert.is_true(run.luarocks_bool("install luarepl"))
36 test_env.remove_dir(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luarepl/0.4-1/doc")
37 local output = run.luarocks("doc luarepl")
38 assert.is.truthy(output:find("Local documentation directory not found"))
39 end)
40 end)
41
42 describe("LuaRocks doc tests with flags", function()
43 it("LuaRocks doc of installed luarepl", function()
44 assert.is_true(run.luarocks_bool("install luarepl"))
45 assert.is_true(run.luarocks_bool("doc luarepl"))
46 end)
47
48 it("LuaRocks doc of luacov and access its home page", function()
49 assert.is_true(run.luarocks_bool("install luacov"))
50 assert.is_true(run.luarocks_bool("doc luacov --home"))
51 end)
52
53 it("LuaRocks doc of luacov and list doc folder", function()
54 assert.is_true(run.luarocks_bool("install luacov"))
55 local output = assert.is.truthy(run.luarocks("doc luacov --list"))
56 assert.is.truthy(output:find("/lib/luarocks/rocks/luacov/0.11.0--1/doc/"))
57 end)
58
59 it("LuaRocks doc of luacov local", function()
60 assert.is_true(run.luarocks_bool("install luacov"))
61 assert.is_true(run.luarocks_bool("doc luacov --local"))
62 end)
63
64 it("LuaRocks doc of luacov porcelain", function()
65 assert.is_true(run.luarocks_bool("install luacov"))
66 assert.is_true(run.luarocks_bool("doc luacov --porcelain"))
67 end)
68 end)
69end)
70
71
diff --git a/spec/download_spec.lua b/spec/download_spec.lua
new file mode 100644
index 00000000..320d9304
--- /dev/null
+++ b/spec/download_spec.lua
@@ -0,0 +1,36 @@
1local test_env = require("test/test_environment")
2local lfs = require("lfs")
3local run = test_env.run
4
5test_env.unload_luarocks()
6
7local extra_rocks = {
8 "/validate-args-1.5.4-1.rockspec"
9}
10
11describe("LuaRocks download tests #blackbox #b_download", function()
12
13 before_each(function()
14 test_env.setup_specs(extra_rocks)
15 end)
16
17 it("LuaRocks download with no flags/arguments", function()
18 assert.is_false(run.luarocks_bool("download"))
19 end)
20
21 it("LuaRocks download invalid", function()
22 assert.is_false(run.luarocks_bool("download invalid"))
23 end)
24
25 it("LuaRocks download all with delete downloaded files", function() --TODO maybe download --all more rocks
26 assert.is_true(run.luarocks_bool("download --all validate-args"))
27 assert.is.truthy(lfs.attributes("validate-args-1.5.4-1.rockspec"))
28 test_env.remove_files(lfs.currentdir(), "validate--args--")
29 end)
30
31 it("LuaRocks download rockspec version", function()
32 assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1"))
33 assert.is.truthy(lfs.attributes("validate-args-1.5.4-1.rockspec"))
34 test_env.remove_files(lfs.currentdir(), "validate--args--")
35 end)
36end)
diff --git a/spec/fetch_spec.lua b/spec/fetch_spec.lua
new file mode 100644
index 00000000..05a709e4
--- /dev/null
+++ b/spec/fetch_spec.lua
@@ -0,0 +1,15 @@
1local test_env = require("test/test_environment")
2
3test_env.unload_luarocks()
4local fetch = require("luarocks.fetch")
5
6describe("Luarocks fetch test #whitebox #w_fetch", function()
7 it("Fetch url to base dir", function()
8 assert.are.same("v0.3", fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2/archive/v0.3.zip"))
9 assert.are.same("lua-compat-5.2", fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2.zip"))
10 assert.are.same("lua-compat-5.2", fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2.tar.gz"))
11 assert.are.same("lua-compat-5.2", fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2.tar.bz2"))
12 assert.are.same("parser.moon", fetch.url_to_base_dir("git://github.com/Cirru/parser.moon"))
13 assert.are.same("v0.3", fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2/archive/v0.3"))
14 end)
15end)
diff --git a/spec/help_spec.lua b/spec/help_spec.lua
new file mode 100644
index 00000000..88aa5030
--- /dev/null
+++ b/spec/help_spec.lua
@@ -0,0 +1,27 @@
1local test_env = require("test/test_environment")
2local run = test_env.run
3
4test_env.unload_luarocks()
5
6describe("LuaRocks help tests #blackbox #b_help", function()
7
8 before_each(function()
9 test_env.setup_specs()
10 end)
11
12 it("LuaRocks help with no flags/arguments", function()
13 assert.is_true(run.luarocks_bool(test_env.quiet("help")))
14 end)
15
16 it("LuaRocks help invalid argument", function()
17 assert.is_false(run.luarocks_bool("help invalid"))
18 end)
19
20 it("LuaRocks help config", function()
21 assert.is_true(run.luarocks_bool(test_env.quiet("help config")))
22 end)
23
24 it("LuaRocks-admin help with no flags/arguments", function()
25 assert.is_true(run.luarocks_admin_bool(test_env.quiet("help")))
26 end)
27end)
diff --git a/spec/install_spec.lua b/spec/install_spec.lua
new file mode 100644
index 00000000..bd480c21
--- /dev/null
+++ b/spec/install_spec.lua
@@ -0,0 +1,129 @@
1local test_env = require("test/test_environment")
2local lfs = require("lfs")
3local run = test_env.run
4local testing_paths = test_env.testing_paths
5local env_variables = test_env.env_variables
6
7test_env.unload_luarocks()
8
9local extra_rocks = {
10 "/cprint-0.1-2.src.rock",
11 "/cprint-0.1-2.rockspec",
12 "/lpeg-0.12-1.src.rock",
13 "/luasec-0.6-1.rockspec",
14 "/luassert-1.7.0-1.src.rock",
15 "/luasocket-3.0rc1-1.src.rock",
16 "/luasocket-3.0rc1-1.rockspec",
17 "/lxsh-0.8.6-2.src.rock",
18 "/lxsh-0.8.6-2.rockspec",
19 "/say-1.2-1.src.rock",
20 "/say-1.0-1.src.rock",
21 "/wsapi-1.6-1.src.rock"
22}
23
24describe("LuaRocks install tests #blackbox #b_install", function()
25
26 before_each(function()
27 test_env.setup_specs(extra_rocks)
28 end)
29
30 describe("LuaRocks install - basic tests", function()
31 it("LuaRocks install with no flags/arguments", function()
32 assert.is_false(run.luarocks_bool("install"))
33 end)
34
35 it("LuaRocks install with invalid argument", function()
36 assert.is_false(run.luarocks_bool("install invalid"))
37 end)
38
39 it("LuaRocks install invalid patch", function()
40 assert.is_false(run.luarocks_bool("install " .. testing_paths.testing_dir .. "/testfiles/invalid_patch-0.1-1.rockspec"))
41 end)
42
43 it("LuaRocks install invalid rock", function()
44 assert.is_false(run.luarocks_bool("install \"invalid.rock\" "))
45 end)
46
47 it("LuaRocks install with local flag as root", function()
48 assert.is_false(run.luarocks_bool("install --local luasocket", { USER = "root" } ))
49 end)
50
51 it("LuaRocks install not a zip file", function()
52 assert.is_false(run.luarocks_bool("install " .. testing_paths.testing_dir .. "/testfiles/not_a_zipfile-1.0-1.src.rock"))
53 end)
54
55 it("LuaRocks install only-deps of lxsh show there is no lxsh", function()
56 assert.is_true(run.luarocks_bool("install lxsh 0.8.6-2 --only-deps"))
57 assert.is_false(run.luarocks_bool("show lxsh"))
58 end)
59
60 it("LuaRocks install incompatible architecture", function()
61 assert.is_false(run.luarocks_bool("install \"foo-1.0-1.impossible-x86.rock\" "))
62 end)
63
64 it("LuaRocks install wsapi with bin", function()
65 run.luarocks_bool("install wsapi")
66 end)
67
68 it("LuaRocks install luasec and show luasocket (dependency)", function()
69 assert.is_true(run.luarocks_bool("install luasec"))
70 assert.is_true(run.luarocks_bool("show luasocket"))
71 end)
72 end)
73
74 describe("LuaRocks install - more complex tests", function()
75 it('LuaRocks install luasec with skipping dependency checks', function()
76 run.luarocks_bool(test_env.quiet(" install luasec --nodeps"))
77 assert.is_true(run.luarocks_bool(test_env.quiet("show luasec")))
78 if env_variables.TYPE_TEST_ENV == "minimal" then
79 assert.is_false(run.luarocks_bool(test_env.quiet("show luasocket")))
80 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket"))
81 end
82 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec"))
83 end)
84
85 it("LuaRocks install only-deps of luasocket packed rock", function()
86 assert.is_true(run.luarocks_bool(test_env.quiet("build --pack-binary-rock luasocket 3.0rc1-1")))
87 local output = run.luarocks("install --only-deps " .. "luasocket-3.0rc1-1." .. test_env.platform .. ".rock")
88 assert.are.same(output, "Successfully installed dependencies for luasocket 3.0rc1-1")
89 assert.is_true(os.remove("luasocket-3.0rc1-1." .. test_env.platform .. ".rock"))
90 end)
91
92 it("LuaRocks install reinstall", function()
93 assert.is_true(run.luarocks_bool(test_env.quiet("build --pack-binary-rock luasocket 3.0rc1-1")))
94 assert.is_true(run.luarocks_bool("install " .. "luasocket-3.0rc1-1." .. test_env.platform .. ".rock"))
95 assert.is_true(run.luarocks_bool("install --deps-mode=none " .. "luasocket-3.0rc1-1." .. test_env.platform .. ".rock"))
96 assert.is_true(os.remove("luasocket-3.0rc1-1." .. test_env.platform .. ".rock"))
97 end)
98
99 it("LuaRocks install binary rock of cprint", function()
100 assert.is_true(run.luarocks_bool(test_env.quiet("build --pack-binary-rock cprint")))
101 assert.is_true(run.luarocks_bool("install cprint-0.1-2." .. test_env.platform .. ".rock"))
102 assert.is_true(os.remove("cprint-0.1-2." .. test_env.platform .. ".rock"))
103 end)
104 end)
105
106 describe("New install functionality based on pull request 552", function()
107 it("LuaRocks install break dependencies warning", function()
108 assert.is_true(run.luarocks_bool("install say 1.2"))
109 assert.is_true(run.luarocks_bool("install luassert"))
110 assert.is_true(run.luarocks_bool("install say 1.0"))
111 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/say/1.2-1"))
112 end)
113 it("LuaRocks install break dependencies force", function()
114 assert.is_true(run.luarocks_bool("install say 1.2"))
115 assert.is_true(run.luarocks_bool("install luassert"))
116 local output = run.luarocks("install --force say 1.0")
117 assert.is.truthy(output:find("Checking stability of dependencies"))
118 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/say/1.2-1"))
119 end)
120 it("LuaRocks install break dependencies force fast", function()
121 assert.is_true(run.luarocks_bool("install say 1.2"))
122 assert.is_true(run.luarocks_bool("install luassert"))
123 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/say/1.2-1"))
124 local output = run.luarocks("install --force-fast say 1.0")
125 assert.is.falsy(output:find("Checking stability of dependencies"))
126 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/say/1.0-1"))
127 end)
128 end)
129end)
diff --git a/spec/lint_spec.lua b/spec/lint_spec.lua
new file mode 100644
index 00000000..f7496037
--- /dev/null
+++ b/spec/lint_spec.lua
@@ -0,0 +1,49 @@
1local test_env = require("test/test_environment")
2local run = test_env.run
3local testing_paths = test_env.testing_paths
4
5test_env.unload_luarocks()
6
7local extra_rocks = {
8 "/validate-args-1.5.4-1.rockspec"
9}
10
11describe("LuaRocks lint tests #blackbox #b_lint", function()
12
13 before_each(function()
14 test_env.setup_specs(extra_rocks)
15 end)
16
17 it("LuaRocks lint with no flags/arguments", function()
18 assert.is_false(run.luarocks_bool("lint"))
19 end)
20
21 it("LuaRocks lint invalid argument", function()
22 assert.is_false(run.luarocks_bool("lint invalid"))
23 end)
24
25 it("LuaRocks lint OK", function()
26 assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1"))
27 local output = run.luarocks("lint validate-args-1.5.4-1.rockspec")
28 assert.are.same(output, "")
29 assert.is_true(os.remove("validate-args-1.5.4-1.rockspec"))
30 end)
31
32 describe("LuaRocks lint mismatch set", function()
33 it("LuaRocks lint mismatch string", function()
34 assert.is_false(run.luarocks_bool("lint " .. testing_paths.testing_dir .. "/testfiles/type_mismatch_string-1.0-1.rockspec"))
35 end)
36
37 it("LuaRocks lint mismatch version", function()
38 assert.is_false(run.luarocks_bool("lint " .. testing_paths.testing_dir .. "/testfiles/type_mismatch_version-1.0-1.rockspec"))
39 end)
40
41 it("LuaRocks lint mismatch table", function()
42 assert.is_false(run.luarocks_bool("lint " .. testing_paths.testing_dir .. "/testfiles/type_mismatch_table-1.0-1.rockspec"))
43 end)
44
45 it("LuaRocks lint mismatch no build table", function()
46 assert.is_false(run.luarocks_bool("lint " .. testing_paths.testing_dir .. "/testfiles/no_build_table-1.0-1.rockspec"))
47 end)
48 end)
49end)
diff --git a/spec/list_spec.lua b/spec/list_spec.lua
new file mode 100644
index 00000000..1b082ab6
--- /dev/null
+++ b/spec/list_spec.lua
@@ -0,0 +1,39 @@
1local test_env = require("test/test_environment")
2local run = test_env.run
3local testing_paths = test_env.testing_paths
4
5test_env.unload_luarocks()
6
7local extra_rocks = {
8 "/say-1.0-1.src.rock",
9 "/say-1.2-1.src.rock"
10}
11
12describe("LuaRocks list tests #blackbox #b_list", function()
13
14 before_each(function()
15 test_env.setup_specs(extra_rocks)
16 end)
17
18 it("LuaRocks list with no flags/arguments", function()
19 local output = run.luarocks("list")
20 assert.is.truthy(output:find("luacov"))
21 end)
22
23 it("LuaRocks list porcelain", function()
24 local output = run.luarocks("list --porcelain")
25 local path = testing_paths.testing_sys_tree:gsub("-", "--") -- !not sure! why this is good
26 assert.is.truthy(output:find("luacov\t0.11.0--1\tinstalled\t" .. path .. "/lib/luarocks/rocks" ))
27 end)
28
29 it("LuaRocks install outdated and list it", function()
30 assert.is_true(run.luarocks_bool("install say 1.0-1"))
31 local output = run.luarocks("list --outdated")
32 assert.is.truthy(output:find("say"))
33 end)
34
35 it("LuaRocks list invalid tree", function()
36 local output = run.luarocks("--tree=/some/invalid/tree list")
37 assert.are.same(output, "Installed rocks:----------------")
38 end)
39end)
diff --git a/spec/make_manifest_spec.lua b/spec/make_manifest_spec.lua
new file mode 100644
index 00000000..1c7f5bf8
--- /dev/null
+++ b/spec/make_manifest_spec.lua
@@ -0,0 +1,17 @@
1local test_env = require("test/test_environment")
2local run = test_env.run
3
4test_env.unload_luarocks()
5
6describe("LuaRocks make_manifest tests #blackbox #b_make_manifest", function()
7
8 before_each(function()
9 test_env.setup_specs()
10 end)
11
12 describe("LuaRocks-admin make manifest tests", function()
13 it("LuaRocks-admin make manifest", function()
14 assert.is_true(run.luarocks_admin_bool("make_manifest"))
15 end)
16 end)
17end)
diff --git a/spec/make_spec.lua b/spec/make_spec.lua
new file mode 100644
index 00000000..e684033a
--- /dev/null
+++ b/spec/make_spec.lua
@@ -0,0 +1,98 @@
1local test_env = require("test/test_environment")
2local lfs = require("lfs")
3local run = test_env.run
4local testing_paths = test_env.testing_paths
5
6test_env.unload_luarocks()
7
8local extra_rocks = {
9 "/lpeg-0.12-1.src.rock",
10 "/luasocket-3.0rc1-1.src.rock",
11 "/luasocket-3.0rc1-1.rockspec",
12 "/lxsh-0.8.6-2.src.rock",
13 "/lxsh-0.8.6-2.rockspec"
14}
15
16describe("LuaRocks make tests #blackbox #b_make", function()
17
18 before_each(function()
19 test_env.setup_specs(extra_rocks)
20 end)
21
22 it("LuaRocks make with no flags/arguments", function()
23 lfs.chdir("test")
24 assert.is_false(run.luarocks_bool("make"))
25 lfs.chdir(testing_paths.luarocks_dir)
26 end)
27
28 it("LuaRocks make with rockspec", function()
29 -- make luasocket
30 assert.is_true(run.luarocks_bool("download --source luasocket 3.0rc1-1"))
31 assert.is_true(run.luarocks_bool("unpack luasocket-3.0rc1-1.src.rock"))
32 lfs.chdir("luasocket-3.0rc1-1/luasocket-3.0-rc1/")
33 assert.is_true(run.luarocks_bool(test_env.quiet("make luasocket-3.0rc1-1.rockspec")))
34
35 -- test it
36 assert.is_true(run.luarocks_bool(test_env.quiet("show luasocket")))
37 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket"))
38
39 -- delete downloaded and unpacked files
40 lfs.chdir(testing_paths.luarocks_dir)
41 test_env.remove_dir("luasocket-3.0rc1-1")
42 assert.is_true(os.remove("luasocket-3.0rc1-1.src.rock"))
43 end)
44
45 describe("LuaRocks making rockspecs (using lxsh)", function()
46 --download lxsh and unpack it
47 before_each(function()
48 assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6-2"))
49 assert.is_true(run.luarocks_bool("unpack lxsh-0.8.6-2.src.rock"))
50 assert.is_true(lfs.chdir("lxsh-0.8.6-2/lxsh-0.8.6-1/"))
51 end)
52
53 -- delete downloaded and unpacked files
54 after_each(function()
55 assert.is_true(lfs.chdir(testing_paths.luarocks_dir))
56 test_env.remove_dir("lxsh-0.8.6-2")
57 assert.is_true(os.remove("lxsh-0.8.6-2.src.rock"))
58 end)
59
60 it("LuaRocks make default rockspec", function()
61 assert.is_true(run.luarocks_bool("new_version lxsh-0.8.6-2.rockspec"))
62 assert.is_true(run.luarocks_bool("make"))
63
64 assert.is_true(run.luarocks_bool(test_env.quiet("show lxsh")))
65 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh"))
66 end)
67
68 it("LuaRocks make unnamed rockspec", function()
69 os.execute("cp lxsh-0.8.6-2.rockspec rockspec") --rewrite with lfs
70 assert.is_true(run.luarocks_bool("make"))
71
72 assert.is_true(run.luarocks_bool(test_env.quiet("show lxsh")))
73 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh"))
74 end)
75
76 it("LuaRocks make ambiguous rockspec", function()
77 assert.is.truthy(os.rename("lxsh-0.8.6-2.rockspec", "lxsh2-0.8.6-2.rockspec"))
78 assert.is_false(run.luarocks_bool("make"))
79
80 assert.is_false(run.luarocks_bool("show lxsh"))
81 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh"))
82 end)
83
84 it("LuaRocks make ambiguous unnamed rockspec", function()
85 assert.is.truthy(os.rename("lxsh-0.8.6-2.rockspec", "1_rockspec"))
86 os.execute("cp 1_rockspec 2_rockspec") --rewrite with lfs
87 assert.is_false(run.luarocks_bool("make"))
88
89 assert.is_false(run.luarocks_bool("show lxsh"))
90 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh"))
91 end)
92
93 it("LuaRocks make pack binary rock", function()
94 assert.is_true(run.luarocks_bool(test_env.quiet("make --deps-mode=none --pack-binary-rock")))
95 assert.is.truthy(lfs.attributes("lxsh-0.8.6-2.all.rock"))
96 end)
97 end)
98end)
diff --git a/spec/new_version_spec.lua b/spec/new_version_spec.lua
new file mode 100644
index 00000000..c4185b1d
--- /dev/null
+++ b/spec/new_version_spec.lua
@@ -0,0 +1,73 @@
1local test_env = require("test/test_environment")
2local lfs = require("lfs")
3local run = test_env.run
4local testing_paths = test_env.testing_paths
5
6test_env.unload_luarocks()
7
8local extra_rocks = {
9 "/abelhas-1.0-1.rockspec",
10 "/lpeg-0.12-1.rockspec"
11}
12
13describe("LuaRocks new_version tests #blackbox #b_new_version", function()
14
15 before_each(function()
16 test_env.setup_specs(extra_rocks)
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
30 it("LuaRocks new version invalid url", function()
31 assert.is_true(run.luarocks_bool("download --rockspec abelhas 1.0"))
32 assert.is_true(run.luarocks_bool("new_version abelhas-1.0-1.rockspec 1.1 http://luainvalid"))
33 assert.is.truthy(lfs.attributes("abelhas-1.1-1.rockspec"))
34 test_env.remove_files(lfs.currentdir(), "abelhas--")
35 end)
36 end)
37
38 describe("LuaRocks new_version more complex tests", function()
39 it("LuaRocks new version with remote spec", function()
40 assert.is_true(run.luarocks_bool("new_version https://luarocks.org/manifests/luarocks/luasocket-2.0.2-6.rockspec"))
41 assert.is.truthy(lfs.attributes("luasocket-2.0.2-6.rockspec"))
42 assert.is.truthy(lfs.attributes("luasocket-2.0.2-7.rockspec"))
43 test_env.remove_files(lfs.currentdir(), "luasocket--")
44 end)
45
46 it("LuaRocks new_version of luacov", 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 0.2"))
49 assert.is.truthy(lfs.attributes("luacov-0.2-1.rockspec"))
50 test_env.remove_files(lfs.currentdir(), "luacov--")
51 end)
52
53 it("LuaRocks new_version url of abelhas", function()
54 assert.is_true(run.luarocks_bool("download --rockspec abelhas 1.0"))
55 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"))
56 assert.is.truthy(lfs.attributes("abelhas-1.1-1.rockspec"))
57 test_env.remove_files(lfs.currentdir(), "abelhas--")
58 end)
59
60 it("LuaRocks new_version of luacov with tag", function()
61 assert.is_true(run.luarocks_bool("download --rockspec luacov 0.11.0"))
62 assert.is_true(run.luarocks_bool("new_version luacov-0.11.0-1.rockspec --tag v0.3"))
63 assert.is.truthy(lfs.attributes("luacov-0.3-1.rockspec"))
64 test_env.remove_files(lfs.currentdir(), "luacov--")
65 end)
66
67 it("LuaRocks new version updating md5", function()
68 assert.is_true(run.luarocks_bool("download --rockspec lpeg 0.12"))
69 assert.is_true(run.luarocks_bool("new_version lpeg-0.12-1.rockspec 0.2 https://luarocks.org/manifests/gvvaughan/lpeg-1.0.0-1.rockspec"))
70 test_env.remove_files(lfs.currentdir(), "lpeg--")
71 end)
72 end)
73end)
diff --git a/spec/pack_spec.lua b/spec/pack_spec.lua
new file mode 100644
index 00000000..0e5b31c6
--- /dev/null
+++ b/spec/pack_spec.lua
@@ -0,0 +1,59 @@
1local test_env = require("test/test_environment")
2local lfs = require("lfs")
3local run = test_env.run
4local testing_paths = test_env.testing_paths
5
6test_env.unload_luarocks()
7
8local extra_rocks = {
9 "/luasec-0.6-1.rockspec",
10 "/luasocket-3.0rc1-1.src.rock",
11 "/luasocket-3.0rc1-1.rockspec",
12 "/say-1.2-1.src.rock",
13 "/say-1.0-1.src.rock"
14}
15
16describe("LuaRocks pack tests #blackbox #b_pack", function()
17
18 before_each(function()
19 test_env.setup_specs(extra_rocks)
20 end)
21
22 it("LuaRocks pack with no flags/arguments", function()
23 assert.is_false(run.luarocks_bool("pack"))
24 end)
25
26 it("LuaRocks pack basic", function()
27 assert.is_true(run.luarocks_bool(test_env.quiet("pack luacov")))
28 assert.is_true(test_env.remove_files(lfs.currentdir(), "luacov-"))
29 end)
30
31 it("LuaRocks pack invalid rockspec", function()
32 assert.is_false(run.luarocks_bool("pack " .. testing_paths.testing_dir .. "/testfiles/invaild_validate-args-1.5.4-1.rockspec"))
33 end)
34
35 it("LuaRocks pack not installed rock", function()
36 assert.is_false(run.luarocks_bool("pack cjson"))
37 end)
38
39 it("LuaRocks pack not installed rock from non existing manifest", function()
40 assert.is_false(run.luarocks_bool("pack /non/exist/temp.manif"))
41 end)
42
43 it("LuaRocks pack specify which version of rock", function()
44 assert.is_true(run.luarocks_bool("install say 1.2"))
45 assert.is_true(run.luarocks_bool("install luassert"))
46 assert.is_true(run.luarocks_bool("install say 1.0"))
47
48 assert.is_false(run.luarocks_bool("pack say"))
49 end)
50
51 it("LuaRocks pack src", function()
52 assert.is_true(run.luarocks_bool(test_env.quiet("install luasec")))
53 assert.is_true(run.luarocks_bool("download --rockspec luasocket 3.0rc1-1"))
54 assert.is_true(run.luarocks_bool("pack luasocket-3.0rc1-1.rockspec"))
55 assert.is_true(test_env.remove_files(lfs.currentdir(), "luasocket-"))
56 end)
57end)
58
59
diff --git a/spec/path_spec.lua b/spec/path_spec.lua
new file mode 100644
index 00000000..22f07591
--- /dev/null
+++ b/spec/path_spec.lua
@@ -0,0 +1,26 @@
1local test_env = require("test/test_environment")
2local run = test_env.run
3
4test_env.unload_luarocks()
5
6describe("LuaRocks path tests #blackbox #b_path", function()
7 before_each(function()
8 test_env.setup_specs()
9 end)
10
11 it("LuaRocks path bin", function()
12 assert.is_true(run.luarocks_bool("path --bin"))
13 end)
14
15 it("LuaRocks path lr-path", function()
16 assert.is_true(run.luarocks_bool("path --lr-path"))
17 end)
18
19 it("LuaRocks path lr-cpath", function()
20 assert.is_true(run.luarocks_bool("path --lr-cpath"))
21 end)
22
23 it("LuaRocks path with tree", function()
24 assert.is_true(run.luarocks_bool("path --tree=lua_modules"))
25 end)
26end)
diff --git a/spec/purge_spec.lua b/spec/purge_spec.lua
new file mode 100644
index 00000000..09a9d433
--- /dev/null
+++ b/spec/purge_spec.lua
@@ -0,0 +1,28 @@
1local test_env = require("test/test_environment")
2local run = test_env.run
3local testing_paths = test_env.testing_paths
4
5test_env.unload_luarocks()
6
7describe("LuaRocks purge tests #blackbox #b_purge", function()
8 before_each(function()
9 test_env.setup_specs()
10 end)
11
12 describe("LuaRocks purge basic tests", function()
13 it("LuaRocks purge missing tree", function()
14 assert.is_false(run.luarocks_bool("purge --tree=" .. testing_paths.testing_tree))
15 end)
16 it("LuaRocks purge tree with no string", function()
17 assert.is_false(run.luarocks_bool("purge --tree=1"))
18 end)
19 it("LuaRocks purge tree with no string", function()
20 assert.is_true(run.luarocks_bool("purge --tree=" .. testing_paths.testing_sys_tree))
21 end)
22 it("LuaRocks purge old versions tree", function()
23 assert.is_true(run.luarocks_bool("purge --old-versions --tree=" .. testing_paths.testing_sys_tree))
24 end)
25 end)
26end)
27
28
diff --git a/spec/refresh_cache_spec.lua b/spec/refresh_cache_spec.lua
new file mode 100644
index 00000000..c20771ab
--- /dev/null
+++ b/spec/refresh_cache_spec.lua
@@ -0,0 +1,17 @@
1local test_env = require("test/test_environment")
2local run = test_env.run
3
4test_env.unload_luarocks()
5
6describe("LuaRocks refresh_cache tests #blackbox #b_refresh_cache", function()
7
8 before_each(function()
9 test_env.setup_specs()
10 end)
11
12 describe("LuaRocks-admin refresh cache tests #ssh", function()
13 it("LuaRocks-admin refresh cache", function()
14 assert.is_true(run.luarocks_admin_bool("--server=testing refresh_cache"))
15 end)
16 end)
17end)
diff --git a/spec/remove_spec.lua b/spec/remove_spec.lua
new file mode 100644
index 00000000..7bf1bb10
--- /dev/null
+++ b/spec/remove_spec.lua
@@ -0,0 +1,85 @@
1local test_env = require("test/test_environment")
2local lfs = require("lfs")
3local run = test_env.run
4local testing_paths = test_env.testing_paths
5
6test_env.unload_luarocks()
7
8local extra_rocks = {
9 "/abelhas-1.0-1.rockspec",
10 "/lualogging-1.3.0-1.src.rock",
11 "/luasocket-3.0rc1-1.src.rock",
12 "/luasocket-3.0rc1-1.rockspec"
13}
14
15describe("LuaRocks remove tests #blackbox #b_remove", function()
16
17 before_each(function()
18 test_env.setup_specs(extra_rocks)
19 end)
20
21 describe("LuaRocks remove basic tests", function()
22 it("LuaRocks remove with no flags/arguments", function()
23 assert.is_false(run.luarocks_bool("remove"))
24 end)
25
26 it("LuaRocks remove invalid rock", function()
27 assert.is_false(run.luarocks_bool("remove invalid.rock"))
28 end)
29
30 it("LuaRocks remove missing rock", function()
31 assert.is_false(run.luarocks_bool("remove missing_rock"))
32 end)
33
34 it("LuaRocks remove invalid argument", function()
35 assert.is_false(run.luarocks_bool("remove luacov --deps-mode"))
36 end)
37
38 it("LuaRocks remove builded abelhas", function()
39 assert.is_true(run.luarocks_bool("build abelhas 1.0"))
40 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/abelhas"))
41 assert.is_true(run.luarocks_bool("remove abelhas 1.0"))
42 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/abelhas"))
43 end)
44 end)
45
46 describe("LuaRocks remove more complex tests", function()
47 before_each(function()
48 assert.is.truthy(test_env.need_rock("luasocket"))
49 end)
50
51 it("LuaRocks remove fail, break dependencies", function()
52 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket"))
53 assert.is_true(run.luarocks_bool("build lualogging"))
54
55 assert.is_false(run.luarocks_bool("remove luasocket"))
56 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket"))
57 end)
58
59 it("LuaRocks remove force", function()
60 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket"))
61 assert.is_true(run.luarocks_bool("build lualogging"))
62
63 local output = run.luarocks("remove --force luasocket")
64 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket"))
65 assert.is.truthy(output:find("Checking stability of dependencies"))
66 end)
67
68 it("LuaRocks remove force fast", function()
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)
85end)
diff --git a/spec/search_spec.lua b/spec/search_spec.lua
new file mode 100644
index 00000000..b31624b8
--- /dev/null
+++ b/spec/search_spec.lua
@@ -0,0 +1,36 @@
1local test_env = require("test/test_environment")
2local run = test_env.run
3
4test_env.unload_luarocks()
5
6local extra_rocks = {
7"/lzlib-0.4.1.53-1.src.rock"
8}
9
10describe("LuaRocks search tests #blackbox #b_search", function()
11
12 before_each(function()
13 test_env.setup_specs(extra_rocks)
14 end)
15
16 it("LuaRocks search with no flags/arguments", function()
17 assert.is_false(run.luarocks_bool("search"))
18 end)
19
20 it("LuaRocks search zlib", function()
21 assert.is_true(run.luarocks_bool("search zlib"))
22 end)
23
24 it("LuaRocks search zlib 1.1", function()
25 assert.is_true(run.luarocks_bool("search zlib 1.1"))
26 end)
27
28 it("LuaRocks search missing rock", function()
29 assert.is_true(run.luarocks_bool("search missing_rock"))
30 end)
31
32 it("LuaRocks search with flag all", function()
33 assert.is_true(run.luarocks_bool(test_env.quiet("search --all")))
34 end)
35
36end)
diff --git a/spec/show_spec.lua b/spec/show_spec.lua
new file mode 100644
index 00000000..f528a6de
--- /dev/null
+++ b/spec/show_spec.lua
@@ -0,0 +1,54 @@
1local test_env = require("test/test_environment")
2local run = test_env.run
3
4test_env.unload_luarocks()
5
6describe("LuaRocks show tests #blackbox #b_show", function()
7
8 before_each(function()
9 test_env.setup_specs()
10 end)
11
12 it("LuaRocks show with no flags/arguments", function()
13 assert.is_false(run.luarocks_bool("show"))
14 end)
15
16 describe("LuaRocks show basic tests with flags", function()
17 it("LuaRocks show invalid", function()
18 assert.is_false(run.luarocks_bool("show invalid"))
19 end)
20
21 it("LuaRocks show luacov", function()
22 local output = run.luarocks("show luacov")
23 end)
24
25 it("LuaRocks show modules of luacov", function()
26 local output = run.luarocks("show --modules luacov")
27 end)
28
29 it("LuaRocks show dependencies of luacov", function()
30 local output = run.luarocks("show --deps luacov")
31 end)
32
33 it("LuaRocks show rockspec of luacov", function()
34 local output = run.luarocks("show --rockspec luacov")
35 end)
36
37 it("LuaRocks show mversion of luacov", function()
38 local output = run.luarocks("show --mversion luacov")
39 end)
40
41 it("LuaRocks show rock tree of luacov", function()
42 local output = run.luarocks("show --rock-tree luacov")
43 end)
44
45 it("LuaRocks show rock directory of luacov", function()
46 local output = run.luarocks("show --rock-dir luacov")
47 end)
48 end)
49
50 it("LuaRocks show old version of luacov", function()
51 run.luarocks("install luacov 0.11.0")
52 run.luarocks("show luacov 0.11.0")
53 end)
54end)
diff --git a/spec/unpack_spec.lua b/spec/unpack_spec.lua
new file mode 100644
index 00000000..495c514e
--- /dev/null
+++ b/spec/unpack_spec.lua
@@ -0,0 +1,67 @@
1local test_env = require("test/test_environment")
2local run = test_env.run
3local testing_paths = test_env.testing_paths
4local lfs = require("lfs")
5
6test_env.unload_luarocks()
7
8local extra_rocks = {
9 "/cprint-0.1-2.src.rock",
10 "/cprint-0.1-2.rockspec",
11 "/luazip-1.2.4-1.rockspec"
12}
13
14describe("LuaRocks unpack tests #blackbox #b_unpack", function()
15
16 before_each(function()
17 test_env.setup_specs(extra_rocks)
18 end)
19
20 describe("LuaRocks unpack basic fail tests", function()
21 it("LuaRocks unpack with no flags/arguments", function()
22 assert.is_false(run.luarocks_bool("unpack"))
23 end)
24 it("LuaRocks unpack with invalid rockspec", function()
25 assert.is_false(run.luarocks_bool("unpack invalid.rockspec"))
26 end)
27 it("LuaRocks unpack with invalid patch", function()
28 assert.is_false(run.luarocks_bool("unpack " .. testing_paths.testing_dir .. "/testfiles/invalid_patch-0.1-1.rockspec"))
29 end)
30 end)
31
32 describe("LuaRocks unpack more complex tests", function()
33 it("LuaRocks unpack download", function()
34 assert.is_true(run.luarocks_bool("unpack cprint"))
35 test_env.remove_dir("cprint-0.1-2")
36 end)
37 it("LuaRocks unpack src", function()
38 assert.is_true(run.luarocks_bool("download --source cprint"))
39 assert.is_true(run.luarocks_bool("unpack cprint-0.1-2.src.rock"))
40 os.remove("cprint-0.1-2.src.rock")
41 test_env.remove_dir("cprint-0.1-2")
42 end)
43 it("LuaRocks unpack rockspec", function()
44 assert.is_true(run.luarocks_bool("download --rockspec cprint"))
45 assert.is_true(run.luarocks_bool("unpack cprint-0.1-2.rockspec"))
46 os.remove("cprint-0.1-2.rockspec")
47 os.remove("lua-cprint")
48 test_env.remove_dir("cprint-0.1-2")
49 end)
50 -- #595 luarocks unpack of a git:// rockspec fails to copy the rockspec
51 it("LuaRocks unpack git:// rockspec", function()
52 assert.is_true(run.luarocks_bool("download --rockspec cprint"))
53 assert.is_true(run.luarocks_bool("unpack luazip-1.2.4-1.rockspec"))
54 assert.is_truthy(lfs.attributes("luazip-1.2.4-1/luazip/luazip-1.2.4-1.rockspec"))
55 test_env.remove_dir("luazip-1.2.4-1")
56 end)
57 it("LuaRocks unpack binary", function()
58 assert.is_true(run.luarocks_bool("build cprint"))
59 assert.is_true(run.luarocks_bool("pack cprint"))
60 assert.is_true(run.luarocks_bool("unpack cprint-0.1-2." .. test_env.platform .. ".rock"))
61 test_env.remove_dir("cprint-0.1-2")
62 os.remove("cprint-0.1-2." .. test_env.platform .. ".rock")
63 end)
64 end)
65end)
66
67
diff --git a/spec/upload_spec.lua b/spec/upload_spec.lua
new file mode 100644
index 00000000..c68a1cdf
--- /dev/null
+++ b/spec/upload_spec.lua
@@ -0,0 +1,74 @@
1local test_env = require("test/test_environment")
2local run = test_env.run
3local testing_paths = test_env.testing_paths
4
5test_env.unload_luarocks()
6
7local extra_rocks = {
8 "/lua-cjson-2.1.0-1.src.rock",
9
10 -- rocks needed for mock-server
11 "/copas-2.0.1-1.src.rock",
12 "/coxpcall-1.16.0-1.src.rock",
13 "/dkjson-2.5-2.src.rock",
14 "/luafilesystem-1.6.3-1.src.rock",
15 "/luasec-0.6-1.rockspec",
16 "/luasocket-3.0rc1-2.src.rock",
17 "/luasocket-3.0rc1-2.rockspec",
18 "/restserver-0.1-1.src.rock",
19 "/restserver-xavante-0.2-1.src.rock",
20 "/rings-1.3.0-1.src.rock",
21 "/wsapi-1.6.1-1.src.rock",
22 "/wsapi-xavante-1.6.1-1.src.rock",
23 "/xavante-2.4.0-1.src.rock"
24}
25
26describe("LuaRocks upload tests #blackbox #b_upload", function()
27
28 before_each(function()
29 test_env.setup_specs(extra_rocks)
30 end)
31
32 it("LuaRocks upload with no flags/arguments", function()
33 assert.is_false(run.luarocks_bool("upload"))
34 end)
35
36 it("LuaRocks upload invalid rockspec", function()
37 assert.is_false(run.luarocks_bool("upload invalid.rockspec"))
38 end)
39
40 it("LuaRocks upload api key invalid", function()
41 assert.is_false(run.luarocks_bool("upload --api-key=invalid invalid.rockspec"))
42 end)
43
44 it("LuaRocks upload api key invalid and skip-pack", function()
45 assert.is_false(run.luarocks_bool("upload --api-key=\"invalid\" --skip-pack luacov-0.11.0-1.rockspec"))
46 end)
47
48 it("LuaRocks upload force", function()
49 assert.is_true(run.luarocks_bool("install lua-cjson"))
50 assert.is_false(run.luarocks_bool("upload --api-key=\"invalid\" --force luacov-0.11.0-1.rockspec"))
51 assert.is_true(run.luarocks_bool("install lua-cjson"))
52 end)
53
54 describe("LuaRocks upload tests with Xavante server #mock", function()
55 before_each(function()
56 assert.is.truthy(test_env.need_rock("restserver-xavante"))
57 local final_command = test_env.execute_helper(testing_paths.lua .. " " .. testing_paths.testing_dir .. "/mock-server.lua &", true, test_env.env_variables)
58 os.execute(final_command)
59 end)
60
61 after_each(function()
62 os.execute("curl localhost:8080/shutdown")
63 end)
64
65 it("LuaRocks upload rockspec with api-key", function()
66 assert.is_true(run.luarocks_bool("upload " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec --api-key=123", {LUAROCKS_CONFIG = testing_paths.testing_dir .. "/luarocks_site.lua"}))
67 end)
68 it("LuaRocks upload rockspec with api-key and skip-pack", function()
69 assert.is_true(run.luarocks_bool("upload --skip-pack " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec --api-key=123", {LUAROCKS_CONFIG = testing_paths.testing_dir .. "/luarocks_site.lua"}))
70 end)
71 end)
72end)
73
74
diff --git a/spec/util_spec.lua b/spec/util_spec.lua
new file mode 100644
index 00000000..23e3ebd8
--- /dev/null
+++ b/spec/util_spec.lua
@@ -0,0 +1,99 @@
1local test_env = require("test/test_environment")
2local lfs = require("lfs")
3local run = test_env.run
4local testing_paths = test_env.testing_paths
5local env_variables = test_env.env_variables
6
7describe("Basic tests #blackbox #b_util", function()
8
9 before_each(function()
10 test_env.setup_specs()
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 local output = run.luarocks("")
38 assert.is.falsy(output:find("LuaRocks scm, a module deployment system for Lua"))
39 assert.is_true(lfs.chdir(main_path))
40
41 output = run.luarocks("")
42 assert.is.truthy(output:find("LuaRocks scm, a module deployment system for Lua"))
43 end)
44
45 it("LuaRocks timeout", function()
46 assert.is.truthy(run.luarocks("--timeout=10"))
47 end)
48
49 it("LuaRocks timeout invalid", function()
50 assert.is_false(run.luarocks_bool("--timeout=abc"))
51 end)
52
53 it("LuaRocks only server=testing", function()
54 assert.is.truthy(run.luarocks("--only-server=testing"))
55 end)
56
57 it("LuaRocks test site config", function()
58 assert.is.truthy(os.rename("src/luarocks/site_config.lua", "src/luarocks/site_config.lua.tmp"))
59 assert.is.falsy(lfs.attributes("src/luarocks/site_config.lua"))
60 assert.is.truthy(lfs.attributes("src/luarocks/site_config.lua.tmp"))
61
62 assert.is.truthy(run.luarocks(""))
63
64 assert.is.truthy(os.rename("src/luarocks/site_config.lua.tmp", "src/luarocks/site_config.lua"))
65 assert.is.falsy(lfs.attributes("src/luarocks/site_config.lua.tmp"))
66 assert.is.truthy(lfs.attributes("src/luarocks/site_config.lua"))
67 end)
68
69 describe("LuaRocks sysconfig fails", function()
70 local scdir = ""
71
72 before_each(function()
73 scdir = testing_paths.testing_lrprefix .. "/etc/luarocks/"
74 lfs.mkdir(testing_paths.testing_lrprefix)
75 lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/")
76 lfs.mkdir(scdir)
77 end)
78
79 after_each(function()
80 test_env.remove_dir(testing_paths.testing_lrprefix)
81 end)
82
83 it("LuaRocks sysconfig fail", function()
84 local sysconfig = io.open(scdir .. "/config.lua", "w+")
85 sysconfig:write("aoeui")
86 sysconfig:close()
87
88 assert.is_false(run.luarocks_bool("list"))
89 end)
90
91 it("LuaRocks sysconfig fail", function()
92 local sysconfig = io.open(scdir .. "/config-" .. env_variables.LUA_VERSION .. ".lua", "w+")
93 sysconfig:write("aoeui")
94 sysconfig:close()
95
96 assert.is_false(run.luarocks_bool("list"))
97 end)
98 end)
99end)
diff --git a/spec/write_rockspec_spec.lua b/spec/write_rockspec_spec.lua
new file mode 100644
index 00000000..531d11eb
--- /dev/null
+++ b/spec/write_rockspec_spec.lua
@@ -0,0 +1,72 @@
1local test_env = require("test/test_environment")
2local lfs = require("lfs")
3local run = test_env.run
4
5test_env.unload_luarocks()
6
7describe("LuaRocks write_rockspec tests #blackbox #b_write_rockspec", function()
8
9 before_each(function()
10 test_env.setup_specs()
11 end)
12
13 describe("LuaRocks write_rockspec basic tests", function()
14 it("LuaRocks write_rockspec with no flags/arguments", function()
15 assert.is_true(run.luarocks_bool("write_rockspec"))
16 os.remove("luarocks-scm-1.rockspec")
17 end)
18
19 it("LuaRocks write_rockspec with invalid argument", function()
20 assert.is_false(run.luarocks_bool("write_rockspec invalid"))
21 end)
22
23 it("LuaRocks write_rockspec invalid zip", function()
24 assert.is_false(run.luarocks_bool("write_rockspec http://example.com/invalid.zip"))
25 end)
26 end)
27
28 describe("LuaRocks write_rockspec more complex tests", function()
29 it("LuaRocks write_rockspec git luarocks", function()
30 assert.is_true(run.luarocks_bool("write_rockspec git://github.com/keplerproject/luarocks"))
31 assert.is.truthy(lfs.attributes("luarocks-scm-1.rockspec"))
32 assert.is_true(os.remove("luarocks-scm-1.rockspec"))
33 end)
34
35 it("LuaRocks write_rockspec git luarocks --tag=v2.3.0", function()
36 assert.is_true(run.luarocks_bool("write_rockspec git://github.com/keplerproject/luarocks --tag=v2.3.0"))
37 assert.is.truthy(lfs.attributes("luarocks-2.3.0-1.rockspec"))
38 assert.is_true(os.remove("luarocks-2.3.0-1.rockspec"))
39 end)
40
41 it("LuaRocks write_rockspec git luarocks with format flag", function()
42 assert.is_true(run.luarocks_bool("write_rockspec git://github.com/mbalmer/luarocks --rockspec-format=1.1 --lua-version=5.1,5.2"))
43 assert.is.truthy(lfs.attributes("luarocks-scm-1.rockspec"))
44 assert.is_true(os.remove("luarocks-scm-1.rockspec"))
45 end)
46
47 it("LuaRocks write_rockspec git luarocks with full flags", function()
48 assert.is_true(run.luarocks_bool("write_rockspec git://github.com/mbalmer/luarocks --lua-version=5.1,5.2 --license=\"MIT/X11\" "
49 .. " --homepage=\"http://www.luarocks.org\" --summary=\"A package manager for Lua modules\" "))
50 assert.is.truthy(lfs.attributes("luarocks-scm-1.rockspec"))
51 assert.is_true(os.remove("luarocks-scm-1.rockspec"))
52 end)
53
54 it("LuaRocks write_rockspec rockspec via http", function()
55 assert.is_true(run.luarocks_bool("write_rockspec http://luarocks.org/releases/luarocks-2.1.0.tar.gz --lua-version=5.1"))
56 assert.is.truthy(lfs.attributes("luarocks-2.1.0-1.rockspec"))
57 assert.is_true(os.remove("luarocks-2.1.0-1.rockspec"))
58 end)
59
60 it("LuaRocks write_rockspec base dir, luassert.tar.gz via https", function()
61 assert.is_true(run.luarocks_bool("write_rockspec https://github.com/downloads/Olivine-Labs/luassert/luassert-1.2.tar.gz --lua-version=5.1"))
62 assert.is.truthy(lfs.attributes("luassert-1.2-1.rockspec"))
63 assert.is_true(os.remove("luassert-1.2-1.rockspec"))
64 end)
65
66 it("LuaRocks write_rockspec git luafcgi with many flags", function()
67 assert.is_true(run.luarocks_bool("write_rockspec git://github.com/mbalmer/luafcgi --lib=fcgi --license=\"3-clause BSD\" " .. "--lua-version=5.1,5.2"))
68 assert.is.truthy(lfs.attributes("luafcgi-scm-1.rockspec")) -- TODO maybe read it content and find arguments from flags?
69 assert.is_true(os.remove("luafcgi-scm-1.rockspec"))
70 end)
71 end)
72end)