From 60f965cce394ec3db1e6cc13e898f0d55760bc01 Mon Sep 17 00:00:00 2001 From: tqcq <99722391+tqcq@users.noreply.github.com> Date: Tue, 5 Dec 2023 15:52:30 +0800 Subject: [PATCH] feature test env --- .gitea/workflows/build.yaml | 5 +++-- CMakeLists.txt | 3 --- src/main.cpp | 13 ------------- tests/CMakeLists.txt | 9 +++++++-- tests/src/ulib/sigslot/sigslot_test.cpp | 3 +++ 5 files changed, 13 insertions(+), 20 deletions(-) delete mode 100644 src/main.cpp diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index b3f2aea..4587b40 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -33,7 +33,7 @@ jobs: -DCMAKE_TOOLCHAIN_FILE=toolchains/${{ matrix.toolchain }} \ -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ -DCMAKE_INSTALL_PREFIX=./install \ - -DCMAKE_VERBOSE_MAKEFILE=ON + -DCMAKE_VERBOSE_MAKEFILE=ON ${CUSTOM_CMAKE_ARGS} cmake --build build --config ${{ matrix.build_type }} --target all -- -j `nproc` cmake --build build --config ${{ matrix.build_type }} --target install steps: @@ -52,7 +52,7 @@ jobs: run: | sudo apt-get update -y sudo apt-get install -y libarchive-dev libssl-dev autoconf libtool pkg-config cmake make gcc g++ - ${{ env.build_command }} -DULIB_BUILD_TESTS=ON + ${{ env.build_command }} - name: run_gtest if: matrix.toolchain == 'host.toolchain.cmake' @@ -68,6 +68,7 @@ jobs: export AFL_LLVM_LAF_ALL=1 export CC=/usr/bin/afl-clang-fast export CXX=/usr/bin/afl-clang-fast++ + export CUSTOM_CMAKE_ARGS="-DULIB_BUILD_TESTS=ON" ${{ env.build_command }} - name: build-in-centos diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e2254b..3f02bc1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,9 +32,6 @@ target_link_libraries(${PROJECT_NAME} PUBLIC fmt::fmt) target_compile_definitions(${PROJECT_NAME} PRIVATE ULIB_LIBRARY_IMPL) target_include_directories(${PROJECT_NAME} PUBLIC src) -add_executable(ulib_main_test src/main.cpp) -target_link_libraries(ulib_main_test PRIVATE ${PROJECT_NAME}) - install(TARGETS ${PROJECT_NAME} DESTINATION lib) if(ULIB_BUILD_TESTS) diff --git a/src/main.cpp b/src/main.cpp deleted file mode 100644 index a3442d4..0000000 --- a/src/main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// -// Created by tqcq on 2023/12/5. -// - -#include -#include -#include - -int main(int argc, char* argv[]) { - ULOG_SET_STRIPPED_PREFIX_LEN(strlen(__FILE__) - strlen("src/main.cpp")); - ULOG_TRACE("Hello, world!"); - return 0; -} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2ae4de3..30b6e84 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -4,7 +4,12 @@ project(ulib_test) set(CMAKE_CXX_STANDARD 98) set(CMAKE_CXX_STANDARD_REQUIRED ON) -add_executable(ulib_test src/ulib/sigslot/sigslot_test.cpp) -target_link_libraries(ulib_test gtest gtest_main) +add_executable(ulib_test + src/ulib/sigslot/sigslot_test.cpp) + +target_link_libraries(ulib_test PRIVATE + ulib + gtest + gtest_main) add_test(NAME ulib_test COMMAND ulib_test) diff --git a/tests/src/ulib/sigslot/sigslot_test.cpp b/tests/src/ulib/sigslot/sigslot_test.cpp index 09cde97..43c1af8 100644 --- a/tests/src/ulib/sigslot/sigslot_test.cpp +++ b/tests/src/ulib/sigslot/sigslot_test.cpp @@ -1,3 +1,6 @@ // // Created by tqcq on 2023/12/5. // + +#include +