From f0bb081797d15dbb06eee7deb339f50d8739651d Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Wed, 10 Jul 2024 18:07:07 +0900 Subject: [PATCH 1/2] .gitignore: add the "build" dir and and the static library file Signed-off-by: Masatake YAMATO --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 682ad0aa..7349962b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .deps .libs +*.a *.gcda *.gcno *.gcov @@ -46,3 +47,5 @@ tests/test-fix-unescaping-input-fields-exuberant tests/test-fix-unescaping-input-fields-no-mode tests/test-fix-unescaping-input-fields-backslash tests/test-fix-unescaping-input-fields-no-filesep + +build From 203ff54c2203924b9001d89559dd722e8a9facdd Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Wed, 10 Jul 2024 19:00:49 +0900 Subject: [PATCH 2/2] Run the test cases with ctest Signed-off-by: Masatake YAMATO --- .circleci/config.yml | 8 ++++++++ CMakeLists.txt | 31 +++++++++++++++++++++++++++++-- README.md | 8 ++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 179bdd07..3dfa8e3f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,6 +20,14 @@ jobs: mkdir build cmake -DCMAKE_BUILD_TYPE=Release -DLIBREADTAGS_BUILD_SHARED=ON -S . -B build cmake --build build --target readtags + - run: + name: Build test cases + command: | + cmake --build build + - run: + name: Run the test cases + command: | + ctest --test-dir build || cat build/Testing/Temporary/LastTest.log - run: name: Install command: | diff --git a/CMakeLists.txt b/CMakeLists.txt index 99aa2255..c39059f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,6 +45,35 @@ endif () add_library(universal-ctags::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + +enable_testing() +set(test_cases + test-api-tagsOpen + test-api-tagsFind + test-api-tagsFindPseudoTag + test-api-tagsFirstPseudoTag + test-api-tagsFirst + test-api-tagsClose + test-api-tagsSetSortType + + test-fix-unescaping + test-fix-null-deref + test-fix-large-tags + test-fix-unescaping-input-fields + test-fix-unescaping-input-fields-exuberant + test-fix-unescaping-input-fields-no-mode + test-fix-unescaping-input-fields-backslash + test-fix-unescaping-input-fields-no-filesep +) + +foreach(t IN LISTS test_cases) + add_executable(${t} tests/${t}.c) + target_link_libraries(${t} readtags) + add_test(NAME ${t} + COMMAND ${t} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests) +endforeach() + # # TODO: # @@ -58,5 +87,3 @@ target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) # Finding Packages. But if you use CMake method FetchContent to add # libreadtags to your project, then current changes should be enough. # -# * Running test cases -# diff --git a/README.md b/README.md index 9a1f54c9..ead49768 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,14 @@ cmake -DCMAKE_BUILD_TYPE=Release -DLIBREADTAGS_BUILD_SHARED=ON -S . -B build cmake --build build --target readtags ``` +#### Configure, build, and test +```shell +mkdir build +cmake -DCMAKE_BUILD_TYPE=Release -DLIBREADTAGS_BUILD_SHARED=ON -S . -B build +cmake --build build +ctest --test-dir build +``` + #### Configure and install This will install the library and headers to `/usr/local`.