Skip to content

Commit

Permalink
cmake: create separate target for running tests
Browse files Browse the repository at this point in the history
Run tests in CMake by a separate target ('make check') and not as a
CMake test.

Part of #134
  • Loading branch information
ligurio committed Oct 27, 2021
1 parent 6749fd5 commit 0ef5dbc
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
make -C build
- name: Run tests
run: make -C build check
run: make -C build luatest
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- Revert all changes related to http v2 (#134).
- Rewrite TAP tests with luatest.
- Create a separate target for running tests in CMake.

### Added

Expand Down
16 changes: 6 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,12 @@ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -Wextra")

add_subdirectory(http)

enable_testing()
add_custom_target(luatest
COMMAND ${LUATEST} -v
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Run regression tests"
)

set (LUA_PATH "LUA_PATH=${PROJECT_SOURCE_DIR}/?.lua\\;${PROJECT_SOURCE_DIR}/?/init.lua\\;\\;")
set (LUA_SOURCE_DIR "LUA_SOURCE_DIR=${PROJECT_SOURCE_DIR}")

add_test(http ${LUATEST})

set_tests_properties(http PROPERTIES ENVIRONMENT "${LUA_PATH};${LUA_SOURCE_DIR}")

# Add `make check`
add_custom_target(check
WORKING_DIRECTORY ${PROJECT_BUILD_DIR}
COMMAND ctest -V)
set_target_properties(luatest PROPERTIES ENVIRONMENT "${LUA_PATH};${LUA_SOURCE_DIR}")
2 changes: 1 addition & 1 deletion debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

DEB_CMAKE_EXTRA_FLAGS := -DCMAKE_INSTALL_LIBDIR=lib/$(DEB_HOST_MULTIARCH) \
-DCMAKE_BUILD_TYPE=RelWithDebInfo
DEB_MAKE_CHECK_TARGET := check
DEB_MAKE_CHECK_TARGET := luatest

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/cmake.mk
2 changes: 1 addition & 1 deletion rpm/tarantool-http.spec
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This package provides a HTTP server for Tarantool.
make %{?_smp_mflags}

%check
make %{?_smp_mflags} check
make %{?_smp_mflags} luatest

%install
%make_install
Expand Down

0 comments on commit 0ef5dbc

Please sign in to comment.