aboutsummaryrefslogtreecommitdiff
path: root/spec/build_spec.lua
diff options
context:
space:
mode:
authorRenato Maia <maia.renato@gmail.com>2025-04-27 17:03:33 -0300
committerHisham Muhammad <hisham@gobolinux.org>2025-05-19 11:30:51 -0300
commit3b7bf479568790a8b04772a36c1b3e712fed4579 (patch)
tree01b97d4dacb07ee45082b23bb9c664013f41655e /spec/build_spec.lua
parent4d7b546602b906f924ac91a01276cd3b2569ca9f (diff)
downloadluarocks-3b7bf479568790a8b04772a36c1b3e712fed4579.tar.gz
luarocks-3b7bf479568790a8b04772a36c1b3e712fed4579.tar.bz2
luarocks-3b7bf479568790a8b04772a36c1b3e712fed4579.zip
feat: add build vars. for rockspecs with the dir. of its deps.
Rockspecs can access the directory of its dependencies using variables in the format 'foo_ROCKDIR' where 'foo' is the name of a dependency. This is used to be able to access files of the rock like 'conf', 'docs' and more.
Diffstat (limited to 'spec/build_spec.lua')
-rw-r--r--spec/build_spec.lua49
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/build_spec.lua b/spec/build_spec.lua
index ad6f4d42..2e139a41 100644
--- a/spec/build_spec.lua
+++ b/spec/build_spec.lua
@@ -417,6 +417,55 @@ describe("LuaRocks build #integration", function()
417 assert.is.truthy(run.luarocks("show uses_luaversion_variable")) 417 assert.is.truthy(run.luarocks("show uses_luaversion_variable"))
418 end, finally) 418 end, finally)
419 end) 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)
420 end) 469 end)
421 470
422 describe("#mock external dependencies", function() 471 describe("#mock external dependencies", function()