Verified Commit aba9eeae authored by Karel Koci's avatar Karel Koci 🤘

Dependency calculations with all candidates

Adds support for candidates. Currently it can be limited only by
version. Limiting by repository isn't supported yet.
parent 054cbeb4
......@@ -24,6 +24,7 @@ local error = error
local type = type
local setmetatable = setmetatable
local getmetatable = getmetatable
local assert = assert
local io = io
local unpack = unpack
local events_wait = events_wait
......@@ -159,12 +160,15 @@ local error_meta = {
}
-- Generate an exception/error object. It can be further modified, of course.
function exception(reason, msg)
return setmetatable({
function exception(reason, msg, extra)
local except = {
tp = "error",
reason = reason,
msg = msg
}, error_meta)
}
assert(not(extra and (extra.tp or extra.reason or extra.msg)))
table_merge(except, extra or {})
return setmetatable(except, error_meta)
end
--[[
......
......@@ -340,10 +340,9 @@ function pkg_aggregate()
-- Canonize dependencies
modifier.deps = deps_canon(modifier.deps)
for _, candidate in ipairs(pkg_group.candidates or {}) do
candidate.deps = deps_canon(candidate.deps) or {} -- deps from updater configuration file
for _, d in ipairs(candidate.Depends or {}) do -- Depends from repository
table.insert(candidate.deps, deps_canon(d))
end
local candidate_deps = { candidate.deps } -- deps from updater configuration file
table.insert(candidate_deps, candidate.Depends) -- Depends from repository)
candidate.deps = deps_canon(candidate_deps)
end
pkg_group.modifier = modifier
-- We merged them together, they are no longer needed separately
......
This diff is collapsed.
......@@ -50,7 +50,7 @@ function assert_table_equal(t1, t2, tables, checked)
end
end
function assert_exception(func, reason, msg)
function assert_exception(func, reason, msg, extra)
local ok, err = pcall(func)
lunit.assert_false(ok, "It hasn't failed")
local dumped, result = pcall(DataDumper, err)
......@@ -62,6 +62,13 @@ function assert_exception(func, reason, msg)
if msg then
lunit.assert_equal(msg, err.msg, "Failed with a wrong message " .. (err.msg or msg))
end
if extra then
local eerr = utils.shallow_copy(extra)
eerr.tp = 'error'
eerr.reason = err.reason
eerr.msg = err.msg
assert_table_equal(eerr, err)
end
end
mocks_called = {}
......
This diff is collapsed.
......@@ -247,13 +247,13 @@ function test_pkg_merge()
local exp = {
abc = {
candidates = {
{Package = "abc", Version = "2", deps = {}, repo = requests.known_repositories_all[1]},
{Package = "abc", Version = "1", deps = {}, repo = requests.known_repositories_all[2]}
{Package = "abc", Version = "2", repo = requests.known_repositories_all[1]},
{Package = "abc", Version = "1", repo = requests.known_repositories_all[2]}
},
modifier = {name = "abc"}
},
another = {
candidates = {{Package = "another", Version = "4", deps = {}, repo = requests.known_repositories_all[2]}},
candidates = {{Package = "another", Version = "4", repo = requests.known_repositories_all[2]}},
modifier = {name = "another"}
},
virt = {
......@@ -262,7 +262,7 @@ function test_pkg_merge()
virtual = true
},
xyz = {
candidates = {{Package = "xyz", Version = "1", deps = {}, repo = requests.known_repositories_all[1]}},
candidates = {{Package = "xyz", Version = "1", repo = requests.known_repositories_all[1]}},
modifier = {
name = "xyz",
order_after = {abc = true},
......
......@@ -112,6 +112,13 @@ function test_exception()
msg = "Error message"
}, e)
assert_equal("Error message", tostring(e))
local e = U.exception("reason", "msg", { extra = true })
assert_table_equal({
tp = "error",
reason = "reason",
msg = "msg",
extra = true
}, e)
end
function test_multi_index()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment