diff options
Diffstat (limited to 'spec/build_spec.lua')
-rw-r--r-- | spec/build_spec.lua | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/spec/build_spec.lua b/spec/build_spec.lua index 034c70d7..2e139a41 100644 --- a/spec/build_spec.lua +++ b/spec/build_spec.lua | |||
@@ -373,6 +373,101 @@ describe("LuaRocks build #integration", function() | |||
373 | end) | 373 | end) |
374 | end) | 374 | end) |
375 | 375 | ||
376 | describe("rockspec format 3.1", function() | ||
377 | it("version of Lua is not provided for old format", function() | ||
378 | test_env.run_in_tmp(function(tmpdir) | ||
379 | write_file("verify_argument.lua", string.format("assert(arg[1] == %q)", test_env.lua_version)) | ||
380 | write_file("uses_luaversion_variable-3.1-11.rockspec", [[ | ||
381 | package = "uses_luaversion_variable" | ||
382 | version = "3.1-11" | ||
383 | source = { | ||
384 | url = "file://]] .. tmpdir:gsub("\\", "/") .. [[/verify_argument.lua" | ||
385 | } | ||
386 | dependencies = { | ||
387 | "lua >= 5.1" | ||
388 | } | ||
389 | build = { | ||
390 | type = "command", | ||
391 | build_command = "$(LUA) verify_argument.lua $(LUA_VERSION)", | ||
392 | } | ||
393 | ]]) | ||
394 | assert.is_false(run.luarocks_bool("build uses_luaversion_variable-3.1-11.rockspec")) | ||
395 | end, finally) | ||
396 | end) | ||
397 | |||
398 | it("version of Lua is provided as variable", function() | ||
399 | test_env.run_in_tmp(function(tmpdir) | ||
400 | write_file("verify_argument.lua", string.format("assert(arg[1] == %q)", test_env.lua_version)) | ||
401 | write_file("uses_luaversion_variable-3.1-11.rockspec", [[ | ||
402 | rockspec_format = "3.1" | ||
403 | package = "uses_luaversion_variable" | ||
404 | version = "3.1-11" | ||
405 | source = { | ||
406 | url = "file://]] .. tmpdir:gsub("\\", "/") .. [[/verify_argument.lua" | ||
407 | } | ||
408 | dependencies = { | ||
409 | "lua >= 5.1" | ||
410 | } | ||
411 | build = { | ||
412 | type = "command", | ||
413 | build_command = "$(LUA) verify_argument.lua $(LUA_VERSION)", | ||
414 | } | ||
415 | ]]) | ||
416 | assert.is_truthy(run.luarocks_bool("build uses_luaversion_variable-3.1-11.rockspec")) | ||
417 | assert.is.truthy(run.luarocks("show uses_luaversion_variable")) | ||
418 | end, finally) | ||
419 | end) | ||
420 | |||
421 | |||
422 | it("dependency directory is not provided for old format", function() | ||
423 | test_env.run_in_tmp(function(tmpdir) | ||
424 | local rocks_tree = run.luarocks("config variables.ROCKS_TREE") | ||
425 | local rocks_path = table.concat({rocks_tree, "a_rock", "1.0-1"}, package.config:sub(1, 1)) | ||
426 | write_file("verify_argument.lua", string.format("assert(arg[1] == %q)", rocks_path)) | ||
427 | write_file("uses_rockdir_variable-3.1-11.rockspec", [[ | ||
428 | package = "uses_rockdir_variable" | ||
429 | version = "3.1-11" | ||
430 | source = { | ||
431 | url = "file://]] .. tmpdir:gsub("\\", "/") .. [[/verify_argument.lua" | ||
432 | } | ||
433 | dependencies = { | ||
434 | "a_rock 1.0" | ||
435 | } | ||
436 | build = { | ||
437 | type = "command", | ||
438 | build_command = "$(LUA) verify_argument.lua $(A_ROCK_ROCKDIR)", | ||
439 | } | ||
440 | ]]) | ||
441 | assert.is_false(run.luarocks_bool("build uses_rockdir_variable-3.1-11.rockspec")) | ||
442 | end, finally) | ||
443 | end) | ||
444 | |||
445 | it("dependency directory is provided as variable", function() | ||
446 | test_env.run_in_tmp(function(tmpdir) | ||
447 | local rocks_tree = run.luarocks("config variables.ROCKS_TREE") | ||
448 | local rocks_path = table.concat({rocks_tree, "a_rock", "1.0-1"}, package.config:sub(1, 1)) | ||
449 | write_file("verify_argument.lua", string.format("assert(arg[1] == %q)", rocks_path)) | ||
450 | write_file("uses_rockdir_variable-3.1-11.rockspec", [[ | ||
451 | rockspec_format = "3.1" | ||
452 | package = "uses_rockdir_variable" | ||
453 | version = "3.1-11" | ||
454 | source = { | ||
455 | url = "file://]] .. tmpdir:gsub("\\", "/") .. [[/verify_argument.lua" | ||
456 | } | ||
457 | dependencies = { | ||
458 | "a_rock 1.0" | ||
459 | } | ||
460 | build = { | ||
461 | type = "command", | ||
462 | build_command = "$(LUA) verify_argument.lua $(A_ROCK_ROCKDIR)", | ||
463 | } | ||
464 | ]]) | ||
465 | assert.is_truthy(run.luarocks_bool("build uses_rockdir_variable-3.1-11.rockspec")) | ||
466 | assert.is.truthy(run.luarocks("show uses_rockdir_variable")) | ||
467 | end, finally) | ||
468 | end) | ||
469 | end) | ||
470 | |||
376 | describe("#mock external dependencies", function() | 471 | describe("#mock external dependencies", function() |
377 | lazy_setup(function() | 472 | lazy_setup(function() |
378 | test_env.setup_specs(nil, "mock") | 473 | test_env.setup_specs(nil, "mock") |