aboutsummaryrefslogtreecommitdiff
path: root/spec/deps_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'spec/deps_spec.lua')
-rw-r--r--spec/deps_spec.lua145
1 files changed, 0 insertions, 145 deletions
diff --git a/spec/deps_spec.lua b/spec/deps_spec.lua
index 32f68f51..dd8fea64 100644
--- a/spec/deps_spec.lua
+++ b/spec/deps_spec.lua
@@ -3,8 +3,6 @@ local lfs = require("lfs")
3local run = test_env.run 3local run = test_env.run
4local testing_paths = test_env.testing_paths 4local testing_paths = test_env.testing_paths
5 5
6test_env.unload_luarocks()
7
8local extra_rocks = { 6local extra_rocks = {
9 "/lxsh-${LXSH}.src.rock", 7 "/lxsh-${LXSH}.src.rock",
10 "/lxsh-${LXSH}.rockspec", 8 "/lxsh-${LXSH}.rockspec",
@@ -116,146 +114,3 @@ describe("LuaRocks deps-mode #integration", function()
116 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/${LXSH}/lxsh-${LXSH}.rockspec")) 114 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/${LXSH}/lxsh-${LXSH}.rockspec"))
117 end) 115 end)
118end) 116end)
119
120test_env.unload_luarocks()
121test_env.setup_specs()
122local cfg = require("luarocks.core.cfg")
123local deps = require("luarocks.deps")
124local fs = require("luarocks.fs")
125
126describe("LuaRocks deps #unit", function()
127 local runner
128
129 lazy_setup(function()
130 runner = require("luacov.runner")
131 runner.init(testing_paths.testrun_dir .. "/luacov.config")
132 runner.tick = true
133 cfg.init()
134 fs.init()
135 deps.check_lua_incdir(cfg.variables)
136 deps.check_lua_libdir(cfg.variables)
137 end)
138
139 lazy_teardown(function()
140 runner.shutdown()
141 end)
142
143 describe("deps", function()
144 describe("deps.autodetect_external_dependencies", function()
145 it("returns false if the given build table has no external dependencies", function()
146 local build_table = {
147 type = "builtin"
148 }
149
150 assert.falsy(deps.autodetect_external_dependencies(build_table))
151 end)
152
153 it("returns a table of the external dependencies found in the given build table", function()
154 local build_table = {
155 type = "builtin",
156 modules = {
157 module1 = {
158 libraries = { "foo1", "foo2" },
159 },
160 module2 = {
161 libraries = "foo3"
162 },
163 }
164 }
165
166 local extdeps = deps.autodetect_external_dependencies(build_table)
167 assert.same(extdeps["FOO1"], { library = "foo1" })
168 assert.same(extdeps["FOO2"], { library = "foo2" })
169 assert.same(extdeps["FOO3"], { library = "foo3" })
170 end)
171
172 it("adds proper include and library dirs to the given build table", function()
173 local build_table
174
175 build_table = {
176 type = "builtin",
177 modules = {
178 module1 = {
179 libraries = "foo"
180 }
181 }
182 }
183 deps.autodetect_external_dependencies(build_table)
184 assert.same(build_table, {
185 type = "builtin",
186 modules = {
187 module1 = {
188 libraries = "foo",
189 incdirs = { "$(FOO_INCDIR)" },
190 libdirs = { "$(FOO_LIBDIR)" }
191 }
192 }
193 })
194
195 build_table = {
196 type = "builtin",
197 modules = {
198 module1 = {
199 libraries = "foo",
200 incdirs = { "INCDIRS" }
201 }
202 }
203 }
204 deps.autodetect_external_dependencies(build_table)
205 assert.same(build_table, {
206 type = "builtin",
207 modules = {
208 module1 = {
209 libraries = "foo",
210 incdirs = { "INCDIRS" },
211 libdirs = { "$(FOO_LIBDIR)" }
212 }
213 }
214 })
215
216 build_table = {
217 type = "builtin",
218 modules = {
219 module1 = {
220 libraries = "foo",
221 libdirs = { "LIBDIRS" }
222 }
223 }
224 }
225 deps.autodetect_external_dependencies(build_table)
226 assert.same(build_table, {
227 type = "builtin",
228 modules = {
229 module1 = {
230 libraries = "foo",
231 incdirs = { "$(FOO_INCDIR)" },
232 libdirs = { "LIBDIRS" }
233 }
234 }
235 })
236
237 build_table = {
238 type = "builtin",
239 modules = {
240 module1 = {
241 libraries = "foo",
242 incdirs = { "INCDIRS" },
243 libdirs = { "LIBDIRS" }
244 }
245 }
246 }
247 deps.autodetect_external_dependencies(build_table)
248 assert.same(build_table, {
249 type = "builtin",
250 modules = {
251 module1 = {
252 libraries = "foo",
253 incdirs = { "INCDIRS" },
254 libdirs = { "LIBDIRS" }
255 }
256 }
257 })
258 end)
259 end)
260 end)
261end)