Skip to content

Commit

Permalink
Merge pull request #32 from pedrobiqua/refactor-tests
Browse files Browse the repository at this point in the history
It's ok
  • Loading branch information
pedrobiqua authored Jan 5, 2025
2 parents 5ed0525 + 7f6c40e commit 5bf2f45
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,10 @@ project(search_engine VERSION 1.0)

add_subdirectory(lib)

include(FetchContent)
add_subdirectory(tests/unit-tests)
option(BUILD_TESTS "Build and enable tests" ON)

if (BUILD_TESTS)
enable_testing()
include(FetchContent)
add_subdirectory(tests/unit-tests)
endif()
3 changes: 2 additions & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def build_lib_cpp(path: str):
old_path = os.getcwd()
os.makedirs(path)
os.chdir(path)
subprocess.run(["cmake", ".."])
subprocess.run(["cmake", "..", "-DBUILD_TESTS=OFF"])
subprocess.run(["make"])
os.chdir(old_path)

Expand All @@ -43,6 +43,7 @@ def build(setup_kwargs):

extensions = []


for lib in libs_names:
ext = Extension(
f"{lib}",
Expand Down
6 changes: 5 additions & 1 deletion tests/unit-tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ add_executable(

target_include_directories(LibUnitTests PRIVATE ${CMAKE_SOURCE_DIR}/lib/include/)

target_link_libraries(LibUnitTests PRIVATE gtest_main search_engine)
target_link_libraries(LibUnitTests PRIVATE gtest_main search_engine)

# Add command cmake test
include(GoogleTest)
gtest_discover_tests(LibUnitTests)

0 comments on commit 5bf2f45

Please sign in to comment.