diff options
author | George Roman <george.roman.99@gmail.com> | 2018-07-19 13:11:11 +0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-07-22 22:53:37 -0300 |
commit | 098fe3c52f1d400301124f5084b1972d57fd62d7 (patch) | |
tree | b775cbb91c564c5135afeb1e8c731d2bfb771878 | |
parent | 66b2816a2fd193eaf09f916efb0231aa7184db8a (diff) | |
download | luarocks-098fe3c52f1d400301124f5084b1972d57fd62d7.tar.gz luarocks-098fe3c52f1d400301124f5084b1972d57fd62d7.tar.bz2 luarocks-098fe3c52f1d400301124f5084b1972d57fd62d7.zip |
Tests: use more fixtures in the build tests
-rw-r--r-- | spec/build_spec.lua | 130 | ||||
-rw-r--r-- | spec/fixtures/with_dep-0.1-1.rockspec | 18 | ||||
-rw-r--r-- | spec/fixtures/with_dep.lua | 6 |
3 files changed, 101 insertions, 53 deletions
diff --git a/spec/build_spec.lua b/spec/build_spec.lua index 0aaa6d63..707ab145 100644 --- a/spec/build_spec.lua +++ b/spec/build_spec.lua | |||
@@ -19,12 +19,9 @@ local extra_rocks = { | |||
19 | "/lpeg-1.0.0-1.rockspec", | 19 | "/lpeg-1.0.0-1.rockspec", |
20 | "/lpeg-1.0.0-1.src.rock", | 20 | "/lpeg-1.0.0-1.src.rock", |
21 | "/luafilesystem-1.6.3-1.src.rock", | 21 | "/luafilesystem-1.6.3-1.src.rock", |
22 | "/lualogging-1.3.0-1.src.rock", | ||
23 | "/luasec-0.6-1.rockspec", | 22 | "/luasec-0.6-1.rockspec", |
24 | "/luasocket-3.0rc1-2.src.rock", | 23 | "/luasocket-3.0rc1-2.src.rock", |
25 | "/luasocket-3.0rc1-2.rockspec", | 24 | "/luasocket-3.0rc1-2.rockspec", |
26 | "/lxsh-0.8.6-2.src.rock", | ||
27 | "/lxsh-0.8.6-2.rockspec", | ||
28 | "/stdlib-41.0.0-1.src.rock", | 25 | "/stdlib-41.0.0-1.src.rock", |
29 | "/validate-args-1.5.4-1.rockspec" | 26 | "/validate-args-1.5.4-1.rockspec" |
30 | } | 27 | } |
@@ -135,17 +132,17 @@ describe("LuaRocks build tests #integration", function() | |||
135 | assert.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) | 132 | assert.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) |
136 | end) | 133 | end) |
137 | 134 | ||
138 | it("LuaRocks build lpeg only-sources example", function() | 135 | it("LuaRocks build with --only-sources", function() |
139 | assert.is_true(run.luarocks_bool("download --rockspec lpeg")) | 136 | assert.is_true(run.luarocks_bool("download --server=" .. testing_paths.fixtures_dir .. "/a_repo --rockspec a_rock")) |
140 | assert.is_false(run.luarocks_bool("build --only-sources=\"http://example.com\" lpeg-1.0.0-1.rockspec")) | 137 | assert.is_false(run.luarocks_bool("build --only-sources=\"http://example.com\" a_rock-1.0-1.rockspec")) |
141 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) | 138 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) |
142 | 139 | ||
143 | assert.is_true(run.luarocks_bool("download --source lpeg")) | 140 | assert.is_true(run.luarocks_bool("download --server=" .. testing_paths.fixtures_dir .. "/a_repo --source a_rock")) |
144 | assert.is_true(run.luarocks_bool("build --only-sources=\"http://example.com\" lpeg-1.0.0-1.src.rock")) | 141 | assert.is_true(run.luarocks_bool("build --only-sources=\"http://example.com\" a_rock-1.0-1.src.rock")) |
145 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) | 142 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) |
146 | 143 | ||
147 | assert.is_true(os.remove("lpeg-1.0.0-1.rockspec")) | 144 | assert.is_true(os.remove("a_rock-1.0-1.rockspec")) |
148 | assert.is_true(os.remove("lpeg-1.0.0-1.src.rock")) | 145 | assert.is_true(os.remove("a_rock-1.0-1.src.rock")) |
149 | end) | 146 | end) |
150 | 147 | ||
151 | it("LuaRocks build fails if an empty tree is given", function() | 148 | it("LuaRocks build fails if an empty tree is given", function() |
@@ -201,9 +198,35 @@ describe("LuaRocks build tests #integration", function() | |||
201 | lfs.rmdir(tmpdir) | 198 | lfs.rmdir(tmpdir) |
202 | end) | 199 | end) |
203 | 200 | ||
204 | it("LuaRocks build luasec with skipping dependency checks", function() | 201 | it("LuaRocks build with skipping dependency checks", function() |
205 | assert.is_true(run.luarocks_bool("build luasec 0.6-1 " .. test_env.openssl_dirs .. " --nodeps")) | 202 | local olddir = lfs.currentdir() |
206 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasec/0.6-1/luasec-0.6-1.rockspec")) | 203 | local tmpdir = get_tmp_path() |
204 | lfs.mkdir(tmpdir) | ||
205 | lfs.chdir(tmpdir) | ||
206 | |||
207 | write_file("test-1.0-1.rockspec", [[ | ||
208 | package = "test" | ||
209 | version = "1.0-1" | ||
210 | source = { | ||
211 | url = "file://]] .. tmpdir:gsub("\\", "/") .. [[/test.lua" | ||
212 | } | ||
213 | dependencies = { | ||
214 | "a_rock 1.0" | ||
215 | } | ||
216 | build = { | ||
217 | type = "builtin", | ||
218 | modules = { | ||
219 | test = "test.lua" | ||
220 | } | ||
221 | } | ||
222 | ]], finally) | ||
223 | write_file("test.lua", "return {}", finally) | ||
224 | |||
225 | assert.is_true(run.luarocks_bool("build test-1.0-1.rockspec --deps-mode=none")) | ||
226 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/test/1.0-1/test-1.0-1.rockspec")) | ||
227 | |||
228 | lfs.chdir(olddir) | ||
229 | lfs.rmdir(tmpdir) | ||
207 | end) | 230 | end) |
208 | 231 | ||
209 | it("LuaRocks build lmathx deps partial match", function() | 232 | it("LuaRocks build lmathx deps partial match", function() |
@@ -267,22 +290,71 @@ describe("LuaRocks build tests #integration", function() | |||
267 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasec/0.6-1/luasec-0.6-1.rockspec")) | 290 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasec/0.6-1/luasec-0.6-1.rockspec")) |
268 | end) | 291 | end) |
269 | 292 | ||
270 | it("LuaRocks build only deps of downloaded rockspec of lxsh", function() | 293 | it("LuaRocks build only deps of a given rockspec", function() |
271 | assert.is_true(run.luarocks_bool("download --rockspec lxsh 0.8.6-2")) | 294 | local olddir = lfs.currentdir() |
272 | assert.is.truthy(run.luarocks("build lxsh-0.8.6-2.rockspec --only-deps")) | 295 | local tmpdir = get_tmp_path() |
273 | assert.is_false(run.luarocks_bool("show lxsh")) | 296 | lfs.mkdir(tmpdir) |
274 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) | 297 | lfs.chdir(tmpdir) |
275 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) | 298 | |
276 | assert.is_true(os.remove("lxsh-0.8.6-2.rockspec")) | 299 | write_file("test-1.0-1.rockspec", [[ |
300 | package = "test" | ||
301 | version = "1.0-1" | ||
302 | source = { | ||
303 | url = "file://]] .. tmpdir:gsub("\\", "/") .. [[/test.lua" | ||
304 | } | ||
305 | dependencies = { | ||
306 | "a_rock 1.0" | ||
307 | } | ||
308 | build = { | ||
309 | type = "builtin", | ||
310 | modules = { | ||
311 | test = "test.lua" | ||
312 | } | ||
313 | } | ||
314 | ]], finally) | ||
315 | write_file("test.lua", "return {}", finally) | ||
316 | |||
317 | assert.is.truthy(run.luarocks_bool("build --server=" .. testing_paths.fixtures_dir .. "/a_repo test-1.0-1.rockspec --only-deps")) | ||
318 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/test/1.0-1/test-1.0-1.rockspec")) | ||
319 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) | ||
320 | |||
321 | lfs.chdir(olddir) | ||
322 | lfs.rmdir(tmpdir) | ||
277 | end) | 323 | end) |
278 | 324 | ||
279 | it("LuaRocks build only deps of downloaded rock of lxsh", function() | 325 | pending("LuaRocks build only deps of a given rock", function() |
280 | assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6-2")) | 326 | local olddir = lfs.currentdir() |
281 | assert.is.truthy(run.luarocks("build lxsh-0.8.6-2.src.rock --only-deps")) | 327 | local tmpdir = get_tmp_path() |
282 | assert.is_false(run.luarocks_bool("show lxsh")) | 328 | lfs.mkdir(tmpdir) |
283 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) | 329 | lfs.chdir(tmpdir) |
284 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) | 330 | |
285 | assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) | 331 | write_file("test-1.0-1.rockspec", [[ |
332 | package = "test" | ||
333 | version = "1.0-1" | ||
334 | source = { | ||
335 | url = "file://]] .. tmpdir:gsub("\\", "/") .. [[/test.lua" | ||
336 | } | ||
337 | dependencies = { | ||
338 | "a_rock 1.0" | ||
339 | } | ||
340 | build = { | ||
341 | type = "builtin", | ||
342 | modules = { | ||
343 | test = "test.lua" | ||
344 | } | ||
345 | } | ||
346 | ]], finally) | ||
347 | write_file("test.lua", "return {}", finally) | ||
348 | |||
349 | assert.is.truthy(run.luarocks_bool("pack test-1.0-1.rockspec")) | ||
350 | assert.is.truthy(lfs.attributes("test-1.0-1.src.rock")) | ||
351 | |||
352 | assert.is.truthy(run.luarocks_bool("build --server=" .. testing_paths.fixtures_dir .. "/a_repo test-1.0-1.src.rock --only-deps")) | ||
353 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/test/1.0-1/test-1.0-1.rockspec")) | ||
354 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) | ||
355 | |||
356 | lfs.chdir(olddir) | ||
357 | lfs.rmdir(tmpdir) | ||
286 | end) | 358 | end) |
287 | 359 | ||
288 | it("LuaRocks build with https", function() | 360 | it("LuaRocks build with https", function() |
diff --git a/spec/fixtures/with_dep-0.1-1.rockspec b/spec/fixtures/with_dep-0.1-1.rockspec deleted file mode 100644 index 53b26c9d..00000000 --- a/spec/fixtures/with_dep-0.1-1.rockspec +++ /dev/null | |||
@@ -1,18 +0,0 @@ | |||
1 | package = "with_dep" | ||
2 | version = "0.1-1" | ||
3 | source = { | ||
4 | url = "http://localhost:8080/file/with_dep.lua" | ||
5 | } | ||
6 | description = { | ||
7 | summary = "An example rockspec", | ||
8 | } | ||
9 | dependencies = { | ||
10 | "lua >= 5.1", | ||
11 | "with_external_dep 0.1", | ||
12 | } | ||
13 | build = { | ||
14 | type = "builtin", | ||
15 | modules = { | ||
16 | with_dep = "with_dep.lua" | ||
17 | } | ||
18 | } | ||
diff --git a/spec/fixtures/with_dep.lua b/spec/fixtures/with_dep.lua deleted file mode 100644 index ad7e462a..00000000 --- a/spec/fixtures/with_dep.lua +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | local pok, with_external_dep = pcall(require, "with_external_dep") | ||
2 | if pok then | ||
3 | print(with_external_dep.foo) | ||
4 | else | ||
5 | print(100) | ||
6 | end | ||