Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F113120
D35.1732384835.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D35.1732384835.diff
View Options
diff --git a/src/testfixtures/factory.cpp b/src/testfixtures/factory.cpp
--- a/src/testfixtures/factory.cpp
+++ b/src/testfixtures/factory.cpp
@@ -19,7 +19,9 @@
{
static std::size_t next = 0;
++next;
- return "$" + std::to_string(next);
+ std::stringstream s;
+ s << std::setw(40) << std::setfill('0') << next;
+ return "$" + s.str();
}
static std::string generateRoomId()
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -1,21 +1,52 @@
-
include(CTest)
set(KAZVTEST_RESPATH ${CMAKE_CURRENT_SOURCE_DIR}/resources)
configure_file(kazvtest-respath.hpp.in kazvtest-respath.hpp)
-add_executable(kazvtest
- testmain.cpp
- basejobtest.cpp
+function(libkazv_add_tests)
+ set(options "")
+ set(oneValueArgs "")
+ set(multiValueArgs EXTRA_LINK_LIBRARIES EXTRA_INCLUDE_DIRECTORIES)
+ cmake_parse_arguments(PARSE_ARGV 0 libkazv_add_tests "${options}" "${oneValueArgs}" "${multiValueArgs}")
+ foreach(test_source ${libkazv_add_tests_UNPARSED_ARGUMENTS})
+ string(REGEX REPLACE "\\.cpp$" "" test_executable "${test_source}")
+ string(REGEX REPLACE "/|\\\\" "--" test_executable "${test_executable}")
+ message(STATUS "Test ${test_executable} added")
+ add_executable("${test_executable}" "${test_source}")
+ target_link_libraries("${test_executable}"
+ PRIVATE Catch2::Catch2WithMain
+ Threads::Threads
+ ${libkazv_add_tests_EXTRA_LINK_LIBRARIES}
+ )
+
+ target_include_directories(
+ "${test_executable}"
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/..
+ ${libkazv_add_tests_EXTRA_INCLUDE_DIRECTORIES}
+ )
+
+ target_compile_definitions("${test_executable}" PRIVATE CATCH_CONFIG_ENABLE_ALL_STRINGMAKERS)
+
+ add_test(NAME "${test_executable}" COMMAND "${test_executable}" "--allow-running-no-tests" "~[needs-internet]")
+ endforeach()
+endfunction()
+
+libkazv_add_tests(
event-test.cpp
cursorutiltest.cpp
base/serialization-test.cpp
base/types-test.cpp
base/immer-utils-test.cpp
base/json-utils-test.cpp
+ EXTRA_LINK_LIBRARIES kazvbase
+)
- client/client-test-util.cpp
+add_library(client-test-lib SHARED client/client-test-util.cpp)
+target_link_libraries(client-test-lib PUBLIC kazvjob kazvclient)
+libkazv_add_tests(
client/discovery-test.cpp
client/sync-test.cpp
client/content-test.cpp
@@ -50,32 +81,34 @@
client/create-room-test.cpp
client/device-list-tracker-benchmark-test.cpp
client/room/read-receipt-test.cpp
+ EXTRA_LINK_LIBRARIES kazvclient kazveventemitter kazvjob client-test-lib kazvtestfixtures
+ EXTRA_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/client
+)
+libkazv_add_tests(
+ basejobtest.cpp
kazvjobtest.cpp
- event-emitter-test.cpp
- crypto-test.cpp
- crypto/deterministic-test.cpp
- promise-test.cpp
- store-test.cpp
file-desc-test.cpp
- )
+ EXTRA_LINK_LIBRARIES kazvbase kazvjob
+)
-target_include_directories(
- kazvtest
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/client)
+libkazv_add_tests(
+ promise-test.cpp
+ EXTRA_LINK_LIBRARIES kazvbase kazvjob kazvstore
+)
-target_compile_definitions(kazvtest PRIVATE CATCH_CONFIG_ENABLE_ALL_STRINGMAKERS)
+libkazv_add_tests(
+ event-emitter-test.cpp
+ EXTRA_LINK_LIBRARIES kazvbase kazveventemitter
+)
-target_link_libraries(kazvtest
- PRIVATE Catch2::Catch2WithMain
- PRIVATE kazv
- PRIVATE kazveventemitter
- PRIVATE kazvjob
- PRIVATE nlohmann_json::nlohmann_json
- PRIVATE immer
- PRIVATE lager
- PRIVATE zug
- PRIVATE kazvtestfixtures
+libkazv_add_tests(
+ crypto-test.cpp
+ crypto/deterministic-test.cpp
+ EXTRA_LINK_LIBRARIES kazvcrypto
)
-add_test(NAME kazvtest COMMAND kazvtest "~[needs-internet]")
+libkazv_add_tests(
+ store-test.cpp
+ EXTRA_LINK_LIBRARIES kazvstore kazvjob
+)
diff --git a/src/tests/crypto/deterministic-test.cpp b/src/tests/crypto/deterministic-test.cpp
--- a/src/tests/crypto/deterministic-test.cpp
+++ b/src/tests/crypto/deterministic-test.cpp
@@ -11,7 +11,7 @@
#include <crypto.hpp>
#include <outbound-group-session.hpp>
-#include <random-generator.hpp>
+#include <client/random-generator.hpp>
using namespace Kazv;
diff --git a/src/tests/testmain.cpp b/src/tests/testmain.cpp
deleted file mode 100644
--- a/src/tests/testmain.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * This file is part of libkazv.
- * SPDX-FileCopyrightText: 2020 Tusooa Zhu
- * SPDX-License-Identifier: AGPL-3.0-or-later
- */
-
-#include <libkazv-config.hpp>
-
-
-#include <catch2/catch_all.hpp>
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 10:00 AM (14 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39329
Default Alt Text
D35.1732384835.diff (4 KB)
Attached To
Mode
D35: Split each test into its own executable
Attached
Detach File
Event Timeline
Log In to Comment