Skip to content

Commit

Permalink
Merge pull request #54 from masatake/ctest
Browse files Browse the repository at this point in the history
Run the test cases with ctest
  • Loading branch information
masatake authored Sep 1, 2024
2 parents b865829 + 203ff54 commit 5498789
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.deps
.libs
*.a
*.gcda
*.gcno
*.gcov
Expand Down Expand Up @@ -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
31 changes: 29 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:
#
Expand All @@ -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
#
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down

0 comments on commit 5498789

Please sign in to comment.