diff options
| author | Arthur LAURENT <[email protected]> | 2024-02-03 16:39:33 +0100 |
|---|---|---|
| committer | Arthur LAURENT <[email protected]> | 2024-02-03 16:39:33 +0100 |
| commit | b40cc4227ce6d4c491d592b361843a42232cd33d (patch) | |
| tree | 0fb44b6a7d0222fefba47893f6eb759112a45eb7 /tests | |
| parent | 07c0af96d81dcaa2c4ab5b5a9450367a70758c2d (diff) | |
improve tests
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/projects/c++/modules/circular_dependency/test.lua | 53 | ||||
| -rw-r--r-- | tests/projects/c++/modules/test_base.lua | 4 | ||||
| -rw-r--r-- | tests/projects/c++/modules/test_headerunits.lua | 4 | ||||
| -rw-r--r-- | tests/projects/c++/modules/test_stdmodules.lua | 4 |
4 files changed, 8 insertions, 57 deletions
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") |
