aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorV1K1NGbg <victor@ilchev.com>2024-08-13 13:03:18 +0300
committerV1K1NGbg <victor@ilchev.com>2024-08-13 13:03:18 +0300
commitcd7f62b9bd1b91fb18d798e408bf41936b0f9bb9 (patch)
tree1de22400aebfec400ad176d77f84532ca19c27de
parentd147560d574dcd9bde5c17eefd49dbbfee5b2505 (diff)
downloadluarocks-cd7f62b9bd1b91fb18d798e408bf41936b0f9bb9.tar.gz
luarocks-cd7f62b9bd1b91fb18d798e408bf41936b0f9bb9.tar.bz2
luarocks-cd7f62b9bd1b91fb18d798e408bf41936b0f9bb9.zip
deps rockspec and test
m---------binary-samples0
-rw-r--r--src/luarocks/core/types/rockspec.lua4
-rw-r--r--src/luarocks/core/types/rockspec.tl4
-rw-r--r--src/luarocks/core/types/testrunner.d.tl2
-rw-r--r--src/luarocks/deps.lua12
-rw-r--r--src/luarocks/deps.tl16
-rw-r--r--src/luarocks/test.tl23
-rw-r--r--src/luarocks/type/rockspec.lua7
8 files changed, 39 insertions, 29 deletions
diff --git a/binary-samples b/binary-samples
new file mode 160000
Subproject 51a1bc57c757f501efc5cc132bfcc1c6076085b
diff --git a/src/luarocks/core/types/rockspec.lua b/src/luarocks/core/types/rockspec.lua
index 6acd4b64..9ee7de37 100644
--- a/src/luarocks/core/types/rockspec.lua
+++ b/src/luarocks/core/types/rockspec.lua
@@ -1,9 +1,7 @@
1 1
2 2
3 3
4local rockspec = {Description = {}, Variables = {}, Source = {}, Test = {}, Install = {}, Build = {}, Dependencies = {}, ExternalDependencies = {}, Hooks = {}, Deploy = {}, Rockspec = {}, } 4local rockspec = {Description = {}, Variables = {}, Source = {}, Test = {}, Install = {}, Build = {}, Dependencies = {}, Hooks = {}, Deploy = {}, Rockspec = {}, }
5
6
7 5
8 6
9 7
diff --git a/src/luarocks/core/types/rockspec.tl b/src/luarocks/core/types/rockspec.tl
index 37f2f240..37aacf7d 100644
--- a/src/luarocks/core/types/rockspec.tl
+++ b/src/luarocks/core/types/rockspec.tl
@@ -28,10 +28,10 @@ local record rockspec
28 BINDIR: string 28 BINDIR: string
29 DOCDIR: string 29 DOCDIR: string
30 CURLNOCERTFLAG: string 30 CURLNOCERTFLAG: string
31 LUA_INCDIR_OK: boolean 31 LUA_INCDIR_OK: string
32 LUA_INCDIR: string 32 LUA_INCDIR: string
33 LUA_DIR: string 33 LUA_DIR: string
34 LUA_LIBDIR_OK: boolean 34 LUA_LIBDIR_OK: string
35 LUA_LIBDIR: string 35 LUA_LIBDIR: string
36 LUA_LIBDIR_FILE: string 36 LUA_LIBDIR_FILE: string
37 LUALIB: string 37 LUALIB: string
diff --git a/src/luarocks/core/types/testrunner.d.tl b/src/luarocks/core/types/testrunner.d.tl
index 0b6c05c9..508356fa 100644
--- a/src/luarocks/core/types/testrunner.d.tl
+++ b/src/luarocks/core/types/testrunner.d.tl
@@ -4,7 +4,7 @@ local type Test = r.Test
4local record testrunner 4local record testrunner
5 record TestRunner 5 record TestRunner
6 detect_type: function(): boolean 6 detect_type: function(): boolean
7 run_tests: function(Test, {string}): boolean, string, string 7 run_tests: function(Test, {string}): boolean, string
8 end 8 end
9end 9end
10return testrunner \ No newline at end of file 10return testrunner \ No newline at end of file
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua
index 05cbbc2d..d4ca2322 100644
--- a/src/luarocks/deps.lua
+++ b/src/luarocks/deps.lua
@@ -760,7 +760,7 @@ local function find_lua_incdir(prefix, luaver, luajitver)
760end 760end
761 761
762function deps.check_lua_incdir(vars) 762function deps.check_lua_incdir(vars)
763 if vars.LUA_INCDIR_OK == true then 763 if vars.LUA_INCDIR_OK == "ok" then
764 return true 764 return true
765 end 765 end
766 766
@@ -769,7 +769,7 @@ function deps.check_lua_incdir(vars)
769 if vars.LUA_INCDIR then 769 if vars.LUA_INCDIR then
770 local ok, err = lua_h_exists(vars.LUA_INCDIR, cfg.lua_version) 770 local ok, err = lua_h_exists(vars.LUA_INCDIR, cfg.lua_version)
771 if ok then 771 if ok then
772 vars.LUA_INCDIR_OK = true 772 vars.LUA_INCDIR_OK = "ok"
773 end 773 end
774 return ok, err 774 return ok, err
775 end 775 end
@@ -778,7 +778,7 @@ function deps.check_lua_incdir(vars)
778 local d, err = find_lua_incdir(vars.LUA_DIR, cfg.lua_version, ljv) 778 local d, err = find_lua_incdir(vars.LUA_DIR, cfg.lua_version, ljv)
779 if d then 779 if d then
780 vars.LUA_INCDIR = d 780 vars.LUA_INCDIR = d
781 vars.LUA_INCDIR_OK = true 781 vars.LUA_INCDIR_OK = "ok"
782 return true 782 return true
783 end 783 end
784 return nil, err 784 return nil, err
@@ -788,7 +788,7 @@ function deps.check_lua_incdir(vars)
788end 788end
789 789
790function deps.check_lua_libdir(vars) 790function deps.check_lua_libdir(vars)
791 if vars.LUA_LIBDIR_OK == true then 791 if vars.LUA_LIBDIR_OK == "ok" then
792 return true 792 return true
793 end 793 end
794 794
@@ -796,7 +796,7 @@ function deps.check_lua_libdir(vars)
796 local ljv = util.get_luajit_version() 796 local ljv = util.get_luajit_version()
797 797
798 if vars.LUA_LIBDIR and vars.LUALIB and fs.exists(dir.path(vars.LUA_LIBDIR, vars.LUALIB)) then 798 if vars.LUA_LIBDIR and vars.LUALIB and fs.exists(dir.path(vars.LUA_LIBDIR, vars.LUALIB)) then
799 vars.LUA_LIBDIR_OK = true 799 vars.LUA_LIBDIR_OK = "ok"
800 return true 800 return true
801 end 801 end
802 802
@@ -837,7 +837,7 @@ function deps.check_lua_libdir(vars)
837 837
838 if ok then 838 if ok then
839 vars.LUALIB = vars.LUA_LIBDIR_FILE 839 vars.LUALIB = vars.LUA_LIBDIR_FILE
840 vars.LUA_LIBDIR_OK = true 840 vars.LUA_LIBDIR_OK = "ok"
841 return true 841 return true
842 else 842 else
843 err = err or "Failed finding the Lua library. You can use `luarocks config variables.LUA_LIBDIR <path>` to set the correct location." 843 err = err or "Failed finding the Lua library. You can use `luarocks config variables.LUA_LIBDIR <path>` to set the correct location."
diff --git a/src/luarocks/deps.tl b/src/luarocks/deps.tl
index d3172f3b..97f051d1 100644
--- a/src/luarocks/deps.tl
+++ b/src/luarocks/deps.tl
@@ -649,7 +649,7 @@ function deps.check_external_deps(rockspec: Rockspec, mode: string): boolean, st
649 end 649 end
650 650
651 for name, ext_files in util.sortedpairs(rockspec.external_dependencies) do 651 for name, ext_files in util.sortedpairs(rockspec.external_dependencies) do
652 local ok, err_dirname, err_testfile, err_files = check_external_dependency(name, ext_files as {string : string | {string}}, rockspec.variables as {string: string}, mode) 652 local ok, err_dirname, err_testfile, err_files = check_external_dependency(name, ext_files as {string : string | {string}}, rockspec.variables, mode)
653 if not ok then 653 if not ok then
654 local lines = {"Could not find "..err_testfile.." file for "..name} 654 local lines = {"Could not find "..err_testfile.." file for "..name}
655 655
@@ -760,7 +760,7 @@ local function find_lua_incdir(prefix: string, luaver: string, luajitver: string
760end 760end
761 761
762function deps.check_lua_incdir(vars: Variables): boolean | string, string, string 762function deps.check_lua_incdir(vars: Variables): boolean | string, string, string
763 if vars.LUA_INCDIR_OK == true 763 if vars.LUA_INCDIR_OK == "ok"
764 then return true 764 then return true
765 end 765 end
766 766
@@ -769,7 +769,7 @@ function deps.check_lua_incdir(vars: Variables): boolean | string, string, strin
769 if vars.LUA_INCDIR then 769 if vars.LUA_INCDIR then
770 local ok, err = lua_h_exists(vars.LUA_INCDIR, cfg.lua_version) 770 local ok, err = lua_h_exists(vars.LUA_INCDIR, cfg.lua_version)
771 if ok then 771 if ok then
772 vars.LUA_INCDIR_OK = true 772 vars.LUA_INCDIR_OK = "ok"
773 end 773 end
774 return ok, err 774 return ok, err
775 end 775 end
@@ -778,7 +778,7 @@ function deps.check_lua_incdir(vars: Variables): boolean | string, string, strin
778 local d, err = find_lua_incdir(vars.LUA_DIR, cfg.lua_version, ljv) 778 local d, err = find_lua_incdir(vars.LUA_DIR, cfg.lua_version, ljv)
779 if d then 779 if d then
780 vars.LUA_INCDIR = d 780 vars.LUA_INCDIR = d
781 vars.LUA_INCDIR_OK = true 781 vars.LUA_INCDIR_OK = "ok"
782 return true 782 return true
783 end 783 end
784 return nil, err 784 return nil, err
@@ -788,7 +788,7 @@ function deps.check_lua_incdir(vars: Variables): boolean | string, string, strin
788end 788end
789 789
790function deps.check_lua_libdir(vars: Variables): boolean, string, string, {string : {string}} 790function deps.check_lua_libdir(vars: Variables): boolean, string, string, {string : {string}}
791 if vars.LUA_LIBDIR_OK == true 791 if vars.LUA_LIBDIR_OK == "ok" --! fix later
792 then return true 792 then return true
793 end 793 end
794 794
@@ -796,7 +796,7 @@ function deps.check_lua_libdir(vars: Variables): boolean, string, string, {strin
796 local ljv = util.get_luajit_version() 796 local ljv = util.get_luajit_version()
797 797
798 if vars.LUA_LIBDIR and vars.LUALIB and fs.exists(dir.path(vars.LUA_LIBDIR, vars.LUALIB)) then 798 if vars.LUA_LIBDIR and vars.LUALIB and fs.exists(dir.path(vars.LUA_LIBDIR, vars.LUALIB)) then
799 vars.LUA_LIBDIR_OK = true 799 vars.LUA_LIBDIR_OK = "ok"
800 return true 800 return true
801 end 801 end
802 802
@@ -814,7 +814,7 @@ function deps.check_lua_libdir(vars: Variables): boolean, string, string, {strin
814 end 814 end
815 local cache = {} 815 local cache = {}
816 local save_LUA_INCDIR = vars.LUA_INCDIR 816 local save_LUA_INCDIR = vars.LUA_INCDIR
817 local ok, _, _, errfiles = check_external_dependency("LUA", { library = libnames }, vars as {string: string}, "build", cache) 817 local ok, _, _, errfiles = check_external_dependency("LUA", { library = libnames }, vars, "build", cache)
818 vars.LUA_INCDIR = save_LUA_INCDIR 818 vars.LUA_INCDIR = save_LUA_INCDIR
819 local err: string 819 local err: string
820 if ok then 820 if ok then
@@ -837,7 +837,7 @@ function deps.check_lua_libdir(vars: Variables): boolean, string, string, {strin
837 837
838 if ok then 838 if ok then
839 vars.LUALIB = vars.LUA_LIBDIR_FILE 839 vars.LUALIB = vars.LUA_LIBDIR_FILE
840 vars.LUA_LIBDIR_OK = true 840 vars.LUA_LIBDIR_OK = "ok"
841 return true 841 return true
842 else 842 else
843 err = err or "Failed finding the Lua library. You can use `luarocks config variables.LUA_LIBDIR <path>` to set the correct location." 843 err = err or "Failed finding the Lua library. You can use `luarocks config variables.LUA_LIBDIR <path>` to set the correct location."
diff --git a/src/luarocks/test.tl b/src/luarocks/test.tl
index b3f2a0fc..83bb4517 100644
--- a/src/luarocks/test.tl
+++ b/src/luarocks/test.tl
@@ -1,4 +1,9 @@
1local record test 1local record test
2 record TestModules
3 {TestRunner}
4 typetomod: {string: TestRunner}
5 modtotype: {TestRunner: string}
6 end
2end 7end
3 8
4local fetch = require("luarocks.fetch") 9local fetch = require("luarocks.fetch")
@@ -7,18 +12,20 @@ local util = require("luarocks.util")
7 12
8local type r = require("luarocks.core.types.rockspec") 13local type r = require("luarocks.core.types.rockspec")
9local type Rockspec = r.Rockspec 14local type Rockspec = r.Rockspec
15local type Dependencies = r.Dependencies
10local type Test = r.Test 16local type Test = r.Test
11 17
12
13local type t = require("luarocks.core.types.testrunner") 18local type t = require("luarocks.core.types.testrunner")
14local type TestRunner = t.TestRunner 19local type TestRunner = t.TestRunner
15 20
21local type TestModules = test.TestModules
22
16local test_types = { 23local test_types = {
17 "busted", 24 "busted",
18 "command", 25 "command",
19} 26}
20 27
21local test_modules: {string | TestRunner} = {} 28local test_modules: TestModules = {}
22 29
23for _, test_type in ipairs(test_types) do 30for _, test_type in ipairs(test_types) do
24 local mod: TestRunner 31 local mod: TestRunner
@@ -28,8 +35,8 @@ for _, test_type in ipairs(test_types) do
28 mod = require("luarocks.test.busted") 35 mod = require("luarocks.test.busted")
29 end 36 end
30 table.insert(test_modules, mod) 37 table.insert(test_modules, mod)
31 test_modules[test_type] = mod --! 38 test_modules.typetomod[test_type] = mod
32 test_modules[mod] = test_type 39 test_modules.modtotype[mod] = test_type
33end 40end
34 41
35local function get_test_type(rockspec: Rockspec): string, string 42local function get_test_type(rockspec: Rockspec): string, string
@@ -39,7 +46,7 @@ local function get_test_type(rockspec: Rockspec): string, string
39 46
40 for _, test_module in ipairs(test_modules) do 47 for _, test_module in ipairs(test_modules) do
41 if test_module.detect_type() then 48 if test_module.detect_type() then
42 return test_modules[test_module] 49 return test_modules.modtotype[test_module]
43 end 50 end
44 end 51 end
45 52
@@ -47,7 +54,7 @@ local function get_test_type(rockspec: Rockspec): string, string
47end 54end
48 55
49-- Run test suite as configured in rockspec in the current directory. 56-- Run test suite as configured in rockspec in the current directory.
50function test.run_test_suite(rockspec_arg: string | Rockspec, test_type: string, args, prepare): boolean, string, string 57function test.run_test_suite(rockspec_arg: string | Rockspec, test_type: string, args: {string}, prepare: boolean): boolean, string, string
51 local rockspec: Rockspec 58 local rockspec: Rockspec
52 if rockspec_arg is string then 59 if rockspec_arg is string then
53 local err, errcode: string, string 60 local err, errcode: string, string
@@ -74,7 +81,7 @@ function test.run_test_suite(rockspec_arg: string | Rockspec, test_type: string,
74 "test_dependencies", 81 "test_dependencies",
75 } 82 }
76 for _, dep_kind in ipairs(all_deps) do 83 for _, dep_kind in ipairs(all_deps) do
77 if rockspec[dep_kind] and next(rockspec[dep_kind]) then --! rockspec as {atring: any} 84 if (rockspec as {string: Dependencies})[dep_kind] and next((rockspec as {string: Dependencies})[dep_kind]) ~= nil then
78 local _, err, errcode = deps.fulfill_dependencies(rockspec, dep_kind, "all") 85 local _, err, errcode = deps.fulfill_dependencies(rockspec, dep_kind, "all")
79 if err then 86 if err then
80 return nil, err, errcode 87 return nil, err, errcode
@@ -82,7 +89,7 @@ function test.run_test_suite(rockspec_arg: string | Rockspec, test_type: string,
82 end 89 end
83 end 90 end
84 91
85 local pok, test_mod: boolean --! Test type 92 local pok, test_mod: boolean, TestRunner
86 if test_type == "command" then 93 if test_type == "command" then
87 pok, test_mod = pcall(require, "luarocks.test.command") 94 pok, test_mod = pcall(require, "luarocks.test.command")
88 if not pok then 95 if not pok then
diff --git a/src/luarocks/type/rockspec.lua b/src/luarocks/type/rockspec.lua
index bf43b154..caa99ec1 100644
--- a/src/luarocks/type/rockspec.lua
+++ b/src/luarocks/type/rockspec.lua
@@ -3,8 +3,13 @@ local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 th
3 3
4 4
5 5
6
7
8
9
10
11
6local type_check = require("luarocks.type_check") 12local type_check = require("luarocks.type_check")
7local util = require("luarocks.core.util")
8 13
9 14
10 15