feat(plugins): Given an optional plugin, conditionally discard deps (#947)

* deps_of_all_optional: First, refactor the code responsible for disabling unneeded deps to be more generic

* deps_of_all_optional: Second, also disable unneeded deps from plugins marked as all optional

* deps_of_all_optional: add tests proving unneeded optional deps are now also discarded

* deps_of_all_optional: forgot return type

---------

Co-authored-by: abeldekat <abel@nomail.com>
This commit is contained in:
abeldekat 2023-07-22 08:20:52 +00:00 committed by GitHub
parent af4d24b8d0
commit e7334d8db5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 65 additions and 24 deletions

View file

@ -273,6 +273,25 @@ describe("plugin spec opt", function()
end
end
end)
it("handles the optional keyword", function()
local tests = {
[{ { "foo/bax" }, { "foo/bar", optional = true, dependencies = "foo/dep1" } }] = false,
[{ { "foo/bax", dependencies = "foo/dep1" }, { "foo/bar", optional = true, dependencies = "foo/dep1" } }] = true,
}
for test, ret in pairs(tests) do
local spec = Plugin.Spec.new(test)
assert(#spec.notifs == 0)
assert(spec.plugins.bax)
assert(not spec.plugins.bar)
assert(#spec.disabled == 0)
if ret then
assert(spec.plugins.dep1)
else
assert(not spec.plugins.opt1)
end
end
end)
end)
describe("plugin opts", function()