From df5cb9cce6cbb757c12f07677edf27b4be219f48 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 23 Jul 2024 23:25:48 +0200 Subject: prompt an error when multiple module with the same names are detected --- .../c++/modules/duplicate_name_detection/test.lua | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 tests/projects/c++/modules/duplicate_name_detection/test.lua (limited to 'tests/projects/c++/modules/duplicate_name_detection/test.lua') diff --git a/tests/projects/c++/modules/duplicate_name_detection/test.lua b/tests/projects/c++/modules/duplicate_name_detection/test.lua new file mode 100644 index 000000000..5215735b5 --- /dev/null +++ b/tests/projects/c++/modules/duplicate_name_detection/test.lua @@ -0,0 +1,70 @@ +import("lib.detect.find_tool") +import("core.base.semver") +import("utils.ci.is_running", {alias = "ci_is_running"}) + +function _build() + try {function() + if ci_is_running() then + os.iorun("xmake -rvD") + else + os.iorun("xmake -r") + end + end, catch {function(errors) + errors = errors.errors + if not errors or not errors:find("detected") then + raise("Modules duplicate name detection does not work\n%s", errors.errors) + end + end}} +end + +function can_build() + if is_subhost("windows") then + return true + elseif is_subhost("msys") then + return true + elseif is_host("linux") then + local gcc = find_tool("gcc", {version = true}) + if gcc and gcc.version and semver.compare(gcc.version, "11.0") >= 0 then + return true + end + local clang = find_tool("clang", {version = true}) + if clang and clang.version and semver.compare(clang.version, "14.0") >= 0 then + return true + end + end +end + +function main(t) + if is_subhost("windows") then + local clang = find_tool("clang", {version = true}) + if clang and clang.version and semver.compare(clang.version, "17.0") >= 0 then + os.exec("xmake f --toolchain=clang -c --yes") + _build() + os.exec("xmake clean -a") + os.exec("xmake f --toolchain=clang --runtimes=c++_shared -c --yes") + _build() + end + + os.exec("xmake clean -a") + os.exec("xmake f -c --yes") + _build() + elseif is_subhost("msys") then + os.exec("xmake f -c -p mingw --yes") + _build() + elseif is_host("linux") then + local gcc = find_tool("gcc", {version = true}) +if gcc and gcc.version and semver.compare(gcc.version, "11.0") >= 0 then + os.exec("xmake f -c --yes") + _build() + end + local clang = find_tool("clang", {version = true}) + if clang and clang.version and semver.compare(clang.version, "14.0") >= 0 then + os.exec("xmake clean -a") + os.exec("xmake f --toolchain=clang -c --yes") + _build() + os.exec("xmake clean -a") + os.exec("xmake f --toolchain=clang --runtimes=c++_shared -c --yes") + _build() + end + end +end -- cgit v1.3.1 From dcd0c80fbde856820ed204d2b04fd51b3aa8ffae Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 24 Jul 2024 23:37:54 +0800 Subject: Update test.lua --- .../c++/modules/duplicate_name_detection/test.lua | 29 +++++++++++++--------- 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'tests/projects/c++/modules/duplicate_name_detection/test.lua') diff --git a/tests/projects/c++/modules/duplicate_name_detection/test.lua b/tests/projects/c++/modules/duplicate_name_detection/test.lua index 5215735b5..34a153037 100644 --- a/tests/projects/c++/modules/duplicate_name_detection/test.lua +++ b/tests/projects/c++/modules/duplicate_name_detection/test.lua @@ -3,18 +3,23 @@ import("core.base.semver") import("utils.ci.is_running", {alias = "ci_is_running"}) function _build() - try {function() - if ci_is_running() then - os.iorun("xmake -rvD") - else - os.iorun("xmake -r") - end - end, catch {function(errors) - errors = errors.errors - if not errors or not errors:find("detected") then - raise("Modules duplicate name detection does not work\n%s", errors.errors) - end - end}} + try { + function() + if ci_is_running() then + os.iorun("xmake -rvD") + else + os.iorun("xmake -r") + end + end, + catch { + function (errors) + errors = tostring(errors) + if not errors:find("duplicate module name detected", 1, true) then + raise("Modules duplicate name detection does not work\n%s", errors) + end + end + } + } end function can_build() -- cgit v1.3.1 From 626b80e46c371a2723f204e2412339e73d6cbece Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 24 Jul 2024 23:48:27 +0800 Subject: Update test.lua --- tests/projects/c++/modules/duplicate_name_detection/test.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/projects/c++/modules/duplicate_name_detection/test.lua') diff --git a/tests/projects/c++/modules/duplicate_name_detection/test.lua b/tests/projects/c++/modules/duplicate_name_detection/test.lua index 34a153037..53033dd7f 100644 --- a/tests/projects/c++/modules/duplicate_name_detection/test.lua +++ b/tests/projects/c++/modules/duplicate_name_detection/test.lua @@ -6,9 +6,9 @@ function _build() try { function() if ci_is_running() then - os.iorun("xmake -rvD") + os.run("xmake -rvD") else - os.iorun("xmake -r") + os.run("xmake -r") end end, catch { -- cgit v1.3.1