diff options
Diffstat (limited to 'tests/actions/addon/test.lua')
| -rw-r--r-- | tests/actions/addon/test.lua | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/tests/actions/addon/test.lua b/tests/actions/addon/test.lua index 01030c4b8..fcc5c2efc 100644 --- a/tests/actions/addon/test.lua +++ b/tests/actions/addon/test.lua @@ -305,7 +305,7 @@ int main(int argc, char** argv) { return 0; } end) end --- the addons which a project declares in `xmake-addons.lua` are installed automatically +-- the addons which a project declares with `add_addons` are installed automatically -- -- @note they must be installed before loading the project, it may use their includes files function test_autofetch(t) @@ -345,7 +345,7 @@ function test_autofetch_skipped_for_option_menu(t) end) end --- a complete project which declares its addons in `xmake-addons.lua` and builds with them, +-- a complete project which declares its addons with `add_addons` and builds with them, -- @see tests/actions/addon/projects/autofetch-build function test_autofetch_build(t) @@ -396,13 +396,11 @@ function test_autofetch_lock_missing_version(t) end) end --- the addons file only declares the addons, it cannot reference them +-- the declared addons are checked, e.g. the reserved names function test_autofetch_invalid(t) - for _, name in ipairs({"autofetch-badinclude", "autofetch-badname"}) do - _with_project(name, function () - t:require_not(try { function () os.runv("xmake", {"config", "-y"}); return true end }) - end) - end + _with_project("autofetch-badname", function () + t:require_not(try { function () os.runv("xmake", {"config", "-y"}); return true end }) + end) end -- the addons can be installed from a repository, by plain name and by repo@name @@ -469,6 +467,26 @@ function test_install_conflicts(t) end) end +-- an addon is able to take over a builtin plugin, so we can move a deprecated builtin +-- plugin to an addon, e.g. `xmake format` +function test_install_override(t) + + -- the builtin plugin is used if we do not install the addon + t:require_not(os.iorunv("xmake", {"format", "--help"}):find("Say hello instead of formatting", 1, true)) + + _with_addons({"custom-override"}, function () + local out = os.iorunv("xmake", {"format"}) + t:require(out:find("hello from custom-override", 1, true)) + + -- and it should not be reported as a conflict + t:require_not(out:find("conflicts", 1, true)) + t:require(os.iorunv("xmake", {"format", "--help"}):find("Say hello instead of formatting", 1, true)) + end) + + -- the builtin plugin is used again after removing the addon + t:require_not(os.iorunv("xmake", {"format", "--help"}):find("Say hello instead of formatting", 1, true)) +end + -- the invalid installs should fail, and the `addon` name is reserved for the addon references function test_invalid(t) t:require_not(try { function () os.runv("xmake", {"addon", "--install", "-y", "addon-test-missing"}); return true end }) |
