aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorV1K1NGbg <victor@ilchev.com>2024-08-13 18:45:28 +0300
committerV1K1NGbg <victor@ilchev.com>2024-08-13 18:45:28 +0300
commit6bafc07e7f6e93ef9d1bcaa73d8f16d17b114e1b (patch)
treeae21b70d9687621bfb4d46a894f2644c6fbaddf7
parentd335afd351497ae5598eaa74c36d8b04cf69148b (diff)
downloadluarocks-6bafc07e7f6e93ef9d1bcaa73d8f16d17b114e1b.tar.gz
luarocks-6bafc07e7f6e93ef9d1bcaa73d8f16d17b114e1b.tar.bz2
luarocks-6bafc07e7f6e93ef9d1bcaa73d8f16d17b114e1b.zip
sanity check
-rw-r--r--src/luarocks/core/types/rockmanifest.d.tl2
-rw-r--r--src/luarocks/manif.lua4
-rw-r--r--src/luarocks/manif.tl4
-rw-r--r--src/luarocks/repos.tl4
-rw-r--r--src/luarocks/test-incomplete.lua (renamed from src/luarocks/test-original.lua)57
-rw-r--r--src/luarocks/test.lua57
6 files changed, 64 insertions, 64 deletions
diff --git a/src/luarocks/core/types/rockmanifest.d.tl b/src/luarocks/core/types/rockmanifest.d.tl
index dbcb0380..59fec9f1 100644
--- a/src/luarocks/core/types/rockmanifest.d.tl
+++ b/src/luarocks/core/types/rockmanifest.d.tl
@@ -1,7 +1,7 @@
1local record rockmanifest 1local record rockmanifest
2 record RockManifest 2 record RockManifest
3 type Entry = string | {string: Entry} 3 type Entry = string | {string: Entry}
4 entries: {string: Entry} 4 rock_manifest: {string: Entry}
5 end 5 end
6end 6end
7return rockmanifest \ No newline at end of file 7return rockmanifest \ No newline at end of file
diff --git a/src/luarocks/manif.lua b/src/luarocks/manif.lua
index 754ad985..437ebe3b 100644
--- a/src/luarocks/manif.lua
+++ b/src/luarocks/manif.lua
@@ -72,7 +72,7 @@ function manif.load_rock_manifest(name, version, root)
72 72
73 local name_version = name .. "/" .. version 73 local name_version = name .. "/" .. version
74 if manif.rock_manifest_cache[name_version] then 74 if manif.rock_manifest_cache[name_version] then
75 return manif.rock_manifest_cache[name_version].entries 75 return manif.rock_manifest_cache[name_version].rock_manifest
76 end 76 end
77 local pathname = path.rock_manifest_file(name, version, root) 77 local pathname = path.rock_manifest_file(name, version, root)
78 local rock_manifest = persist.load_into_table(pathname) 78 local rock_manifest = persist.load_into_table(pathname)
@@ -80,7 +80,7 @@ function manif.load_rock_manifest(name, version, root)
80 return nil, "rock_manifest file not found for " .. name .. " " .. version .. " - not a LuaRocks tree?" 80 return nil, "rock_manifest file not found for " .. name .. " " .. version .. " - not a LuaRocks tree?"
81 end 81 end
82 manif.rock_manifest_cache[name_version] = rock_manifest 82 manif.rock_manifest_cache[name_version] = rock_manifest
83 return rock_manifest.entries 83 return rock_manifest.rock_manifest
84end 84end
85 85
86 86
diff --git a/src/luarocks/manif.tl b/src/luarocks/manif.tl
index 3ce753e1..0a329fff 100644
--- a/src/luarocks/manif.tl
+++ b/src/luarocks/manif.tl
@@ -72,7 +72,7 @@ function manif.load_rock_manifest(name: string, version: string, root?: string |
72 72
73 local name_version = name.."/"..version 73 local name_version = name.."/"..version
74 if manif.rock_manifest_cache[name_version] then 74 if manif.rock_manifest_cache[name_version] then
75 return manif.rock_manifest_cache[name_version].entries 75 return manif.rock_manifest_cache[name_version].rock_manifest
76 end 76 end
77 local pathname = path.rock_manifest_file(name, version, root) 77 local pathname = path.rock_manifest_file(name, version, root)
78 local rock_manifest = persist.load_into_table(pathname) as RockManifest 78 local rock_manifest = persist.load_into_table(pathname) as RockManifest
@@ -80,7 +80,7 @@ function manif.load_rock_manifest(name: string, version: string, root?: string |
80 return nil, "rock_manifest file not found for "..name.." "..version.." - not a LuaRocks tree?" 80 return nil, "rock_manifest file not found for "..name.." "..version.." - not a LuaRocks tree?"
81 end 81 end
82 manif.rock_manifest_cache[name_version] = rock_manifest 82 manif.rock_manifest_cache[name_version] = rock_manifest
83 return rock_manifest.entries 83 return rock_manifest.rock_manifest
84end 84end
85 85
86--- Load a local or remote manifest describing a repository. 86--- Load a local or remote manifest describing a repository.
diff --git a/src/luarocks/repos.tl b/src/luarocks/repos.tl
index 5ce73831..b5e1efe8 100644
--- a/src/luarocks/repos.tl
+++ b/src/luarocks/repos.tl
@@ -450,8 +450,8 @@ function repos.deploy_local_files(name: string, version: string, wrap_bin_script
450 if not rock_manifest then return nil, load_err end 450 if not rock_manifest then return nil, load_err end
451 451
452 local repo = cfg.root_dir 452 local repo = cfg.root_dir
453 local renames = {} 453 local renames: {Op} = {}
454 local installs = {} 454 local installs: {Op} = {}
455 455
456 local function install_binary(source: string, target: string): boolean, string 456 local function install_binary(source: string, target: string): boolean, string
457 if wrap_bin_scripts and fs.is_lua(source) then 457 if wrap_bin_scripts and fs.is_lua(source) then
diff --git a/src/luarocks/test-original.lua b/src/luarocks/test-incomplete.lua
index d074b950..762b98b5 100644
--- a/src/luarocks/test-original.lua
+++ b/src/luarocks/test-incomplete.lua
@@ -1,10 +1,24 @@
1local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local assert = _tl_compat and _tl_compat.assert or assert; local ipairs = _tl_compat and _tl_compat.ipairs or ipairs; local pcall = _tl_compat and _tl_compat.pcall or pcall; local table = _tl_compat and _tl_compat.table or table; local test = {TestModules = {}, }
2
3
4
5
6
1 7
2local test = {}
3 8
4local fetch = require("luarocks.fetch") 9local fetch = require("luarocks.fetch")
5local deps = require("luarocks.deps") 10local deps = require("luarocks.deps")
6local util = require("luarocks.util") 11local util = require("luarocks.util")
7 12
13
14
15
16
17
18
19
20
21
8local test_types = { 22local test_types = {
9 "busted", 23 "busted",
10 "command", 24 "command",
@@ -13,10 +27,15 @@ local test_types = {
13local test_modules = {} 27local test_modules = {}
14 28
15for _, test_type in ipairs(test_types) do 29for _, test_type in ipairs(test_types) do
16 local mod = require("luarocks.test." .. test_type) 30 local mod
31 if test_type == "command" then
32 mod = require("luarocks.test.command")
33 elseif test_type == "busted" then
34 mod = require("luarocks.test.busted")
35 end
17 table.insert(test_modules, mod) 36 table.insert(test_modules, mod)
18 test_modules[test_type] = mod 37 test_modules.typetomod[test_type] = mod
19 test_modules[mod] = test_type 38 test_modules.modtotype[mod] = test_type
20end 39end
21 40
22local function get_test_type(rockspec) 41local function get_test_type(rockspec)
@@ -26,14 +45,14 @@ local function get_test_type(rockspec)
26 45
27 for _, test_module in ipairs(test_modules) do 46 for _, test_module in ipairs(test_modules) do
28 if test_module.detect_type() then 47 if test_module.detect_type() then
29 return test_modules[test_module] 48 return test_modules.modtotype[test_module]
30 end 49 end
31 end 50 end
32 51
33 return nil, "could not detect test type -- no test suite for " .. rockspec.package .. "?" 52 return nil, "could not detect test type -- no test suite for " .. rockspec.package .. "?"
34end 53end
35 54
36-- Run test suite as configured in rockspec in the current directory. 55
37function test.run_test_suite(rockspec_arg, test_type, args, prepare) 56function test.run_test_suite(rockspec_arg, test_type, args, prepare)
38 local rockspec 57 local rockspec
39 if type(rockspec_arg) == "string" then 58 if type(rockspec_arg) == "string" then
@@ -43,13 +62,12 @@ function test.run_test_suite(rockspec_arg, test_type, args, prepare)
43 return nil, err, errcode 62 return nil, err, errcode
44 end 63 end
45 else 64 else
46 assert(type(rockspec_arg) == "table")
47 rockspec = rockspec_arg 65 rockspec = rockspec_arg
48 end 66 end
49 67
50 if not test_type then 68 if not test_type then
51 local err 69 local err
52 test_type, err = get_test_type(rockspec, test_type) 70 test_type, err = get_test_type(rockspec)
53 if not test_type then 71 if not test_type then
54 return nil, err 72 return nil, err
55 end 73 end
@@ -62,23 +80,30 @@ function test.run_test_suite(rockspec_arg, test_type, args, prepare)
62 "test_dependencies", 80 "test_dependencies",
63 } 81 }
64 for _, dep_kind in ipairs(all_deps) do 82 for _, dep_kind in ipairs(all_deps) do
65 if rockspec[dep_kind] and next(rockspec[dep_kind]) then 83 if (rockspec)[dep_kind] and next((rockspec)[dep_kind]) ~= nil then
66 local ok, err, errcode = deps.fulfill_dependencies(rockspec, dep_kind, "all") 84 local _, err, errcode = deps.fulfill_dependencies(rockspec, dep_kind, "all")
67 if err then 85 if err then
68 return nil, err, errcode 86 return nil, err, errcode
69 end 87 end
70 end 88 end
71 end 89 end
72 90
73 local mod_name = "luarocks.test." .. test_type 91 local pok, test_mod
74 local pok, test_mod = pcall(require, mod_name) 92 if test_type == "command" then
75 if not pok then 93 pok, test_mod = pcall(require, "luarocks.test.command")
76 return nil, "failed loading test execution module " .. mod_name 94 if not pok then
95 return nil, "failed loading test execution module luarocks.test.command"
96 end
97 elseif test_type == "busted" then
98 pok, test_mod = pcall(require, "luarocks.test.busted")
99 if not pok then
100 return nil, "failed loading test execution module luarocks.test.busted"
101 end
77 end 102 end
78 103
79 if prepare then 104 if prepare then
80 if test_type == "busted" then 105 if test_type == "busted" then
81 return test_mod.run_tests(rockspec_arg, {"--version"}) 106 return test_mod.run_tests(rockspec.test, { "--version" })
82 else 107 else
83 return true 108 return true
84 end 109 end
@@ -87,7 +112,7 @@ function test.run_test_suite(rockspec_arg, test_type, args, prepare)
87 if type(flags) == "table" then 112 if type(flags) == "table" then
88 util.variable_substitutions(flags, rockspec.variables) 113 util.variable_substitutions(flags, rockspec.variables)
89 114
90 -- insert any flags given in test.flags at the front of args 115
91 for i = 1, #flags do 116 for i = 1, #flags do
92 table.insert(args, i, flags[i]) 117 table.insert(args, i, flags[i])
93 end 118 end
diff --git a/src/luarocks/test.lua b/src/luarocks/test.lua
index 762b98b5..d074b950 100644
--- a/src/luarocks/test.lua
+++ b/src/luarocks/test.lua
@@ -1,24 +1,10 @@
1local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local assert = _tl_compat and _tl_compat.assert or assert; local ipairs = _tl_compat and _tl_compat.ipairs or ipairs; local pcall = _tl_compat and _tl_compat.pcall or pcall; local table = _tl_compat and _tl_compat.table or table; local test = {TestModules = {}, }
2
3
4
5
6
7 1
2local test = {}
8 3
9local fetch = require("luarocks.fetch") 4local fetch = require("luarocks.fetch")
10local deps = require("luarocks.deps") 5local deps = require("luarocks.deps")
11local util = require("luarocks.util") 6local util = require("luarocks.util")
12 7
13
14
15
16
17
18
19
20
21
22local test_types = { 8local test_types = {
23 "busted", 9 "busted",
24 "command", 10 "command",
@@ -27,15 +13,10 @@ local test_types = {
27local test_modules = {} 13local test_modules = {}
28 14
29for _, test_type in ipairs(test_types) do 15for _, test_type in ipairs(test_types) do
30 local mod 16 local mod = require("luarocks.test." .. test_type)
31 if test_type == "command" then
32 mod = require("luarocks.test.command")
33 elseif test_type == "busted" then
34 mod = require("luarocks.test.busted")
35 end
36 table.insert(test_modules, mod) 17 table.insert(test_modules, mod)
37 test_modules.typetomod[test_type] = mod 18 test_modules[test_type] = mod
38 test_modules.modtotype[mod] = test_type 19 test_modules[mod] = test_type
39end 20end
40 21
41local function get_test_type(rockspec) 22local function get_test_type(rockspec)
@@ -45,14 +26,14 @@ local function get_test_type(rockspec)
45 26
46 for _, test_module in ipairs(test_modules) do 27 for _, test_module in ipairs(test_modules) do
47 if test_module.detect_type() then 28 if test_module.detect_type() then
48 return test_modules.modtotype[test_module] 29 return test_modules[test_module]
49 end 30 end
50 end 31 end
51 32
52 return nil, "could not detect test type -- no test suite for " .. rockspec.package .. "?" 33 return nil, "could not detect test type -- no test suite for " .. rockspec.package .. "?"
53end 34end
54 35
55 36-- Run test suite as configured in rockspec in the current directory.
56function test.run_test_suite(rockspec_arg, test_type, args, prepare) 37function test.run_test_suite(rockspec_arg, test_type, args, prepare)
57 local rockspec 38 local rockspec
58 if type(rockspec_arg) == "string" then 39 if type(rockspec_arg) == "string" then
@@ -62,12 +43,13 @@ function test.run_test_suite(rockspec_arg, test_type, args, prepare)
62 return nil, err, errcode 43 return nil, err, errcode
63 end 44 end
64 else 45 else
46 assert(type(rockspec_arg) == "table")
65 rockspec = rockspec_arg 47 rockspec = rockspec_arg
66 end 48 end
67 49
68 if not test_type then 50 if not test_type then
69 local err 51 local err
70 test_type, err = get_test_type(rockspec) 52 test_type, err = get_test_type(rockspec, test_type)
71 if not test_type then 53 if not test_type then
72 return nil, err 54 return nil, err
73 end 55 end
@@ -80,30 +62,23 @@ function test.run_test_suite(rockspec_arg, test_type, args, prepare)
80 "test_dependencies", 62 "test_dependencies",
81 } 63 }
82 for _, dep_kind in ipairs(all_deps) do 64 for _, dep_kind in ipairs(all_deps) do
83 if (rockspec)[dep_kind] and next((rockspec)[dep_kind]) ~= nil then 65 if rockspec[dep_kind] and next(rockspec[dep_kind]) then
84 local _, err, errcode = deps.fulfill_dependencies(rockspec, dep_kind, "all") 66 local ok, err, errcode = deps.fulfill_dependencies(rockspec, dep_kind, "all")
85 if err then 67 if err then
86 return nil, err, errcode 68 return nil, err, errcode
87 end 69 end
88 end 70 end
89 end 71 end
90 72
91 local pok, test_mod 73 local mod_name = "luarocks.test." .. test_type
92 if test_type == "command" then 74 local pok, test_mod = pcall(require, mod_name)
93 pok, test_mod = pcall(require, "luarocks.test.command") 75 if not pok then
94 if not pok then 76 return nil, "failed loading test execution module " .. mod_name
95 return nil, "failed loading test execution module luarocks.test.command"
96 end
97 elseif test_type == "busted" then
98 pok, test_mod = pcall(require, "luarocks.test.busted")
99 if not pok then
100 return nil, "failed loading test execution module luarocks.test.busted"
101 end
102 end 77 end
103 78
104 if prepare then 79 if prepare then
105 if test_type == "busted" then 80 if test_type == "busted" then
106 return test_mod.run_tests(rockspec.test, { "--version" }) 81 return test_mod.run_tests(rockspec_arg, {"--version"})
107 else 82 else
108 return true 83 return true
109 end 84 end
@@ -112,7 +87,7 @@ function test.run_test_suite(rockspec_arg, test_type, args, prepare)
112 if type(flags) == "table" then 87 if type(flags) == "table" then
113 util.variable_substitutions(flags, rockspec.variables) 88 util.variable_substitutions(flags, rockspec.variables)
114 89
115 90 -- insert any flags given in test.flags at the front of args
116 for i = 1, #flags do 91 for i = 1, #flags do
117 table.insert(args, i, flags[i]) 92 table.insert(args, i, flags[i])
118 end 93 end