diff options
Diffstat (limited to 'tests')
14 files changed, 48 insertions, 18 deletions
diff --git a/tests/actions/addon/custom-override/addon.lua b/tests/actions/addon/custom-override/addon.lua new file mode 100644 index 000000000..3540b51f5 --- /dev/null +++ b/tests/actions/addon/custom-override/addon.lua @@ -0,0 +1,2 @@ +addon("custom-override") + set_description("the addon which takes over a builtin plugin") diff --git a/tests/actions/addon/custom-override/plugins/format/main.lua b/tests/actions/addon/custom-override/plugins/format/main.lua new file mode 100644 index 000000000..92f9b73b8 --- /dev/null +++ b/tests/actions/addon/custom-override/plugins/format/main.lua @@ -0,0 +1,3 @@ +function main() + print("hello from custom-override") +end diff --git a/tests/actions/addon/custom-override/plugins/format/xmake.lua b/tests/actions/addon/custom-override/plugins/format/xmake.lua new file mode 100644 index 000000000..446e24db1 --- /dev/null +++ b/tests/actions/addon/custom-override/plugins/format/xmake.lua @@ -0,0 +1,6 @@ +-- @note `format` is a builtin plugin of xmake, we use it to test that an addon +-- is able to take over a builtin plugin +task("format") + set_category("plugin") + set_menu {usage = "xmake format", description = "Say hello instead of formatting.", options = {}} + on_run("main") diff --git a/tests/actions/addon/projects/autofetch-badinclude/xmake-addons.lua b/tests/actions/addon/projects/autofetch-badinclude/xmake-addons.lua deleted file mode 100644 index 6931855ae..000000000 --- a/tests/actions/addon/projects/autofetch-badinclude/xmake-addons.lua +++ /dev/null @@ -1,2 +0,0 @@ --- this file only declares the addons, it cannot reference them -includes("@addon/custom-include/check") diff --git a/tests/actions/addon/projects/autofetch-badinclude/xmake.lua b/tests/actions/addon/projects/autofetch-badinclude/xmake.lua deleted file mode 100644 index 0d94cf61c..000000000 --- a/tests/actions/addon/projects/autofetch-badinclude/xmake.lua +++ /dev/null @@ -1,2 +0,0 @@ -target("test") - set_kind("phony") diff --git a/tests/actions/addon/projects/autofetch-badname/xmake-addons.lua b/tests/actions/addon/projects/autofetch-badname/xmake-addons.lua deleted file mode 100644 index 165325fb7..000000000 --- a/tests/actions/addon/projects/autofetch-badname/xmake-addons.lua +++ /dev/null @@ -1,2 +0,0 @@ --- the `addon` name is reserved for the addon references -add_addons("addon") diff --git a/tests/actions/addon/projects/autofetch-badname/xmake.lua b/tests/actions/addon/projects/autofetch-badname/xmake.lua index 0d94cf61c..ffbf6cbe4 100644 --- a/tests/actions/addon/projects/autofetch-badname/xmake.lua +++ b/tests/actions/addon/projects/autofetch-badname/xmake.lua @@ -1,2 +1,5 @@ +-- the `addon` name is reserved for the addon references +add_addons("addon") + target("test") set_kind("phony") diff --git a/tests/actions/addon/projects/autofetch-build/xmake-addons.lua b/tests/actions/addon/projects/autofetch-build/xmake-addons.lua deleted file mode 100644 index 2091e3b7f..000000000 --- a/tests/actions/addon/projects/autofetch-build/xmake-addons.lua +++ /dev/null @@ -1,2 +0,0 @@ --- the addons which this project needs, they are installed automatically when we load it -add_addons("custom-include", "custom-rule", "custom-toolchain") diff --git a/tests/actions/addon/projects/autofetch-build/xmake.lua b/tests/actions/addon/projects/autofetch-build/xmake.lua index bad3f8928..862ddf676 100644 --- a/tests/actions/addon/projects/autofetch-build/xmake.lua +++ b/tests/actions/addon/projects/autofetch-build/xmake.lua @@ -1,3 +1,6 @@ +-- the addons which this project needs, they are installed automatically +add_addons("custom-include", "custom-rule", "custom-toolchain") + -- the option comes from the includes file of an addon includes("@addon/custom-include/check") diff --git a/tests/actions/addon/projects/autofetch-lockmiss/xmake-addons.lua b/tests/actions/addon/projects/autofetch-lockmiss/xmake-addons.lua deleted file mode 100644 index a85e0fe11..000000000 --- a/tests/actions/addon/projects/autofetch-lockmiss/xmake-addons.lua +++ /dev/null @@ -1 +0,0 @@ -add_addons("custom-include") diff --git a/tests/actions/addon/projects/autofetch-lockmiss/xmake.lua b/tests/actions/addon/projects/autofetch-lockmiss/xmake.lua index 0d94cf61c..a96a4e713 100644 --- a/tests/actions/addon/projects/autofetch-lockmiss/xmake.lua +++ b/tests/actions/addon/projects/autofetch-lockmiss/xmake.lua @@ -1,2 +1,4 @@ +add_addons("custom-include") + target("test") set_kind("phony") diff --git a/tests/actions/addon/projects/autofetch/xmake-addons.lua b/tests/actions/addon/projects/autofetch/xmake-addons.lua deleted file mode 100644 index a85e0fe11..000000000 --- a/tests/actions/addon/projects/autofetch/xmake-addons.lua +++ /dev/null @@ -1 +0,0 @@ -add_addons("custom-include") diff --git a/tests/actions/addon/projects/autofetch/xmake.lua b/tests/actions/addon/projects/autofetch/xmake.lua index 4eaca0785..75c909904 100644 --- a/tests/actions/addon/projects/autofetch/xmake.lua +++ b/tests/actions/addon/projects/autofetch/xmake.lua @@ -1,3 +1,6 @@ +-- the addons which this project needs, they are installed automatically +add_addons("custom-include") + -- the addon is installed automatically, so we can use its includes file here includes("@addon/custom-include/check") 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 }) |
