diff options
author | George Roman <george.roman.99@gmail.com> | 2018-06-18 18:57:47 +0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-06-21 23:33:00 -0300 |
commit | bdfe731a601f3d12ffafbf504c9b06d70d5aa819 (patch) | |
tree | b6b94d398ba01fb9345d05b55c0bf2a93801cb2a | |
parent | 48ae1d2e7705af6a7527ca61710fe18ccdb7d0b9 (diff) | |
download | luarocks-bdfe731a601f3d12ffafbf504c9b06d70d5aa819.tar.gz luarocks-bdfe731a601f3d12ffafbf504c9b06d70d5aa819.tar.bz2 luarocks-bdfe731a601f3d12ffafbf504c9b06d70d5aa819.zip |
Tests: replace small fixture files with inline content
20 files changed, 269 insertions, 151 deletions
diff --git a/spec/build_spec.lua b/spec/build_spec.lua index ae559654..74efccd5 100644 --- a/spec/build_spec.lua +++ b/spec/build_spec.lua | |||
@@ -1,7 +1,9 @@ | |||
1 | local test_env = require("spec.util.test_env") | 1 | local test_env = require("spec.util.test_env") |
2 | local lfs = require("lfs") | 2 | local lfs = require("lfs") |
3 | local get_tmp_path = test_env.get_tmp_path | ||
3 | local run = test_env.run | 4 | local run = test_env.run |
4 | local testing_paths = test_env.testing_paths | 5 | local testing_paths = test_env.testing_paths |
6 | local write_file = test_env.write_file | ||
5 | 7 | ||
6 | test_env.unload_luarocks() | 8 | test_env.unload_luarocks() |
7 | 9 | ||
@@ -40,12 +42,35 @@ describe("LuaRocks build tests #integration", function() | |||
40 | end) | 42 | end) |
41 | 43 | ||
42 | it("LuaRocks build with no arguments behaves as luarocks make", function() | 44 | it("LuaRocks build with no arguments behaves as luarocks make", function() |
43 | local tmpdir = test_env.get_tmp_path() | ||
44 | lfs.mkdir(tmpdir) | ||
45 | local olddir = lfs.currentdir() | 45 | local olddir = lfs.currentdir() |
46 | local tmpdir = get_tmp_path() | ||
47 | lfs.mkdir(tmpdir) | ||
46 | lfs.chdir(tmpdir) | 48 | lfs.chdir(tmpdir) |
47 | test_env.copy(testing_paths.fixtures_dir .. "/c_module-1.0-1.rockspec", tmpdir .. "/c_module-1.0-1.rockspec") | 49 | |
48 | test_env.copy(testing_paths.fixtures_dir .. "/c_module.c", tmpdir .. "/c_module.c") | 50 | write_file("c_module-1.0-1.rockspec", [[ |
51 | package = "c_module" | ||
52 | version = "1.0-1" | ||
53 | source = { | ||
54 | url = "http://example.com/c_module" | ||
55 | } | ||
56 | build = { | ||
57 | type = "builtin", | ||
58 | modules = { | ||
59 | c_module = { "c_module.c" } | ||
60 | } | ||
61 | } | ||
62 | ]], finally) | ||
63 | write_file("c_module.c", [[ | ||
64 | #include <lua.h> | ||
65 | #include <lauxlib.h> | ||
66 | |||
67 | int luaopen_c_module(lua_State* L) { | ||
68 | lua_newtable(L); | ||
69 | lua_pushinteger(L, 1); | ||
70 | lua_setfield(L, -2, "c_module"); | ||
71 | return 1; | ||
72 | } | ||
73 | ]], finally) | ||
49 | 74 | ||
50 | assert.is_true(run.luarocks_bool("build")) | 75 | assert.is_true(run.luarocks_bool("build")) |
51 | if test_env.TEST_TARGET_OS == "windows" then | 76 | if test_env.TEST_TARGET_OS == "windows" then |
@@ -245,6 +270,32 @@ describe("LuaRocks build tests #integration", function() | |||
245 | end) | 270 | end) |
246 | 271 | ||
247 | describe("rockspec format 3.0 #rs3", function() | 272 | describe("rockspec format 3.0 #rs3", function() |
273 | local tmpdir | ||
274 | local olddir | ||
275 | |||
276 | before_each(function() | ||
277 | tmpdir = get_tmp_path() | ||
278 | olddir = lfs.currentdir() | ||
279 | lfs.mkdir(tmpdir) | ||
280 | lfs.chdir(tmpdir) | ||
281 | |||
282 | lfs.mkdir("autodetect") | ||
283 | write_file("autodetect/bla.lua", "return {}", finally) | ||
284 | write_file("c_module.c", [[ | ||
285 | |||
286 | ]], finally) | ||
287 | end) | ||
288 | |||
289 | after_each(function() | ||
290 | if olddir then | ||
291 | lfs.chdir(olddir) | ||
292 | if tmpdir then | ||
293 | lfs.rmdir("autodetect") | ||
294 | lfs.rmdir(tmpdir) | ||
295 | end | ||
296 | end | ||
297 | end) | ||
298 | |||
248 | it("defaults to build.type == 'builtin'", function() | 299 | it("defaults to build.type == 'builtin'", function() |
249 | local rockspec = "a_rock-1.0-1.rockspec" | 300 | local rockspec = "a_rock-1.0-1.rockspec" |
250 | test_env.write_file(rockspec, [[ | 301 | test_env.write_file(rockspec, [[ |
@@ -277,7 +328,7 @@ describe("LuaRocks build tests #integration", function() | |||
277 | package = "autodetect" | 328 | package = "autodetect" |
278 | version = "1.0-1" | 329 | version = "1.0-1" |
279 | source = { | 330 | source = { |
280 | url = "file://]] .. testing_paths.fixtures_dir .. [[/autodetect/bla.lua" | 331 | url = "file://autodetect/bla.lua" |
281 | } | 332 | } |
282 | description = { | 333 | description = { |
283 | summary = "An example rockspec", | 334 | summary = "An example rockspec", |
@@ -299,7 +350,7 @@ describe("LuaRocks build tests #integration", function() | |||
299 | package = "autodetect" | 350 | package = "autodetect" |
300 | version = "1.0-1" | 351 | version = "1.0-1" |
301 | source = { | 352 | source = { |
302 | url = "file://]] .. testing_paths.fixtures_dir .. [[/autodetect/bla.lua" | 353 | url = "file://autodetect/bla.lua" |
303 | } | 354 | } |
304 | description = { | 355 | description = { |
305 | summary = "An example rockspec", | 356 | summary = "An example rockspec", |
@@ -319,7 +370,7 @@ describe("LuaRocks build tests #integration", function() | |||
319 | package = "autodetect" | 370 | package = "autodetect" |
320 | version = "1.0-1" | 371 | version = "1.0-1" |
321 | source = { | 372 | source = { |
322 | url = "file://]] .. testing_paths.fixtures_dir .. [[/c_module.c" | 373 | url = "file://c_module.c" |
323 | } | 374 | } |
324 | description = { | 375 | description = { |
325 | summary = "An example rockspec", | 376 | summary = "An example rockspec", |
@@ -348,9 +399,39 @@ describe("LuaRocks build tests #integration", function() | |||
348 | teardown(function() | 399 | teardown(function() |
349 | test_env.mock_server_done() | 400 | test_env.mock_server_done() |
350 | end) | 401 | end) |
351 | 402 | ||
352 | it("fails when missing external dependency", function() | 403 | it("fails when missing external dependency", function() |
353 | assert.is_false(run.luarocks_bool("build " .. testing_paths.fixtures_dir .. "/missing_external-0.1-1.rockspec INEXISTENT_INCDIR=\"/invalid/dir\"")) | 404 | local tmpdir = get_tmp_path() |
405 | local olddir = lfs.currentdir() | ||
406 | lfs.mkdir(tmpdir) | ||
407 | lfs.chdir(tmpdir) | ||
408 | |||
409 | write_file("missing_external-0.1-1.rockspec", [[ | ||
410 | package = "missing_external" | ||
411 | version = "0.1-1" | ||
412 | source = { | ||
413 | url = "https://example.com/build.lua" | ||
414 | } | ||
415 | external_dependencies = { | ||
416 | INEXISTENT = { | ||
417 | library = "inexistentlib*", | ||
418 | header = "inexistentheader*.h", | ||
419 | } | ||
420 | } | ||
421 | dependencies = { | ||
422 | "lua >= 5.1" | ||
423 | } | ||
424 | build = { | ||
425 | type = "builtin", | ||
426 | modules = { | ||
427 | build = "build.lua" | ||
428 | } | ||
429 | } | ||
430 | ]], finally) | ||
431 | assert.is_false(run.luarocks_bool("build missing_external-0.1-1.rockspec INEXISTENT_INCDIR=\"/invalid/dir\"")) | ||
432 | |||
433 | lfs.chdir(olddir) | ||
434 | lfs.rmdir(tmpdir) | ||
354 | end) | 435 | end) |
355 | 436 | ||
356 | it("builds with external dependency", function() | 437 | it("builds with external dependency", function() |
diff --git a/spec/fetch_spec.lua b/spec/fetch_spec.lua index 9a10b58d..ce4cfb56 100644 --- a/spec/fetch_spec.lua +++ b/spec/fetch_spec.lua | |||
@@ -4,11 +4,13 @@ local git_repo = require("spec.util.git_repo") | |||
4 | test_env.unload_luarocks() | 4 | test_env.unload_luarocks() |
5 | test_env.setup_specs() | 5 | test_env.setup_specs() |
6 | local fetch = require("luarocks.fetch") | 6 | local fetch = require("luarocks.fetch") |
7 | local fs = require("luarocks.fs") | ||
7 | local path = require("luarocks.path") | 8 | local path = require("luarocks.path") |
8 | local rockspecs = require("luarocks.rockspecs") | 9 | local rockspecs = require("luarocks.rockspecs") |
9 | local lfs = require("lfs") | 10 | local lfs = require("lfs") |
10 | local testing_paths = test_env.testing_paths | ||
11 | local get_tmp_path = test_env.get_tmp_path | 11 | local get_tmp_path = test_env.get_tmp_path |
12 | local testing_paths = test_env.testing_paths | ||
13 | local write_file = test_env.write_file | ||
12 | 14 | ||
13 | describe("Luarocks fetch test #unit #mock", function() | 15 | describe("Luarocks fetch test #unit #mock", function() |
14 | local are_same_files = function(file1, file2) | 16 | local are_same_files = function(file1, file2) |
@@ -121,7 +123,6 @@ describe("Luarocks fetch test #unit #mock", function() | |||
121 | end) | 123 | end) |
122 | 124 | ||
123 | describe("fetch.find_base_dir", function() | 125 | describe("fetch.find_base_dir", function() |
124 | |||
125 | it("extracts the archive given by the file argument and returns the inferred and the actual root directory in the archive", function() | 126 | it("extracts the archive given by the file argument and returns the inferred and the actual root directory in the archive", function() |
126 | local url = "http://localhost:8080/file/an_upstream_tarball-0.1.tar.gz" | 127 | local url = "http://localhost:8080/file/an_upstream_tarball-0.1.tar.gz" |
127 | local file, tmpdir = assert(fetch.fetch_url_at_temp_dir(url, "test")) | 128 | local file, tmpdir = assert(fetch.fetch_url_at_temp_dir(url, "test")) |
@@ -185,6 +186,26 @@ describe("Luarocks fetch test #unit #mock", function() | |||
185 | end) | 186 | end) |
186 | 187 | ||
187 | describe("fetch.load_local_rockspec", function() | 188 | describe("fetch.load_local_rockspec", function() |
189 | local tmpdir | ||
190 | local olddir | ||
191 | |||
192 | before_each(function() | ||
193 | tmpdir = get_tmp_path() | ||
194 | olddir = lfs.currentdir() | ||
195 | lfs.mkdir(tmpdir) | ||
196 | lfs.chdir(tmpdir) | ||
197 | fs.change_dir(tmpdir) | ||
198 | end) | ||
199 | |||
200 | after_each(function() | ||
201 | if olddir then | ||
202 | lfs.chdir(olddir) | ||
203 | if tmpdir then | ||
204 | lfs.rmdir(tmpdir) | ||
205 | end | ||
206 | end | ||
207 | end) | ||
208 | |||
188 | it("returns a table representing the rockspec from the given file skipping some checks if the quick argument is enabled", function() | 209 | it("returns a table representing the rockspec from the given file skipping some checks if the quick argument is enabled", function() |
189 | local rockspec = fetch.load_local_rockspec(testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec", true) | 210 | local rockspec = fetch.load_local_rockspec(testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec", true) |
190 | assert.same(rockspec.name, "a_rock") | 211 | assert.same(rockspec.name, "a_rock") |
@@ -192,20 +213,35 @@ describe("Luarocks fetch test #unit #mock", function() | |||
192 | assert.same(rockspec.source.url, "http://localhost:8080/file/a_rock.lua") | 213 | assert.same(rockspec.source.url, "http://localhost:8080/file/a_rock.lua") |
193 | assert.same(rockspec.description, { summary = "An example rockspec" }) | 214 | assert.same(rockspec.description, { summary = "An example rockspec" }) |
194 | 215 | ||
195 | rockspec = fetch.load_local_rockspec(testing_paths.fixtures_dir .. "/missing_mandatory_field-1.0-1.rockspec", true) | 216 | write_file("missing_mandatory_field-1.0-1.rockspec", [[ |
217 | package="missing_mandatory_field" | ||
218 | version="1.0-1" | ||
219 | source = { | ||
220 | url = "http://example.com/foo.tar.gz" | ||
221 | } | ||
222 | ]], finally) | ||
223 | rockspec = fetch.load_local_rockspec("missing_mandatory_field-1.0-1.rockspec", true) | ||
196 | assert.same(rockspec.name, "missing_mandatory_field") | 224 | assert.same(rockspec.name, "missing_mandatory_field") |
197 | assert.same(rockspec.version, "1.0-1") | 225 | assert.same(rockspec.version, "1.0-1") |
198 | assert.same(rockspec.source.url, "http://example.com/foo.tar.gz") | 226 | assert.same(rockspec.source.url, "http://example.com/foo.tar.gz") |
199 | 227 | ||
200 | rockspec = fetch.load_local_rockspec(testing_paths.fixtures_dir .. "/unknown_field-1.0-1.rockspec", true) | 228 | write_file("unknown_field-1.0-1.rockspec", [[ |
229 | package="unknown_field" | ||
230 | version="1.0-1" | ||
231 | source = { | ||
232 | url = "http://example.com/foo.tar.gz" | ||
233 | } | ||
234 | unknown="foo" | ||
235 | ]], finally) | ||
236 | rockspec = fetch.load_local_rockspec("unknown_field-1.0-1.rockspec", true) | ||
201 | assert.same(rockspec.name, "unknown_field") | 237 | assert.same(rockspec.name, "unknown_field") |
202 | assert.same(rockspec.version, "1.0-1") | 238 | assert.same(rockspec.version, "1.0-1") |
203 | assert.same(rockspec.source.url, "http://example.com/foo.tar.gz") | 239 | assert.same(rockspec.source.url, "http://example.com/foo.tar.gz") |
204 | 240 | ||
205 | -- The previous calls fail if the detailed checking is done | 241 | -- The previous calls fail if the detailed checking is done |
206 | path.use_tree(testing_paths.testing_tree) | 242 | path.use_tree(testing_paths.testing_tree) |
207 | assert.falsy(fetch.load_local_rockspec(testing_paths.fixtures_dir .. "/missing_mandatory_field-1.0-1.rockspec")) | 243 | assert.falsy(fetch.load_local_rockspec("missing_mandatory_field-1.0-1.rockspec")) |
208 | assert.falsy(fetch.load_local_rockspec(testing_paths.fixtures_dir .. "/unknown_field-1.0-1.rockspec")) | 244 | assert.falsy(fetch.load_local_rockspec("unknown_field-1.0-1.rockspec")) |
209 | end) | 245 | end) |
210 | 246 | ||
211 | it("returns a table representing the rockspec from the given file", function() | 247 | it("returns a table representing the rockspec from the given file", function() |
@@ -222,24 +258,47 @@ describe("Luarocks fetch test #unit #mock", function() | |||
222 | end) | 258 | end) |
223 | 259 | ||
224 | it("returns false if the rockspec version is not supported", function() | 260 | it("returns false if the rockspec version is not supported", function() |
225 | assert.falsy(fetch.load_local_rockspec(testing_paths.fixtures_dir .. "/invalid_version.rockspec")) | 261 | assert.falsy(fetch.load_local_rockspec("invalid_version.rockspec")) |
226 | end) | 262 | end) |
227 | 263 | ||
228 | it("returns false if the rockspec doesn't pass the type checking", function() | 264 | it("returns false if the rockspec doesn't pass the type checking", function() |
229 | assert.falsy(fetch.load_local_rockspec(testing_paths.fixtures_dir .. "/type_mismatch_string-1.0-1.rockspec")) | 265 | write_file("type_mismatch_string-1.0-1.rockspec", [[ |
266 | package="type_mismatch_version" | ||
267 | version=1.0 | ||
268 | ]], finally) | ||
269 | assert.falsy(fetch.load_local_rockspec("type_mismatch_string-1.0-1.rockspec")) | ||
230 | end) | 270 | end) |
231 | 271 | ||
232 | it("returns false if the rockspec file name is not right", function() | 272 | it("returns false if the rockspec file name is not right", function() |
233 | assert.falsy(fetch.load_local_rockspec(testing_paths.fixtures_dir .. "/invalid_rockspec_name.rockspec")) | 273 | write_file("invalid_rockspec_name.rockspec", [[ |
274 | package="invalid_rockspec_name" | ||
275 | version="1.0-1" | ||
276 | source = { | ||
277 | url = "http://example.com/foo.tar.gz" | ||
278 | } | ||
279 | build = { | ||
280 | |||
281 | } | ||
282 | ]], finally) | ||
283 | assert.falsy(fetch.load_local_rockspec("invalid_rockspec_name.rockspec")) | ||
234 | end) | 284 | end) |
235 | 285 | ||
236 | it("returns false if the version in the rockspec file name doesn't match the version declared in the rockspec", function() | 286 | it("returns false if the version in the rockspec file name doesn't match the version declared in the rockspec", function() |
237 | assert.falsy(fetch.load_local_rockspec(testing_paths.fixtures_dir .. "/inconsistent_versions-1.0-1.rockspec")) | 287 | write_file("inconsistent_versions-1.0-1.rockspec", [[ |
288 | package="inconsistent_versions" | ||
289 | version="1.0-2" | ||
290 | source = { | ||
291 | url = "http://example.com/foo.tar.gz" | ||
292 | } | ||
293 | build = { | ||
294 | |||
295 | } | ||
296 | ]], finally) | ||
297 | assert.falsy(fetch.load_local_rockspec("inconsistent_versions-1.0-1.rockspec")) | ||
238 | end) | 298 | end) |
239 | end) | 299 | end) |
240 | 300 | ||
241 | describe("fetch.load_rockspec", function() | 301 | describe("fetch.load_rockspec", function() |
242 | |||
243 | it("returns a table containing the requested rockspec by downloading it into a temporary directory", function() | 302 | it("returns a table containing the requested rockspec by downloading it into a temporary directory", function() |
244 | path.use_tree(testing_paths.testing_tree) | 303 | path.use_tree(testing_paths.testing_tree) |
245 | local rockspec = fetch.load_rockspec("http://localhost:8080/file/a_rock-1.0-1.rockspec") | 304 | local rockspec = fetch.load_rockspec("http://localhost:8080/file/a_rock-1.0-1.rockspec") |
@@ -279,6 +338,25 @@ describe("Luarocks fetch test #unit #mock", function() | |||
279 | end) | 338 | end) |
280 | 339 | ||
281 | describe("fetch.get_sources", function() | 340 | describe("fetch.get_sources", function() |
341 | local tmpdir | ||
342 | local olddir | ||
343 | |||
344 | before_each(function() | ||
345 | tmpdir = get_tmp_path() | ||
346 | olddir = lfs.currentdir() | ||
347 | lfs.mkdir(tmpdir) | ||
348 | lfs.chdir(tmpdir) | ||
349 | fs.change_dir(tmpdir) | ||
350 | end) | ||
351 | |||
352 | after_each(function() | ||
353 | if olddir then | ||
354 | lfs.chdir(olddir) | ||
355 | if tmpdir then | ||
356 | lfs.rmdir(tmpdir) | ||
357 | end | ||
358 | end | ||
359 | end) | ||
282 | 360 | ||
283 | it("downloads the sources for building a rock and returns the resulting source filename and its parent directory", function() | 361 | it("downloads the sources for building a rock and returns the resulting source filename and its parent directory", function() |
284 | local rockspec = assert(fetch.load_rockspec("http://localhost:8080/file/a_rock-1.0-1.rockspec")) | 362 | local rockspec = assert(fetch.load_rockspec("http://localhost:8080/file/a_rock-1.0-1.rockspec")) |
@@ -311,12 +389,33 @@ describe("Luarocks fetch test #unit #mock", function() | |||
311 | end) | 389 | end) |
312 | 390 | ||
313 | it("returns false and does nothing if the rockspec source url is invalid", function() | 391 | it("returns false and does nothing if the rockspec source url is invalid", function() |
314 | local rockspec = assert(fetch.load_rockspec("http://localhost:8080/file/invalid_url-1.0-1.rockspec")) | 392 | write_file("invalid_url-1.0-1.rockspec", [[ |
393 | package="invalid_url" | ||
394 | version="1.0-1" | ||
395 | source = { | ||
396 | url = "http://localhost:8080/file/nonexistent" | ||
397 | } | ||
398 | build = { | ||
399 | |||
400 | } | ||
401 | ]], finally) | ||
402 | local rockspec = assert(fetch.load_rockspec("invalid_url-1.0-1.rockspec")) | ||
315 | assert.falsy(fetch.get_sources(rockspec, false)) | 403 | assert.falsy(fetch.get_sources(rockspec, false)) |
316 | end) | 404 | end) |
317 | 405 | ||
318 | it("returns false and does nothing if the downloaded rockspec has an invalid md5 checksum", function() | 406 | it("returns false and does nothing if the downloaded rockspec has an invalid md5 checksum", function() |
319 | local rockspec = assert(fetch.load_rockspec("http://localhost:8080/file/invalid_checksum-1.0-1.rockspec")) | 407 | write_file("invalid_checksum-1.0-1.rockspec", [[ |
408 | package="invalid_checksum" | ||
409 | version="1.0-1" | ||
410 | source = { | ||
411 | url = "http://localhost:8080/file/a_rock.lua", | ||
412 | md5 = "invalid" | ||
413 | } | ||
414 | build = { | ||
415 | |||
416 | } | ||
417 | ]], finally) | ||
418 | local rockspec = assert(fetch.load_rockspec("invalid_checksum-1.0-1.rockspec")) | ||
320 | assert.falsy(fetch.get_sources(rockspec, false)) | 419 | assert.falsy(fetch.get_sources(rockspec, false)) |
321 | end) | 420 | end) |
322 | end) | 421 | end) |
diff --git a/spec/fixtures/autodetect/bla.lua b/spec/fixtures/autodetect/bla.lua deleted file mode 100644 index a5647075..00000000 --- a/spec/fixtures/autodetect/bla.lua +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | return {} | ||
diff --git a/spec/fixtures/c_module-1.0-1.rockspec b/spec/fixtures/c_module-1.0-1.rockspec deleted file mode 100644 index 2913ecf6..00000000 --- a/spec/fixtures/c_module-1.0-1.rockspec +++ /dev/null | |||
@@ -1,11 +0,0 @@ | |||
1 | package = "c_module" | ||
2 | version = "1.0-1" | ||
3 | source = { | ||
4 | url = "http://example.com/c_module" | ||
5 | } | ||
6 | build = { | ||
7 | type = "builtin", | ||
8 | modules = { | ||
9 | c_module = { "c_module.c" } | ||
10 | } | ||
11 | } | ||
diff --git a/spec/fixtures/c_module.c b/spec/fixtures/c_module.c deleted file mode 100644 index 4c27dda8..00000000 --- a/spec/fixtures/c_module.c +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | #include <lua.h> | ||
2 | #include <lauxlib.h> | ||
3 | |||
4 | int luaopen_c_module(lua_State* L) { | ||
5 | lua_newtable(L); | ||
6 | lua_pushinteger(L, 1); | ||
7 | lua_setfield(L, -2, "c_module"); | ||
8 | return 1; | ||
9 | } | ||
diff --git a/spec/fixtures/inconsistent_versions-1.0-1.rockspec b/spec/fixtures/inconsistent_versions-1.0-1.rockspec deleted file mode 100644 index c8c1eee2..00000000 --- a/spec/fixtures/inconsistent_versions-1.0-1.rockspec +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | package="inconsistent_versions" | ||
2 | version="1.0-2" | ||
3 | source = { | ||
4 | url = "http://example.com/foo.tar.gz" | ||
5 | } | ||
6 | build = { | ||
7 | |||
8 | } | ||
diff --git a/spec/fixtures/invalid_checksum-1.0-1.rockspec b/spec/fixtures/invalid_checksum-1.0-1.rockspec deleted file mode 100644 index 256cb1fe..00000000 --- a/spec/fixtures/invalid_checksum-1.0-1.rockspec +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | package="invalid_checksum" | ||
2 | version="1.0-1" | ||
3 | source = { | ||
4 | url = "http://localhost:8080/file/a_rock.lua", | ||
5 | md5 = "invalid" | ||
6 | } | ||
7 | build = { | ||
8 | |||
9 | } | ||
diff --git a/spec/fixtures/invalid_rockspec_name.rockspec b/spec/fixtures/invalid_rockspec_name.rockspec deleted file mode 100644 index ab70c75d..00000000 --- a/spec/fixtures/invalid_rockspec_name.rockspec +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | package="invalid_rockspec_name" | ||
2 | version="1.0-1" | ||
3 | source = { | ||
4 | url = "http://example.com/foo.tar.gz" | ||
5 | } | ||
6 | build = { | ||
7 | |||
8 | } | ||
diff --git a/spec/fixtures/invalid_rockspec_version-1.0-1.rockspec b/spec/fixtures/invalid_rockspec_version-1.0-1.rockspec deleted file mode 100644 index f644b3d9..00000000 --- a/spec/fixtures/invalid_rockspec_version-1.0-1.rockspec +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | rockspec_format="3.1" | ||
2 | package="invalid_rockspec_version" | ||
3 | version="1.0-1" | ||
4 | source = { | ||
5 | url = "http://example.com/foo.tar.gz" | ||
6 | } | ||
7 | build = { | ||
8 | |||
9 | } | ||
diff --git a/spec/fixtures/invalid_url-1.0-1.rockspec b/spec/fixtures/invalid_url-1.0-1.rockspec deleted file mode 100644 index a74b0281..00000000 --- a/spec/fixtures/invalid_url-1.0-1.rockspec +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | package="invalid_url" | ||
2 | version="1.0-1" | ||
3 | source = { | ||
4 | url = "http://localhost:8080/file/nonexistent" | ||
5 | } | ||
6 | build = { | ||
7 | |||
8 | } | ||
diff --git a/spec/fixtures/missing_external-0.1-1.rockspec b/spec/fixtures/missing_external-0.1-1.rockspec deleted file mode 100644 index 5f8e6219..00000000 --- a/spec/fixtures/missing_external-0.1-1.rockspec +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | package = "missing_external" | ||
2 | version = "0.1-1" | ||
3 | source = { | ||
4 | -- any valid URL | ||
5 | url = "https://raw.github.com/keplerproject/luarocks/master/src/luarocks/build.lua" | ||
6 | } | ||
7 | description = { | ||
8 | summary = "Missing external dependency", | ||
9 | } | ||
10 | external_dependencies = { | ||
11 | INEXISTENT = { | ||
12 | library = "inexistentlib*", | ||
13 | header = "inexistentheader*.h", | ||
14 | } | ||
15 | } | ||
16 | dependencies = { | ||
17 | "lua >= 5.1" | ||
18 | } | ||
19 | build = { | ||
20 | type = "builtin", | ||
21 | modules = { | ||
22 | build = "build.lua" | ||
23 | } | ||
24 | } | ||
diff --git a/spec/fixtures/missing_mandatory_field-1.0-1.rockspec b/spec/fixtures/missing_mandatory_field-1.0-1.rockspec deleted file mode 100644 index 56dac987..00000000 --- a/spec/fixtures/missing_mandatory_field-1.0-1.rockspec +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | package="missing_mandatory_field" | ||
2 | version="1.0-1" | ||
3 | source = { | ||
4 | url = "http://example.com/foo.tar.gz" | ||
5 | } | ||
diff --git a/spec/fixtures/no_build_table-0.1-1.rockspec b/spec/fixtures/no_build_table-0.1-1.rockspec deleted file mode 100644 index 5d79e9a0..00000000 --- a/spec/fixtures/no_build_table-0.1-1.rockspec +++ /dev/null | |||
@@ -1,12 +0,0 @@ | |||
1 | package = "no_build_table" | ||
2 | version = "0.1-1" | ||
3 | source = { | ||
4 | -- any valid URL | ||
5 | url = "https://raw.github.com/keplerproject/luarocks/master/src/luarocks/build.lua" | ||
6 | } | ||
7 | description = { | ||
8 | summary = "A rockspec with no build field", | ||
9 | } | ||
10 | dependencies = { | ||
11 | "lua >= 5.1" | ||
12 | } | ||
diff --git a/spec/fixtures/not_a_zipfile-1.0-1.src.rock b/spec/fixtures/not_a_zipfile-1.0-1.src.rock deleted file mode 100644 index e36f8bbe..00000000 --- a/spec/fixtures/not_a_zipfile-1.0-1.src.rock +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | I am not a .zip file! | ||
diff --git a/spec/fixtures/type_mismatch_string-1.0-1.rockspec b/spec/fixtures/type_mismatch_string-1.0-1.rockspec deleted file mode 100644 index 7a607cfd..00000000 --- a/spec/fixtures/type_mismatch_string-1.0-1.rockspec +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | |||
2 | package="type_mismatch_version" | ||
3 | version=1.0 | ||
4 | |||
diff --git a/spec/fixtures/type_mismatch_table-1.0-1.rockspec b/spec/fixtures/type_mismatch_table-1.0-1.rockspec deleted file mode 100644 index f348b798..00000000 --- a/spec/fixtures/type_mismatch_table-1.0-1.rockspec +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | |||
2 | package="type_mismatch_table" | ||
3 | version="1.0-1" | ||
4 | |||
5 | source = "not a table" | ||
diff --git a/spec/fixtures/type_mismatch_version-1.0-1.rockspec b/spec/fixtures/type_mismatch_version-1.0-1.rockspec deleted file mode 100644 index 5e30dae6..00000000 --- a/spec/fixtures/type_mismatch_version-1.0-1.rockspec +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | |||
2 | package="type_mismatch_version" | ||
3 | version="1.0" | ||
4 | |||
diff --git a/spec/fixtures/unknown_field-1.0-1.rockspec b/spec/fixtures/unknown_field-1.0-1.rockspec deleted file mode 100644 index bcad2d53..00000000 --- a/spec/fixtures/unknown_field-1.0-1.rockspec +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | package="unknown_field" | ||
2 | version="1.0-1" | ||
3 | source = { | ||
4 | url = "http://example.com/foo.tar.gz" | ||
5 | } | ||
6 | unknown="foo" | ||
diff --git a/spec/install_spec.lua b/spec/install_spec.lua index 3525cda3..f18b7c89 100644 --- a/spec/install_spec.lua +++ b/spec/install_spec.lua | |||
@@ -3,6 +3,8 @@ local lfs = require("lfs") | |||
3 | local run = test_env.run | 3 | local run = test_env.run |
4 | local testing_paths = test_env.testing_paths | 4 | local testing_paths = test_env.testing_paths |
5 | local env_variables = test_env.env_variables | 5 | local env_variables = test_env.env_variables |
6 | local get_tmp_path = test_env.get_tmp_path | ||
7 | local write_file = test_env.write_file | ||
6 | 8 | ||
7 | test_env.unload_luarocks() | 9 | test_env.unload_luarocks() |
8 | 10 | ||
@@ -55,7 +57,18 @@ describe("luarocks install #integration", function() | |||
55 | end) | 57 | end) |
56 | 58 | ||
57 | it("fails not a zip file", function() | 59 | it("fails not a zip file", function() |
58 | assert.is_false(run.luarocks_bool("install " .. testing_paths.fixtures_dir .. "/not_a_zipfile-1.0-1.src.rock")) | 60 | local olddir = lfs.currentdir() |
61 | local tmpdir = get_tmp_path() | ||
62 | lfs.mkdir(tmpdir) | ||
63 | lfs.chdir(tmpdir) | ||
64 | |||
65 | write_file("not_a_zipfile-1.0-1.src.rock", [[ | ||
66 | I am not a .zip file! | ||
67 | ]], finally) | ||
68 | assert.is_false(run.luarocks_bool("install not_a_zipfile-1.0-1.src.rock")) | ||
69 | |||
70 | lfs.chdir(olddir) | ||
71 | lfs.rmdir(tmpdir) | ||
59 | end) | 72 | end) |
60 | 73 | ||
61 | it("only-deps of lxsh show there is no lxsh", function() | 74 | it("only-deps of lxsh show there is no lxsh", function() |
diff --git a/spec/lint_spec.lua b/spec/lint_spec.lua index e7af97fa..4bc93e95 100644 --- a/spec/lint_spec.lua +++ b/spec/lint_spec.lua | |||
@@ -1,8 +1,11 @@ | |||
1 | local test_env = require("spec.util.test_env") | 1 | local test_env = require("spec.util.test_env") |
2 | local run = test_env.run | 2 | local run = test_env.run |
3 | local get_tmp_path = test_env.get_tmp_path | ||
3 | local testing_paths = test_env.testing_paths | 4 | local testing_paths = test_env.testing_paths |
5 | local write_file = test_env.write_file | ||
4 | 6 | ||
5 | test_env.unload_luarocks() | 7 | test_env.unload_luarocks() |
8 | local lfs = require("lfs") | ||
6 | 9 | ||
7 | local extra_rocks = { | 10 | local extra_rocks = { |
8 | "/validate-args-1.5.4-1.rockspec" | 11 | "/validate-args-1.5.4-1.rockspec" |
@@ -30,20 +33,66 @@ describe("LuaRocks lint tests #integration", function() | |||
30 | end) | 33 | end) |
31 | 34 | ||
32 | describe("LuaRocks lint mismatch set", function() | 35 | describe("LuaRocks lint mismatch set", function() |
36 | local tmpdir | ||
37 | local olddir | ||
38 | |||
39 | before_each(function() | ||
40 | tmpdir = get_tmp_path() | ||
41 | olddir = lfs.currentdir() | ||
42 | lfs.mkdir(tmpdir) | ||
43 | lfs.chdir(tmpdir) | ||
44 | end) | ||
45 | |||
46 | after_each(function() | ||
47 | if olddir then | ||
48 | lfs.chdir(olddir) | ||
49 | if tmpdir then | ||
50 | lfs.rmdir(tmpdir) | ||
51 | end | ||
52 | end | ||
53 | end) | ||
54 | |||
33 | it("LuaRocks lint mismatch string", function() | 55 | it("LuaRocks lint mismatch string", function() |
34 | assert.is_false(run.luarocks_bool("lint " .. testing_paths.fixtures_dir .. "/type_mismatch_string-1.0-1.rockspec")) | 56 | write_file("type_mismatch_string-1.0-1.rockspec", [[ |
57 | package="type_mismatch_version" | ||
58 | version=1.0 | ||
59 | ]], finally) | ||
60 | assert.is_false(run.luarocks_bool("lint type_mismatch_string-1.0-1.rockspec")) | ||
35 | end) | 61 | end) |
36 | 62 | ||
37 | it("LuaRocks lint mismatch version", function() | 63 | it("LuaRocks lint mismatch version", function() |
38 | assert.is_false(run.luarocks_bool("lint " .. testing_paths.fixtures_dir .. "/type_mismatch_version-1.0-1.rockspec")) | 64 | write_file("type_mismatch_version-1.0-1.rockspec", [[ |
65 | package="type_mismatch_version" | ||
66 | version="1.0" | ||
67 | ]], finally) | ||
68 | assert.is_false(run.luarocks_bool("lint type_mismatch_version-1.0-1.rockspec")) | ||
39 | end) | 69 | end) |
40 | 70 | ||
41 | it("LuaRocks lint mismatch table", function() | 71 | it("LuaRocks lint mismatch table", function() |
42 | assert.is_false(run.luarocks_bool("lint " .. testing_paths.fixtures_dir .. "/type_mismatch_table-1.0-1.rockspec")) | 72 | write_file("type_mismatch_table-1.0-1.rockspec", [[ |
73 | package="type_mismatch_table" | ||
74 | version="1.0-1" | ||
75 | |||
76 | source = "not a table" | ||
77 | ]], finally) | ||
78 | assert.is_false(run.luarocks_bool("lint type_mismatch_table-1.0-1.rockspec")) | ||
43 | end) | 79 | end) |
44 | 80 | ||
45 | it("LuaRocks lint mismatch no build table", function() | 81 | it("LuaRocks lint mismatch no build table", function() |
46 | assert.is_false(run.luarocks_bool("lint " .. testing_paths.fixtures_dir .. "/no_build_table-1.0-1.rockspec")) | 82 | write_file("no_build_table-1.0-1.rockspec", [[ |
83 | package = "no_build_table" | ||
84 | version = "0.1-1" | ||
85 | source = { | ||
86 | url = "http://example.com/foo/tar.gz" | ||
87 | } | ||
88 | description = { | ||
89 | summary = "A rockspec with no build field", | ||
90 | } | ||
91 | dependencies = { | ||
92 | "lua >= 5.1" | ||
93 | } | ||
94 | ]], finally) | ||
95 | assert.is_false(run.luarocks_bool("lint no_build_table-1.0-1.rockspec")) | ||
47 | end) | 96 | end) |
48 | end) | 97 | end) |
49 | end) | 98 | end) |