Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: run gtest #172

Merged
merged 8 commits into from
Feb 8, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/resp/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright (c) 2023-present, Arana/Kiwi Community. All rights reserved.
# Copyright (c) 2023-present, arana-db Community. All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.

cmake_minimum_required(VERSION 3.25)
CMAKE_MINIMUM_REQUIRED(VERSION 3.25)

INCLUDE(GoogleTest)
SET(CMAKE_CXX_STANDARD 20)
2 changes: 1 addition & 1 deletion src/std/kiwi_slot.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023-present, Arana/Kiwi Community. All rights reserved.
// Copyright (c) 2023-present, arana-db Community. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
43 changes: 21 additions & 22 deletions src/std/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
# Copyright (c) 2023-present, Arana/Kiwi Community. All rights reserved.
# Copyright (c) 2023-present, arana-db Community. All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.

cmake_minimum_required(VERSION 3.18)

include(GoogleTest)
set(CMAKE_CXX_STANDARD 20)
CMAKE_MINIMUM_REQUIRED(VERSION 3.25)

aux_source_directory(.. DIR_SRCS)
INCLUDE(GoogleTest)
SET(CMAKE_CXX_STANDARD 20)

file(GLOB_RECURSE KSTD_TEST_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/*.cc")
AUX_SOURCE_DIRECTORY(../ DIR_SRCS)

foreach (std_test_source ${KSTD_TEST_SOURCE})
get_filename_component(std_test_filename ${std_test_source} NAME)
string(REPLACE ".cc" "" std_test_name ${std_test_filename})
FILE(GLOB_RECURSE GTEST_TEST_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/*.cc")

# set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
add_executable(${std_test_name} ${std_test_source})
target_include_directories(${std_test_name}
PRIVATE ${PROJECT_SOURCE_DIR}/src
FOREACH (gtest_test_source ${GTEST_TEST_SOURCE})
GET_FILENAME_COMPONENT(gtest_test_filename ${gtest_test_source} NAME)
STRING(REPLACE ".cc" "" gtest_test_name ${gtest_test_filename})

ADD_EXECUTABLE(${gtest_test_name} ${gtest_test_source} ${DIR_SRCS})
TARGET_INCLUDE_DIRECTORIES(${gtest_test_name}
PRIVATE ${GTEST_INCLUDE_DIR}
)

add_dependencies(${std_test_name} kstd gtest)
target_link_libraries(${std_test_name}
PRIVATE kstd
PRIVATE ${GTEST_LIBRARIES}
)
gtest_discover_tests(${std_test_name})
endforeach ()
)

ADD_DEPENDENCIES(${gtest_test_name} kstd gtest)
TARGET_LINK_LIBRARIES(${gtest_test_name}
PUBLIC kstd
PUBLIC gtest
)
GTEST_DISCOVER_TESTS(${gtest_test_name})
ENDFOREACH ()