mtxclient: enable tests

This commit is contained in:
Lu Wang
2025-09-29 21:18:37 +08:00
parent bf105ba1f0
commit e4abb3f95c
2 changed files with 90 additions and 11 deletions
+13 -11
View File
@@ -12,29 +12,27 @@
openssl,
re2,
spdlog,
gtest,
}:
stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
pname = "mtxclient";
version = "0.10.1";
src = fetchFromGitHub {
owner = "Nheko-Reborn";
repo = "mtxclient";
rev = "v${version}";
rev = "v${finalAttrs.version}";
hash = "sha256-Y0FMCq4crSbm0tJtYq04ZFwWw+vlfxXKXBo0XUgf7hw=";
};
postPatch = ''
# See https://github.com/gabime/spdlog/issues/1897
sed -i '1a add_compile_definitions(SPDLOG_FMT_EXTERNAL)' CMakeLists.txt
'';
patches = [
./remove-network-tests.patch
];
cmakeFlags = [
# Network requiring tests can't be disabled individually:
# https://github.com/Nheko-Reborn/mtxclient/issues/22
"-DBUILD_LIB_TESTS=OFF"
"-DBUILD_LIB_EXAMPLES=OFF"
(lib.cmakeBool "BUILD_LIB_TESTS" finalAttrs.finalPackage.doCheck)
(lib.cmakeBool "BUILD_LIB_EXAMPLES" false)
];
nativeBuildInputs = [
@@ -53,6 +51,10 @@ stdenv.mkDerivation rec {
spdlog
];
checkInputs = [ gtest ];
doCheck = true;
meta = with lib; {
description = "Client API library for the Matrix protocol";
homepage = "https://github.com/Nheko-Reborn/mtxclient";
@@ -64,4 +66,4 @@ stdenv.mkDerivation rec {
];
platforms = platforms.all;
};
}
})
@@ -0,0 +1,77 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9d9f92932246ebec8ab5d1cc462366a17818d014..ce27390bd754a33986188dd2bf29cd0c818c2d58 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -398,36 +398,6 @@ if(BUILD_LIB_TESTS)
file(COPY tests/fixtures DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
- add_executable(client_api tests/client_api.cpp)
- target_link_libraries(client_api
- MatrixClient::MatrixClient
- GTest::GTest
- GTest::Main)
- target_include_directories(client_api PRIVATE
- ${CMAKE_CURRENT_SOURCE_DIR}/tests)
-
- add_executable(media_api tests/media_api.cpp)
- target_link_libraries(media_api
- MatrixClient::MatrixClient
- GTest::GTest
- GTest::Main)
- target_include_directories(media_api PRIVATE
- ${CMAKE_CURRENT_SOURCE_DIR}/tests)
-
- add_executable(e2ee tests/e2ee.cpp)
- target_link_libraries(e2ee
- MatrixClient::MatrixClient
- GTest::GTest
- GTest::Main)
- target_include_directories(e2ee PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests)
-
- add_executable(device tests/device.cpp)
- target_link_libraries(device
- MatrixClient::MatrixClient
- GTest::GTest
- GTest::Main)
- target_include_directories(device PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests)
-
add_executable(utils tests/utils.cpp)
target_link_libraries(utils
MatrixClient::MatrixClient
@@ -435,21 +405,6 @@ if(BUILD_LIB_TESTS)
GTest::Main)
target_include_directories(utils PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests)
- add_executable(pushrules tests/pushrules.cpp)
- target_link_libraries(pushrules
- MatrixClient::MatrixClient
- GTest::GTest
- GTest::Main)
- target_include_directories(pushrules PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests)
-
- add_executable(connection tests/connection.cpp)
- target_link_libraries(connection
- MatrixClient::MatrixClient
- GTest::GTest
- GTest::Main)
- target_include_directories(connection PRIVATE
- ${CMAKE_CURRENT_SOURCE_DIR}/tests)
-
add_executable(identifiers tests/identifiers.cpp)
target_link_libraries(identifiers
MatrixClient::MatrixClient
@@ -498,13 +453,7 @@ if(BUILD_LIB_TESTS)
GTest::GTest
GTest::Main)
- add_test(BasicConnectivity connection)
- add_test(ClientAPI client_api)
- add_test(MediaAPI media_api)
- add_test(Encryption e2ee)
- add_test(Devices device)
add_test(Utilities utils)
- add_test(Pushrules pushrules)
add_test(Identifiers identifiers)
add_test(Errors errors)
add_test(CryptoStructs crypto)