Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to fix tests in appveyor build. #7

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ before_build:
- if defined BINDIR (set "PATH=%BINDIR%;%PATH:C:\Program Files\Git\usr\bin;=%")
- md build_dir
- cd build_dir
- cmake -Wno-dev -DEXTLOG_TESTS=ON -DEXTLOG_EXAMPLES=ON --config "%CONFIGURATION%" -G "%GENERATOR%" ..
- cmake -Wno-dev -DEXTLOG_TESTS=ON -DEXTLOG_EXAMPLES=ON -G "%GENERATOR%" ..

build_script:
- cmake --build . --config "%CONFIGURATION%"

test_script:
- ctest -C "%CONFIGURATION%" --output-on-failure
- C:\projects\logging\build_dir\tests\Release\test-ext-logging.exe
- ctest -C "%CONFIGURATION%" --rerun-failed --output-on-failure -VV
33 changes: 23 additions & 10 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,26 @@ foreach(test_name IN LISTS test-files${suffix}) # <- DO NOT EXPAND LIST
list(APPEND test_sources "${test_name}.cpp")
endforeach()

set(test_target "test-ext-logging${suffix}")
add_executable("${test_target}" gtest.cpp ${test_sources})
target_include_directories("${test_target}" SYSTEM PRIVATE ${gtest_SOURCE_DIR}/include)
target_link_libraries("${test_target}" ext::basics ext::logging gtest_main gtest Threads::Threads)
target_compile_options("${test_target}" PRIVATE ${ext_stone-warnings})
target_compile_definitions("${test_target}" PUBLIC EXT_CHECKED=1 EXT_IN_TEST=1)
# -- repeated calls should append which does not happen for me (cmake 3.16 on linux)
#target_compile_definitions("${test_target}" PUBLIC EXT_IN_TEST=1
add_test(NAME "${test_target}_run" COMMAND $<TARGET_FILE:${test_target}>)
set_target_properties (${test_target} PROPERTIES FOLDER tests/${test_target})
foreach(suffix IN ITEMS "")
#build one executable
set(test_sources)
foreach(test_name IN LISTS test-files${suffix}) # <- DO NOT EXPAND LIST
list(APPEND test_sources "${test_name}.cpp")
endforeach()

set(test_target "test-ext-logging${suffix}")
add_executable("${test_target}" gtest.cpp ${test_sources})
target_include_directories("${test_target}" SYSTEM PRIVATE ${gtest_SOURCE_DIR}/include)
target_link_libraries("${test_target}"
ext::basics${suffix}
ext::logging${suffix}
gtest_main gtest
Threads::Threads
)
target_compile_options("${test_target}" PRIVATE ${ext_stone-warnings})
target_compile_definitions("${test_target}" PUBLIC EXT_CHECKED=1 EXT_IN_TEST=1)
# -- repeated calls should append which does not happen for me (cmake 3.16 on linux)
#target_compile_definitions("${test_target}" PUBLIC EXT_IN_TEST=1
add_test(NAME "${test_target}_run" COMMAND $<TARGET_FILE:${test_target}>)
set_target_properties (${test_target} PROPERTIES FOLDER tests/${test_target})
endforeach()