From aa26b7fd4c4c528395d41d601058eebf9a747e5c Mon Sep 17 00:00:00 2001 From: star9029 Date: Mon, 22 Apr 2024 23:01:35 +0800 Subject: [PATCH] add fakeit (#3848) --- packages/f/fakeit/xmake.lua | 54 +++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 packages/f/fakeit/xmake.lua diff --git a/packages/f/fakeit/xmake.lua b/packages/f/fakeit/xmake.lua new file mode 100644 index 000000000..e431e691d --- /dev/null +++ b/packages/f/fakeit/xmake.lua @@ -0,0 +1,54 @@ +package("fakeit") + set_kind("library", {headeronly = true}) + set_homepage("https://github.com/eranpeer/FakeIt") + set_description("C++ mocking made easy. A simple yet very expressive, headers only library for c++ mocking.") + set_license("MIT") + + add_urls("https://github.com/eranpeer/FakeIt/archive/refs/tags/$(version).tar.gz", + "https://github.com/eranpeer/FakeIt.git") + + add_versions("2.4.0", "eb79459ad6a97a5c985e3301b0d44538bdce2ba26115afe040f3874688edefb5") + + local test_frameworks = { + "gtest", + "mstest", + "boost", + "catch", + "tpunit", + "mettle", + "qtest", + "nunit", + "cute", + "doctest", + "standalone", + } + + add_configs("framework", {description = "Choose test library to use", default = "standalone", type = "string", values = test_frameworks}) + + on_load(function (package) + local framework = package:config("framework") + if framework == "gtest" then + package:add("deps", "gtest") + elseif framework == "boost" then + package:add("deps", "boost", {configs = {test = true}}) + elseif framework == "catch" then + package:add("deps", "catch2") + elseif framework == "doctest" then + package:add("deps", "doctest") + end + end) + + on_install(function (package) + os.vcp(path.join("single_header", package:config("framework"), "*"), package:installdir("include")) + end) + + on_test(function (package) + assert(package:check_cxxsnippets({test = [[ + struct SomeInterface { + virtual int foo(int) = 0; + }; + void test() { + fakeit::Mock mock; + } + ]]}, {configs = {languages = "c++11"}, includes = "fakeit.hpp"})) + end)