From dbb8d2b48dff5168af981e2a70e016cda0d508ee Mon Sep 17 00:00:00 2001 From: star9029 Date: Mon, 21 Aug 2023 22:45:06 +0800 Subject: [PATCH] clean-test: add package (#2476) * clean-test: add package * fix configs * disable plat * disable shared --- packages/c/clean-test/xmake.lua | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 packages/c/clean-test/xmake.lua diff --git a/packages/c/clean-test/xmake.lua b/packages/c/clean-test/xmake.lua new file mode 100644 index 000000000..d66ed73ec --- /dev/null +++ b/packages/c/clean-test/xmake.lua @@ -0,0 +1,43 @@ +package("clean-test") + set_homepage("https://clean-test.dev") + set_description("A modern C++-20 testing framework.") + set_license("BSL-1.0") + + add_urls("https://github.com/clean-test/clean-test.git") + add_versions("2023.05.15", "d99321c97ba51c26397114ce535be4d1d9174693") + + if is_plat("linux", "bsd") then + add_syslinks("pthread") + add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true}) + elseif is_plat("macosx", "iphoneos") then + add_configs("shared", {description = "Build shared library.", default = true, type = "boolean", readonly = true}) + end + + add_deps("cmake") + + on_install("windows", "linux", "bsd", "mingw", "msys", "cross", function (package) + local configs = {"-DCLEANTEST_TEST=OFF"} + if package:config("shared") then + table.insert(configs, "-DCLEANTEST_BUILD_STATIC=OFF") + table.insert(configs, "-DCLEANTEST_BUILD_SHARED=ON") + else + table.insert(configs, "-DCLEANTEST_BUILD_STATIC=ON") + table.insert(configs, "-DCLEANTEST_BUILD_SHARED=OFF") + end + table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release")) + import("package.tools.cmake").install(package, configs) + end) + + on_test(function (package) + assert(package:check_cxxsnippets({test = [[ + #include + constexpr auto sum(auto... vs) { return (0 + ... + vs); } + namespace ct = clean_test; + using namespace ct::literals; + void test() { + auto const suite = ct::Suite{"sum", [] { + "0"_test = [] { ct::expect(sum() == 0_i); }; + }}; + } + ]]}, {configs = {languages = "c++20"}})) + end)