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_base.lua | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'tests/projects/c++/modules/test_base.lua') diff --git a/tests/projects/c++/modules/test_base.lua b/tests/projects/c++/modules/test_base.lua index efef15520..08cda468b 100644 --- a/tests/projects/c++/modules/test_base.lua +++ b/tests/projects/c++/modules/test_base.lua @@ -12,21 +12,34 @@ end function main(t) if is_subhost("windows") then - os.exec("xmake f -c") + 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 --cxxflags=\"-stdlib=libc++\" -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 is_host("linux") and gcc and gcc.version and semver.compare(gcc.version, "11.0") >= 0 then - os.exec("xmake f -c") + 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") + os.exec("xmake f --toolchain=clang -c --yes") _build() os.exec("xmake clean -a") - os.exec("xmake f --toolchain=clang --cxxflags=\"-stdlib=libc++\" -c") + os.exec("xmake f --toolchain=clang --cxxflags=\"-stdlib=libc++\" -c --yes") _build() 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_base.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_base.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_base.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 794f6db0adafe26f041d31594cc7e516017ede39 Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 4 Feb 2024 09:26:34 +0800 Subject: Update test_base.lua --- tests/projects/c++/modules/test_base.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests/projects/c++/modules/test_base.lua') diff --git a/tests/projects/c++/modules/test_base.lua b/tests/projects/c++/modules/test_base.lua index 4c972c7b6..092fbd72f 100644 --- a/tests/projects/c++/modules/test_base.lua +++ b/tests/projects/c++/modules/test_base.lua @@ -10,6 +10,23 @@ function _build() 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}) -- cgit v1.3.1 From 6015b11e6904c81b676c53d6947d7ab00a474781 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 10 Feb 2024 23:02:44 +0800 Subject: test modules incremental compilation --- tests/projects/c++/modules/test_base.lua | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/projects/c++/modules/test_base.lua') diff --git a/tests/projects/c++/modules/test_base.lua b/tests/projects/c++/modules/test_base.lua index 092fbd72f..219901c63 100644 --- a/tests/projects/c++/modules/test_base.lua +++ b/tests/projects/c++/modules/test_base.lua @@ -8,6 +8,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 can_build() -- cgit v1.3.1