build: Move lib_spark tests into separate exe

So we don't have to run them through sparkd
This commit is contained in:
John Colvin committed 2024-11-29 15:05:53 +00:00
1 parent 7d4367d50c
commit 64d015d1ed
48 files changed
+87 -44

No files matched your search

+27 -1
View File
@@ -33,7 +33,7 @@ get_proto_sources(
${PROJECT_NAME}_PROTO_SOURCES
${PROJECT_NAME}_PROTO_SERVICES
)
get_cpp_sources(${PROJECT_NAME}_SOURCES)
get_cpp_sources(${PROJECT_NAME}_SOURCES ${PROJECT_NAME}_TEST_SOURCES)
protobuf_generate_cpp(
CXX_SOURCES ${PROJECT_NAME}_CXX_PROTO_SOURCES
CXX_HEADERS ${PROJECT_NAME}_CXX_PROTO_HEADERS
@@ -131,3 +131,29 @@ foreach(_hdr ${${PROJECT_NAME}_CXX_PROTO_SERVICE_HEADERS})
endforeach()
install_basic()
# Add tests executable (if there are any)
if (${PROJECT_NAME}_TEST_SOURCES)
add_executable(${PROJECT_NAME}-tests ${${PROJECT_NAME}_TEST_SOURCES})
# Set RPATH so the tests exe knows where to find the shared lib.
set_target_properties(
${PROJECT_NAME}-tests
PROPERTIES
BUILD_RPATH "$ORIGIN"
INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}"
)
# Link main lib
target_link_directories(
${PROJECT_NAME}-tests
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_LIBDIR}>
)
target_link_libraries(${PROJECT_NAME}-tests PRIVATE ${PROJECT_NAME})
# Catch2
find_package(Catch2 CONFIG REQUIRED COMPONENTS Catch2WithMain)
target_link_libraries(${PROJECT_NAME}-tests PRIVATE Catch2::Catch2WithMain)
endif()
@@ -25,10 +25,23 @@ function(get_proto_sources cfg_srcs non_cfg_srcs service_srcs)
set(${service_srcs} ${_service_srcs} PARENT_SCOPE)
endfunction()
function(get_cpp_sources dest)
function(get_cpp_sources srcs test_srcs)
file(
GLOB_RECURSE _dest
GLOB_RECURSE _srcs
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
${PROJECT_NAME}/*.cpp)
set(${dest} ${_dest} PARENT_SCOPE)
# Note: cpp files inside 'tests' dir(s) are considered tests.
# Remove tests from main sources, and add them to test sources
foreach(item ${_srcs})
if(${item} MATCHES "tests/.*\.cpp$")
list(APPEND _test_srcs ${item})
endif()
endforeach()
foreach(item ${_test_srcs})
list(REMOVE_ITEM ${_srcs} ${item})
endforeach()
set(${srcs} ${_srcs} PARENT_SCOPE)
set(${test_srcs} ${_test_srcs} PARENT_SCOPE)
endfunction()
@@ -14,8 +14,9 @@
#include "spark/orderman/orders/algo/algo_orders/TaskingEyeAlgo.h"
#include "spark/orderman/orders/algo/algo_orders/VolAlgo.h"
#include "spark/orderman/orders/algo/algo_orders/limit_cover/LimitCoverAdapter.h"
#include "spark/orderman/orders/algo/algo_orders/tests/ExecutionTesterAlgo.h"
#include "spark/plugin/SparkServices.h"
#include "spark/tests/orderman/algos/ExecutionTesterAlgo.h"
#include <vector>
using namespace bts;
@@ -1,7 +1,7 @@
#include "spark/utils/TempDir.h"
#include "spark/utils/TempFile.h"
#include "../config.h"
#include "spark/config/config.h"
#include "spark/config/invalid/invalid.pb.h"
#include "spark/config/protos/testkeys.pb.h"
#include "system/expression/parser_exceptions.h"
@@ -1,6 +1,6 @@
#include "spark/utils/TempFile.h"
#include "../config.h"
#include "spark/config/config.h"
#include "spark/utils/bts_assert.h"
#include "spark/utils/is_unittest_environment.h"
#include "system/config/configuration_exception.h"
@@ -2,7 +2,7 @@
#include "spark/jetfix/connection/AsyncReader.h"
#include "spark/jetfix/connection/IConnection.h"
#include "spark/jetfix/gateway/ICoreGatewayEventSink.h"
#include "spark/jetfix/tests/sample_fix.h"
#include "spark/tests/jetfix/sample_fix.h"
#include <catch2/catch_all.hpp>
#include <fstream>
@@ -1,6 +1,6 @@
#pragma once
#include "../coconut2.h"
#include "spark/md/coconut2.h"
#include "spark/utils/bts_no_copy.h"
#include <memory>
@@ -1,7 +1,7 @@
#ifndef _WIN32
#include "../IntPrice.h"
#include "../MBOProcessor.h"
#include "Co2TestInstrument.h"
#include "spark/md/IntPrice.h"
#include "spark/md/MBOProcessor.h"
#include "spark/tests/md/Co2TestInstrument.h"
#include "spark/utils/Shuffle.h"
#include <algorithm>
@@ -1,25 +1,24 @@
#ifndef _WIN32
#include "../MDClient.h"
#include "../SecurityCache.h"
#include "../SettlementRecorder.h"
#include "../coconut2.h"
#include "Co2TestInstrument.h"
#include "spark/config/config.h"
#include "spark/config/protos/market_data.pb.h"
#include "spark/md/MDClient.h"
#include "spark/md/PriceSize.h"
#include "spark/md/SecurityCache.h"
#include "spark/md/SettlementRecorder.h"
#include "spark/md/coconut2.h"
#include "spark/md/relay/query_server.h"
#include "spark/metrics/metrics.h"
#include "spark/persistence/SqliteStore.h"
#include "spark/tests/md/Co2TestInstrument.h"
#include "spark/tests/md/md_test_utils.h"
#include "spark/utils/Dispatcher.h"
#include "spark/utils/Shuffle.h"
#include "spark/utils/Sqlite_utils.h"
#include "spark/utils/bts_chrono.h"
#include "spark/utils/defer.h"
#include "spark/utils/warn_ctrl.h"
#include "system/os.h"
#include "md_test_utils.h"
#include "spark/config/protos/market_data.pb.h"
#include "spark/utils/Sqlite_utils.h"
#include <algorithm>
#include <catch2/catch_all.hpp>
#include <cmath>
@@ -1,5 +1,5 @@
#include "md_test_utils.h"
#include "../MDProducer.h"
#include "spark/md/MDProducer.h"
#include <string>
#include <vector>
@@ -45,4 +45,4 @@ void assign_ids(
} // namespace test
} // namespace md
} // namespace bts
} // namespace bts
@@ -1,7 +1,7 @@
#pragma once
#include "../MDProducerHandle.h"
#include "spark/md/IntPrice.h"
#include "spark/md/MDProducerHandle.h"
#include "spark/md/PriceSize.h"
#include <vector>
@@ -37,4 +37,4 @@ void assign_ids(
} // namespace test
} // namespace md
} // namespace bts
} // namespace bts
@@ -1,9 +1,10 @@
#ifndef _WIN32
#include "../MDConsumerHandle.h"
#include "Co2TestInstrument.h"
#include "spark/md/MDConsumerHandle.h"
#include "spark/tests/md/Co2TestInstrument.h"
#include "spark/tests/md/md_test_utils.h"
#include "spark/utils/TimeStamp.h"
#include "spark/utils/sane_algorithm.h"
#include "md_test_utils.h"
#include <algorithm>
#include <catch2/catch_all.hpp>
#include <memory>
@@ -12,6 +13,7 @@
#include <string>
#include <tuple>
#include <vector>
#define ENABLE_BENCHMARK 0
#if ENABLE_BENCHMARK
#include <benchmark/benchmark.h>
@@ -7,12 +7,13 @@
#include "spark/orderman/orderman_utils/orderman_utils.h"
#include "spark/orderman/orders/algo/algo_orders/LimitCoverAlgo.h"
#include "spark/orderman/orders/algo/algo_orders/limit_cover/LimitCoverAdapter.h"
#include "spark/orderman/orders/algo/algo_orders/tests/AlgoTestDriver.h"
#include "spark/orderman/orders/algo/algo_orders/tests/limit_cover/LimitCoverState.h"
#include "spark/orderman/orders/algo/algo_orders/tests/limit_cover/LimitCoverTestUtils.h"
#include "spark/orderman/orders/algo/algo_orders/tests/limit_cover/TestSteps.h"
#include "spark/sparkproto/SparkProtos.pb.h"
#include "spark/tests/orderman/algos/AlgoTestDriver.h"
#include "spark/tests/orderman/algos/limit_cover/LimitCoverState.h"
#include "spark/tests/orderman/algos/limit_cover/LimitCoverTestUtils.h"
#include "spark/tests/orderman/algos/limit_cover/TestSteps.h"
#include "spark/utils/PBUtils.h"
#include <array>
#include <catch2/catch_all.hpp>
#include <cmath>
@@ -1,8 +1,8 @@
#include "../DormanAlgo.h"
#include "AlgoTestDriver.h"
#include "spark/domain_model/Security.h"
#include "spark/orderman/orderman_utils/Book.h"
#include "spark/orderman/orderman_utils/orderman_utils.h"
#include "spark/orderman/orders/algo/algo_orders/DormanAlgo.h"
#include "spark/tests/orderman/algos/AlgoTestDriver.h"
#include <catch2/catch_all.hpp>
#include <optional>
@@ -1,11 +1,11 @@
#include "spark/orderman/orders/algo/algo_orders/tests/limit_cover/LimitCoverState.h"
#include "LimitCoverState.h"
#include "spark/domain_model/Security.h"
#include "spark/md/IntPrice.h"
#include "spark/orderman/order_factory/IOrderFactory.h"
#include "spark/orderman/orderman_utils/BookUtils.h"
#include "spark/orderman/orderman_utils/Formatter.h"
#include "spark/orderman/orders/algo/algo_orders/limit_cover/LimitCoverAdapter.h"
#include "spark/orderman/orders/algo/algo_orders/tests/limit_cover/LimitCoverTestUtils.h"
#include "spark/tests/orderman/algos/limit_cover/LimitCoverTestUtils.h"
#include <catch2/catch_all.hpp>
@@ -4,8 +4,9 @@
#include "spark/orderman/orderman_utils/Book.h"
#include "spark/orderman/orders/algo/algo_orders/LimitCoverAlgo.h"
#include "spark/orderman/orders/algo/algo_orders/limit_cover/LimitCoverDefinition.h"
#include "spark/orderman/orders/algo/algo_orders/tests/AlgoTestDriver.h"
#include "spark/sparkproto/SparkProtos.pb.h"
#include "spark/tests/orderman/algos/AlgoTestDriver.h"
#include <iostream>
#include <map>
#include <optional>
@@ -124,4 +125,4 @@ operator<<(std::ostream &ostr, const LimitCoverState &lcs) {
} // namespace limit_cover
} // namespace test
} // namespace orderman
} // namespace bts
} // namespace bts
@@ -1,7 +1,7 @@
#include "spark/orderman/orders/algo/algo_orders/tests/limit_cover/TestSteps.h"
#include "TestSteps.h"
#include "spark/api/services/OrderService.pb.h"
#include "spark/orderman/order_factory/IOrderFactory.h"
#include "spark/orderman/orders/algo/algo_orders/tests/limit_cover/LimitCoverTestUtils.h"
#include "spark/tests/orderman/algos/limit_cover/LimitCoverTestUtils.h"
#include <catch2/catch_all.hpp>
#include <functional>
@@ -1,6 +1,6 @@
#pragma once
#include "spark/api/services/OrderService.pb.h"
#include "spark/orderman/orders/algo/algo_orders/tests/limit_cover/LimitCoverState.h"
#include "spark/tests/orderman/algos/limit_cover/LimitCoverState.h"
#include <catch2/catch_all.hpp>
#include <functional>
@@ -1,7 +1,7 @@
#include "../SplitterAlgo.h"
#include "AlgoTestDriver.h"
#include "spark/orderman/orderman_utils/Book.h"
#include "spark/orderman/orders/algo/algo_orders/SplitterAlgo.h"
#include "spark/tests/orderman/algos/AlgoTestDriver.h"
#include "spark/utils/bts_chrono.h"
#include <catch2/catch_all.hpp>
@@ -1,6 +1,6 @@
#include "../PersistenceServiceServer.h"
#include "spark/api/public/ServiceContext.h"
#include "spark/api/services/PersistenceService.client.pb.h"
#include "spark/persistence/PersistenceServiceServer.h"
#include "spark/persistence/SqliteStore.h"
#include "spark/utils/TempDir.h"
#include "spark/utils/Uuid.h"