summaryrefslogtreecommitdiff
path: root/tests/projects/c++/modules
diff options
context:
space:
mode:
authorruki <[email protected]>2025-11-06 09:20:52 +0800
committerGitHub <[email protected]>2025-11-06 09:20:52 +0800
commit169c7ddce5a07c82b5aa60fbc6fcb37e4593fb7d (patch)
tree2f2b90ec77ff0cf6093f2e534e69d9e9eda116dc /tests/projects/c++/modules
parentc5d08dcde1187fbf3903d51d63af8e15e28650c1 (diff)
parentce723897432dad8d8f94ddf831e3a8d7db6e2700 (diff)
Merge pull request #6993 from Arthapz/fix-xmake_tests_modules
Fix xmake tests modules
Diffstat (limited to 'tests/projects/c++/modules')
-rw-r--r--tests/projects/c++/modules/test_dependency_scanner.lua2
-rw-r--r--tests/projects/c++/modules/test_xmake_test.lua22
-rw-r--r--tests/projects/c++/modules/xmake_tests1/src/foo.cppm3
-rw-r--r--tests/projects/c++/modules/xmake_tests1/src/main.cpp3
-rw-r--r--tests/projects/c++/modules/xmake_tests1/test.lua1
-rw-r--r--tests/projects/c++/modules/xmake_tests1/xmake.lua15
-rw-r--r--tests/projects/c++/modules/xmake_tests2/src/foo.cppm3
-rw-r--r--tests/projects/c++/modules/xmake_tests2/src/main.cpp3
-rw-r--r--tests/projects/c++/modules/xmake_tests2/test.lua1
-rw-r--r--tests/projects/c++/modules/xmake_tests2/xmake.lua21
10 files changed, 73 insertions, 1 deletions
diff --git a/tests/projects/c++/modules/test_dependency_scanner.lua b/tests/projects/c++/modules/test_dependency_scanner.lua
index 406ac76f4..450a53084 100644
--- a/tests/projects/c++/modules/test_dependency_scanner.lua
+++ b/tests/projects/c++/modules/test_dependency_scanner.lua
@@ -8,7 +8,7 @@ MSVC_MIN_VER = "14.29"
function _build(platform, toolchain_name, runtimes, policies, flags)
local flags = ""
if ci_is_running() then
- flags = "-vD"
+ flags = "-vD"
end
os.exec("xmake f" .. platform .. "--toolchain=" .. toolchain_name .. runtimes .. "-c --yes " .. policies .. " --foo=n" .. " " .. flags)
local outdata
diff --git a/tests/projects/c++/modules/test_xmake_test.lua b/tests/projects/c++/modules/test_xmake_test.lua
new file mode 100644
index 000000000..2d0b0a2d1
--- /dev/null
+++ b/tests/projects/c++/modules/test_xmake_test.lua
@@ -0,0 +1,22 @@
+inherit("test_base")
+import("utils.ci.is_running", {alias = "ci_is_running"})
+
+CLANG_MIN_VER = is_subhost("windows") and "19" or "17"
+GCC_MIN_VER = "11"
+MSVC_MIN_VER = "14.29"
+
+function run_xmake_test(...)
+ local flags = ""
+ if ci_is_running() then
+ flags = "-vD"
+ end
+ local outdata, errdata = os.iorun("xmake test " .. flags)
+ assert(outdata, errdata)
+end
+
+function main(t)
+ local clang_options = {compiler = "clang", version = CLANG_MIN_VER, after_build = run_xmake_test}
+ local gcc_options = {compiler = "gcc", version = GCC_MIN_VER, after_build = run_xmake_test}
+ local msvc_options = {version = MSVC_MIN_VER, after_build = run_xmake_test}
+ run_tests(clang_options, gcc_options, msvc_options)
+end
diff --git a/tests/projects/c++/modules/xmake_tests1/src/foo.cppm b/tests/projects/c++/modules/xmake_tests1/src/foo.cppm
new file mode 100644
index 000000000..d0cb72703
--- /dev/null
+++ b/tests/projects/c++/modules/xmake_tests1/src/foo.cppm
@@ -0,0 +1,3 @@
+export module Foo;
+
+export inline int foo() { return 0; }
diff --git a/tests/projects/c++/modules/xmake_tests1/src/main.cpp b/tests/projects/c++/modules/xmake_tests1/src/main.cpp
new file mode 100644
index 000000000..7a7488a3b
--- /dev/null
+++ b/tests/projects/c++/modules/xmake_tests1/src/main.cpp
@@ -0,0 +1,3 @@
+import Foo;
+
+int main() { return foo(); }
diff --git a/tests/projects/c++/modules/xmake_tests1/test.lua b/tests/projects/c++/modules/xmake_tests1/test.lua
new file mode 100644
index 000000000..25ca8a7a3
--- /dev/null
+++ b/tests/projects/c++/modules/xmake_tests1/test.lua
@@ -0,0 +1 @@
+inherit(".test_xmake_test")
diff --git a/tests/projects/c++/modules/xmake_tests1/xmake.lua b/tests/projects/c++/modules/xmake_tests1/xmake.lua
new file mode 100644
index 000000000..64198ec69
--- /dev/null
+++ b/tests/projects/c++/modules/xmake_tests1/xmake.lua
@@ -0,0 +1,15 @@
+add_rules('mode.debug', 'mode.release')
+ set_languages('c++23')
+ set_policy('build.c++.modules.std', false)
+
+target('module_dep')
+ set_kind('moduleonly')
+ add_files('src/*.cppm')
+
+target('module_target')
+ set_kind('moduleonly')
+ add_files('src/*.cppm')
+
+add_deps('module_dep')
+ add_tests('test', { kind = 'binary', files = 'src/main.cpp', build_should_pass = true })
+ add_tests('test2', { kind = 'binary', files = 'src/main.cpp', build_should_pass = true })
diff --git a/tests/projects/c++/modules/xmake_tests2/src/foo.cppm b/tests/projects/c++/modules/xmake_tests2/src/foo.cppm
new file mode 100644
index 000000000..d0cb72703
--- /dev/null
+++ b/tests/projects/c++/modules/xmake_tests2/src/foo.cppm
@@ -0,0 +1,3 @@
+export module Foo;
+
+export inline int foo() { return 0; }
diff --git a/tests/projects/c++/modules/xmake_tests2/src/main.cpp b/tests/projects/c++/modules/xmake_tests2/src/main.cpp
new file mode 100644
index 000000000..7a7488a3b
--- /dev/null
+++ b/tests/projects/c++/modules/xmake_tests2/src/main.cpp
@@ -0,0 +1,3 @@
+import Foo;
+
+int main() { return foo(); }
diff --git a/tests/projects/c++/modules/xmake_tests2/test.lua b/tests/projects/c++/modules/xmake_tests2/test.lua
new file mode 100644
index 000000000..25ca8a7a3
--- /dev/null
+++ b/tests/projects/c++/modules/xmake_tests2/test.lua
@@ -0,0 +1 @@
+inherit(".test_xmake_test")
diff --git a/tests/projects/c++/modules/xmake_tests2/xmake.lua b/tests/projects/c++/modules/xmake_tests2/xmake.lua
new file mode 100644
index 000000000..e5326b36d
--- /dev/null
+++ b/tests/projects/c++/modules/xmake_tests2/xmake.lua
@@ -0,0 +1,21 @@
+add_rules("mode.debug", "mode.release")
+set_languages("c++23")
+set_policy("build.c++.modules.std", false)
+
+target("module_dep")
+ set_kind("moduleonly")
+ add_files("src/*.cppm")
+
+target("module_target1")
+ set_kind("moduleonly")
+ add_files("src/*.cppm")
+
+ add_deps("module_dep")
+ add_tests("tests", {kind = "binary", files = "src/main.cpp", build_should_pass = true})
+
+target("module_target2")
+ set_kind("moduleonly")
+ add_files("src/*.cppm")
+
+ add_deps("module_dep")
+ add_tests("tests", {kind = "binary", files = "src/main.cpp", build_should_pass = true})