summaryrefslogtreecommitdiff
path: root/tests/projects/c++/modules
diff options
context:
space:
mode:
Diffstat (limited to 'tests/projects/c++/modules')
-rw-r--r--tests/projects/c++/modules/duplicate_name_detection/src/bar.mpp (renamed from tests/projects/c++/modules/link_order/src/bar.mpp)2
-rw-r--r--tests/projects/c++/modules/duplicate_name_detection/src/foo.mpp (renamed from tests/projects/c++/modules/link_order/src/foo.mpp)2
-rw-r--r--tests/projects/c++/modules/duplicate_name_detection/src/main.cpp (renamed from tests/projects/c++/modules/link_order/src/main.cpp)2
-rw-r--r--tests/projects/c++/modules/duplicate_name_detection/test.lua70
-rw-r--r--tests/projects/c++/modules/duplicate_name_detection/xmake.lua (renamed from tests/projects/c++/modules/link_order/xmake.lua)4
-rw-r--r--tests/projects/c++/modules/link_order/test.lua1
6 files changed, 75 insertions, 6 deletions
diff --git a/tests/projects/c++/modules/link_order/src/bar.mpp b/tests/projects/c++/modules/duplicate_name_detection/src/bar.mpp
index dc7c14ec8..a51969b8f 100644
--- a/tests/projects/c++/modules/link_order/src/bar.mpp
+++ b/tests/projects/c++/modules/duplicate_name_detection/src/bar.mpp
@@ -1,4 +1,4 @@
-export module duplicate;
+export module foo;
export int value() {
return 1;
diff --git a/tests/projects/c++/modules/link_order/src/foo.mpp b/tests/projects/c++/modules/duplicate_name_detection/src/foo.mpp
index eba3a4223..d97e5f085 100644
--- a/tests/projects/c++/modules/link_order/src/foo.mpp
+++ b/tests/projects/c++/modules/duplicate_name_detection/src/foo.mpp
@@ -1,4 +1,4 @@
-export module duplicate;
+export module foo;
export int value() {
return 0;
diff --git a/tests/projects/c++/modules/link_order/src/main.cpp b/tests/projects/c++/modules/duplicate_name_detection/src/main.cpp
index cd9524d8b..50ddf1fdd 100644
--- a/tests/projects/c++/modules/link_order/src/main.cpp
+++ b/tests/projects/c++/modules/duplicate_name_detection/src/main.cpp
@@ -1,4 +1,4 @@
-import duplicate;
+import foo;
int main() {
return value();
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
diff --git a/tests/projects/c++/modules/link_order/xmake.lua b/tests/projects/c++/modules/duplicate_name_detection/xmake.lua
index 4cb2af87f..f4539695c 100644
--- a/tests/projects/c++/modules/link_order/xmake.lua
+++ b/tests/projects/c++/modules/duplicate_name_detection/xmake.lua
@@ -9,12 +9,12 @@ target("bar")
set_kind("moduleonly")
add_files("src/bar.mpp")
-target("link_order_1")
+target("duplicate_name_detection_1")
set_kind("binary")
add_deps("foo", "bar")
add_files("src/main.cpp")
-target("link_order_2")
+target("duplicate_name_detection_2")
set_kind("binary")
add_deps("bar", "foo")
add_files("src/main.cpp")
diff --git a/tests/projects/c++/modules/link_order/test.lua b/tests/projects/c++/modules/link_order/test.lua
deleted file mode 100644
index 7717f8049..000000000
--- a/tests/projects/c++/modules/link_order/test.lua
+++ /dev/null
@@ -1 +0,0 @@
-inherit(".test_base")