From e20c6cafdb241ad6f858556c33463da1a092abdc Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 23 Jan 2024 18:22:52 +0100 Subject: improve module tests --- tests/projects/c++/modules/test_headerunits.lua | 35 +++++++++++++++++++------ 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'tests/projects/c++/modules/test_headerunits.lua') diff --git a/tests/projects/c++/modules/test_headerunits.lua b/tests/projects/c++/modules/test_headerunits.lua index 3b664c96c..0ece0992d 100644 --- a/tests/projects/c++/modules/test_headerunits.lua +++ b/tests/projects/c++/modules/test_headerunits.lua @@ -13,15 +13,33 @@ 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, "15.0") >= 0 then + -- clang headerunit are bugged + -- os.exec("xmake f --toolchain=clang --policies=build.c++.clang.fallbackscanner -c --yes") + -- _build() + -- if semver.compare(clang.version, "17.0") >= 0 then + -- os.exec("xmake clean -a") + -- -- clang-scan-deps dependency detection doesn't support header units atm + -- os.exec("xmake f --toolchain=clang --policies=build.c++.clang.fallbackscanner --cxxflags=\"-stdlib=libc++\" -c --yes") + -- _build() + -- end + end + local vs = find_vstudio() if vs and vs["2022"] then + os.exec("xmake clean -a") os.exec("xmake f -c --yes") _build() end + elseif is_subhost("msys") then + -- on windows, mingw modulemapper doesn't handle headeunit path correctly, but it's working with mingw on macOS / Linux + -- 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 - -- gcc trtbd dependency detection doesn't support header units atm + -- gcc dependency detection doesn't support header units atm os.exec("xmake f --policies=build.c++.gcc.fallbackscanner -c --yes") _build() end @@ -30,15 +48,16 @@ function main(t) if semver.compare(clang.version, "15.0") >= 0 then os.exec("xmake clean -a") -- clang-scan-deps dependency detection doesn't support header units atm - os.exec("xmake f --toolchain=clang --policies=build.c++.clang.fallbackscanner -c") + os.exec("xmake f --toolchain=clang --policies=build.c++.clang.fallbackscanner -c --yes") _build() - -- elseif semver.compare(clang.version, "15.0") >= 0 then - -- there is currently a bug on llvm git that prevent to build STL header units https://github.com/llvm/llvm-project/issues/58540 - -- os.exec("xmake clean -a") - -- clang-scan-deps dependency detection doesn't support header units atm - -- os.exec("xmake f --toolchain=clang --policies=build.c++.modules.fallbackscanner.clang --cxxflags=\"-stdlib=libc++\" -c") - -- _build() end + -- libc++ headerunit are bugged + -- if semver.compare(clang.version, "17.0") >= 0 then + -- os.exec("xmake clean -a") + -- -- clang-scan-deps dependency detection doesn't support header units atm + -- os.exec("xmake f --toolchain=clang --policies=build.c++.clang.fallbackscanner --cxxflags=\"-stdlib=libc++\" -c --yes") + -- _build() + -- end end end end -- cgit v1.3.1 From cb8b45ba6e641156ca2e7544cce901c749b9d30a Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Fri, 26 Jan 2024 18:43:00 +0100 Subject: update tests to use XMake runtimes support --- tests/projects/c++/modules/test_base.lua | 4 ++-- tests/projects/c++/modules/test_headerunits.lua | 4 ++-- tests/projects/c++/modules/test_stdmodules.lua | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'tests/projects/c++/modules/test_headerunits.lua') diff --git a/tests/projects/c++/modules/test_base.lua b/tests/projects/c++/modules/test_base.lua index 08cda468b..c4252d41c 100644 --- a/tests/projects/c++/modules/test_base.lua +++ b/tests/projects/c++/modules/test_base.lua @@ -17,7 +17,7 @@ function main(t) os.exec("xmake f --toolchain=clang -c --yes") _build() os.exec("xmake clean -a") - os.exec("xmake f --toolchain=clang --cxxflags=\"-stdlib=libc++\" -c --yes") + os.exec("xmake f --toolchain=clang --runtimes=c++_shared -c --yes") _build() end @@ -39,7 +39,7 @@ function main(t) os.exec("xmake f --toolchain=clang -c --yes") _build() os.exec("xmake clean -a") - os.exec("xmake f --toolchain=clang --cxxflags=\"-stdlib=libc++\" -c --yes") + os.exec("xmake f --toolchain=clang --runtimes=c++_shared -c --yes") _build() end end diff --git a/tests/projects/c++/modules/test_headerunits.lua b/tests/projects/c++/modules/test_headerunits.lua index 0ece0992d..ba7fde015 100644 --- a/tests/projects/c++/modules/test_headerunits.lua +++ b/tests/projects/c++/modules/test_headerunits.lua @@ -21,7 +21,7 @@ function main(t) -- if semver.compare(clang.version, "17.0") >= 0 then -- os.exec("xmake clean -a") -- -- clang-scan-deps dependency detection doesn't support header units atm - -- os.exec("xmake f --toolchain=clang --policies=build.c++.clang.fallbackscanner --cxxflags=\"-stdlib=libc++\" -c --yes") + -- os.exec("xmake f --toolchain=clang --policies=build.c++.clang.fallbackscanner --runtimes=c++_shared -c --yes") -- _build() -- end end @@ -55,7 +55,7 @@ function main(t) -- if semver.compare(clang.version, "17.0") >= 0 then -- os.exec("xmake clean -a") -- -- clang-scan-deps dependency detection doesn't support header units atm - -- os.exec("xmake f --toolchain=clang --policies=build.c++.clang.fallbackscanner --cxxflags=\"-stdlib=libc++\" -c --yes") + -- os.exec("xmake f --toolchain=clang --policies=build.c++.clang.fallbackscanner --runtimes=c++_shared -c --yes") -- _build() -- end end diff --git a/tests/projects/c++/modules/test_stdmodules.lua b/tests/projects/c++/modules/test_stdmodules.lua index 0ba72cc50..222ec9458 100644 --- a/tests/projects/c++/modules/test_stdmodules.lua +++ b/tests/projects/c++/modules/test_stdmodules.lua @@ -19,7 +19,7 @@ function main(t) -- _build() -- clang don't support libc++ std modules atm -- os.exec("xmake clean -a") - -- os.exec("xmake f --toolchain=clang --cxxflags=\"-stdlib=libc++\" -c --yes") + -- os.exec("xmake f --toolchain=clang --runtimes=c++_shared -c --yes") -- _build() -- end local msvc = toolchain.load("msvc") @@ -52,7 +52,7 @@ function main(t) -- _build() -- clang don't support libc++ std modules atm -- os.exec("xmake clean -a") - -- os.exec("xmake f --toolchain=clang --cxxflags=\"-stdlib=libc++\" -c --yes") + -- os.exec("xmake f --toolchain=clang --runtimes=c++_shared -c --yes") -- _build() -- end end -- cgit v1.3.1 From b40cc4227ce6d4c491d592b361843a42232cd33d Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Sat, 3 Feb 2024 16:39:33 +0100 Subject: improve tests --- .../c++/modules/circular_dependency/test.lua | 53 +--------------------- tests/projects/c++/modules/test_base.lua | 4 +- tests/projects/c++/modules/test_headerunits.lua | 4 +- tests/projects/c++/modules/test_stdmodules.lua | 4 +- 4 files changed, 8 insertions(+), 57 deletions(-) (limited to 'tests/projects/c++/modules/test_headerunits.lua') diff --git a/tests/projects/c++/modules/circular_dependency/test.lua b/tests/projects/c++/modules/circular_dependency/test.lua index 02b11dbff..14f82051a 100644 --- a/tests/projects/c++/modules/circular_dependency/test.lua +++ b/tests/projects/c++/modules/circular_dependency/test.lua @@ -1,54 +1,5 @@ -import("lib.detect.find_tool") -import("core.base.semver") - -function _build() - local ci = (os.getenv("CI") or os.getenv("GITHUB_ACTIONS") or ""):lower() - local passed = false - try {function() - if ci == "true" then - os.run("xmake -rvD") - else - os.run("xmake -r") - end - end, catch{function(errors) - print(errors) - passed = errors:match("circular modules dependency detected!") - end}} - - assert(passed) -end +import(".test_base", {alias = "test_build"}) 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, "14.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 + t:will_raise(test_build, "error: circular modules dependency detected!") end diff --git a/tests/projects/c++/modules/test_base.lua b/tests/projects/c++/modules/test_base.lua index c4252d41c..e6f46764a 100644 --- a/tests/projects/c++/modules/test_base.lua +++ b/tests/projects/c++/modules/test_base.lua @@ -1,9 +1,9 @@ import("lib.detect.find_tool") import("core.base.semver") +import("utils.ci.is_running", {alias = "ci_is_running"}) function _build() - local ci = (os.getenv("CI") or os.getenv("GITHUB_ACTIONS") or ""):lower() - if ci == "true" then + if ci_is_running() then os.exec("xmake -rvD") else os.exec("xmake -r") diff --git a/tests/projects/c++/modules/test_headerunits.lua b/tests/projects/c++/modules/test_headerunits.lua index ba7fde015..05d7463ea 100644 --- a/tests/projects/c++/modules/test_headerunits.lua +++ b/tests/projects/c++/modules/test_headerunits.lua @@ -1,10 +1,10 @@ import("lib.detect.find_tool") import("core.base.semver") import("detect.sdks.find_vstudio") +import("utils.ci.is_running", {alias = "ci_is_running"}) function _build() - local ci = (os.getenv("CI") or os.getenv("GITHUB_ACTIONS") or ""):lower() - if ci == "true" then + if ci_is_running() then os.exec("xmake -rvD") else os.exec("xmake -r") diff --git a/tests/projects/c++/modules/test_stdmodules.lua b/tests/projects/c++/modules/test_stdmodules.lua index c408c1d08..b70ff6bbb 100644 --- a/tests/projects/c++/modules/test_stdmodules.lua +++ b/tests/projects/c++/modules/test_stdmodules.lua @@ -1,10 +1,10 @@ import("lib.detect.find_tool") import("core.base.semver") import("core.tool.toolchain") +import("utils.ci.is_running", {alias = "ci_is_running"}) function _build() - local ci = (os.getenv("CI") or os.getenv("GITHUB_ACTIONS") or ""):lower() - if ci == "true" then + if ci_is_running() then os.exec("xmake -rvD") else os.exec("xmake -r") -- cgit v1.3.1 From 2d59e22d8cbf7ec4405f80ad38d6b836cc125875 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Sat, 3 Feb 2024 17:39:56 +0100 Subject: fix tests --- tests/projects/c++/modules/circular_dependency/test.lua | 2 +- tests/projects/c++/modules/test_base.lua | 4 ++-- tests/projects/c++/modules/test_headerunits.lua | 4 ++-- tests/projects/c++/modules/test_stdmodules.lua | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'tests/projects/c++/modules/test_headerunits.lua') diff --git a/tests/projects/c++/modules/circular_dependency/test.lua b/tests/projects/c++/modules/circular_dependency/test.lua index 14f82051a..fc20e469c 100644 --- a/tests/projects/c++/modules/circular_dependency/test.lua +++ b/tests/projects/c++/modules/circular_dependency/test.lua @@ -1,5 +1,5 @@ import(".test_base", {alias = "test_build"}) function main(t) - t:will_raise(test_build, "error: circular modules dependency detected!") + t:will_raise(test_build, "circular modules dependency detected") end diff --git a/tests/projects/c++/modules/test_base.lua b/tests/projects/c++/modules/test_base.lua index e6f46764a..4c972c7b6 100644 --- a/tests/projects/c++/modules/test_base.lua +++ b/tests/projects/c++/modules/test_base.lua @@ -4,9 +4,9 @@ import("utils.ci.is_running", {alias = "ci_is_running"}) function _build() if ci_is_running() then - os.exec("xmake -rvD") + os.run("xmake -rvD") else - os.exec("xmake -r") + os.run("xmake -r") end end diff --git a/tests/projects/c++/modules/test_headerunits.lua b/tests/projects/c++/modules/test_headerunits.lua index 05d7463ea..bb32070cf 100644 --- a/tests/projects/c++/modules/test_headerunits.lua +++ b/tests/projects/c++/modules/test_headerunits.lua @@ -5,9 +5,9 @@ import("utils.ci.is_running", {alias = "ci_is_running"}) function _build() if ci_is_running() then - os.exec("xmake -rvD") + os.run("xmake -rvD") else - os.exec("xmake -r") + os.run("xmake -r") end end diff --git a/tests/projects/c++/modules/test_stdmodules.lua b/tests/projects/c++/modules/test_stdmodules.lua index b70ff6bbb..68a5922ef 100644 --- a/tests/projects/c++/modules/test_stdmodules.lua +++ b/tests/projects/c++/modules/test_stdmodules.lua @@ -5,9 +5,9 @@ import("utils.ci.is_running", {alias = "ci_is_running"}) function _build() if ci_is_running() then - os.exec("xmake -rvD") + os.run("xmake -rvD") else - os.exec("xmake -r") + os.run("xmake -r") end end -- cgit v1.3.1 From 4cb6ecce1119c66bb5c84a27f3f155b2b28ab6ba Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 16 Feb 2024 00:59:50 +0800 Subject: add more tests --- .../projects/c++/modules/internal_partition/src/hello_internal.mpp | 4 ++-- tests/projects/c++/modules/test_headerunits.lua | 6 ++++++ tests/projects/c++/modules/test_stdmodules.lua | 6 ++++++ 3 files changed, 14 insertions(+), 2 deletions(-) (limited to 'tests/projects/c++/modules/test_headerunits.lua') diff --git a/tests/projects/c++/modules/internal_partition/src/hello_internal.mpp b/tests/projects/c++/modules/internal_partition/src/hello_internal.mpp index 8d0d4bee0..46a86c361 100644 --- a/tests/projects/c++/modules/internal_partition/src/hello_internal.mpp +++ b/tests/projects/c++/modules/internal_partition/src/hello_internal.mpp @@ -7,5 +7,5 @@ module hello:part_internal; namespace hello { void say_internal(const char *str) { printf("%s\n", str); - } -} \ No newline at end of file + } +} diff --git a/tests/projects/c++/modules/test_headerunits.lua b/tests/projects/c++/modules/test_headerunits.lua index bb32070cf..70e8b3d51 100644 --- a/tests/projects/c++/modules/test_headerunits.lua +++ b/tests/projects/c++/modules/test_headerunits.lua @@ -9,6 +9,12 @@ function _build() else os.run("xmake -r") end + local outdata = os.iorun("xmake") + if outdata then + if outdata:find("compiling") or outdata:find("linking") or outdata:find("generating") then + raise("Modules incremental compilation does not work\n%s", outdata) + end + end end function main(t) diff --git a/tests/projects/c++/modules/test_stdmodules.lua b/tests/projects/c++/modules/test_stdmodules.lua index 68a5922ef..6c3a16b2c 100644 --- a/tests/projects/c++/modules/test_stdmodules.lua +++ b/tests/projects/c++/modules/test_stdmodules.lua @@ -9,6 +9,12 @@ function _build() else os.run("xmake -r") end + local outdata = os.iorun("xmake") + if outdata then + if outdata:find("compiling") or outdata:find("linking") or outdata:find("generating") then + raise("Modules incremental compilation does not work\n%s", outdata) + end + end end function main(t) -- cgit v1.3.1