Skip to content

Commit

Permalink
small fixes after merging #418 - also relates #413
Browse files Browse the repository at this point in the history
  • Loading branch information
onqtam committed Nov 4, 2020
1 parent 8aeb798 commit 46e3bb3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 61 deletions.
2 changes: 1 addition & 1 deletion doc/markdown/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Testing code over distributed processes requires support from the testing framew

## Example

See [**the complete test**](../../examples/mpi.cpp) and [**the configuration of main()**](../../examples/main.cpp)
See [**the complete test**](../../examples/mpi/mpi.cpp) and [**the configuration of main()**](../../examples/mpi/main.cpp)

### MPI_TEST_CASE

Expand Down
2 changes: 1 addition & 1 deletion doctest/extensions/doctest_mpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#ifdef DOCTEST_CONFIG_IMPLEMENT

#include "doctest/doctest.h"
#include "doctest/extensions/mpi_reporter.h"
#include "mpi_reporter.h"

#else

Expand Down
62 changes: 3 additions & 59 deletions examples/mpi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,63 +1,7 @@
################################################################################
## BUILD ALL EXAMPLE SOURCES INTO A SINGLE BINARY AND EXECUTE TESTS ON EACH FILE
################################################################################

# TODO factor with example/all_features/CMakeLists.txt

set(files_with_output
main.cpp
mpi.cpp
)

set(files_all
${files_with_output}
)

find_package(MPI COMPONENTS CXX)
if(MPI_FOUND)
# add the executable
add_executable(mpi_features ${files_all})
target_link_libraries(mpi_features doctest ${CMAKE_THREAD_LIBS_INIT} MPI::MPI_CXX)

# easy way to fix test coverage - disable colors and crash handling
target_compile_definitions(mpi_features PRIVATE
DOCTEST_CONFIG_COLORS_NONE
DOCTEST_CONFIG_NO_POSIX_SIGNALS
DOCTEST_CONFIG_NO_WINDOWS_SEH)

# omit the version and the num test cases skipped from the summary - this way the output will change less often
set(common_args COMMAND $<TARGET_FILE:mpi_features> --no-skipped-summary --no-version)

# add per-file tests
foreach(f ${files_with_output})
doctest_add_test(NAME ${f} ${common_args} -sf=*${f})
endforeach()

# add this separately since it shouldn't have output compared to reference output - due to concurrency
# not adding it for MinGW since it crashes when using mingw-w64-x86_64-8.1.0-release-posix-seh-rt_v6-rev0
# (also disabled for old XCode builds on travis where there is no thread_local support and this is defined in the build matrix)
if(NOT MINGW AND NOT DEFINED DOCTEST_THREAD_LOCAL)
doctest_add_test(NO_OUTPUT NAME concurrency.cpp ${common_args} -sf=*concurrency.cpp -d) # duration: there is no output anyway
endif()

# queries
doctest_add_test(NAME version COMMAND $<TARGET_FILE:mpi_features> -v)
doctest_add_test(NAME help ${common_args} -h)
doctest_add_test(NO_OUTPUT NAME outfile ${common_args} -c -out=temp) # just to exercise the output option
doctest_add_test(NAME count ${common_args} -c -sf=*coverage*)
doctest_add_test(NAME list_test_cases ${common_args} -ltc -sf=*coverage*)
doctest_add_test(NAME list_test_suites ${common_args} -lts -sf=*coverage*)
doctest_add_test(NAME list_reporters ${common_args} -lr -sf=*coverage*)
add_executable(test_mpi main.cpp mpi.cpp)
target_link_libraries(test_mpi doctest ${CMAKE_THREAD_LIBS_INIT} MPI::MPI_CXX)

# options
doctest_add_test(NAME all_binary ${common_args} -tc=all?binary* -s) # print all binary asserts - for getAssertString()
doctest_add_test(NAME abort_after ${common_args} -aa=2 -e=off -sf=*coverage*) # abort after 2 assert fails and parse a negative
doctest_add_test(NAME first_last ${common_args} -f=2 -l=4 -sf=*coverage*) # run a range
doctest_add_test(NAME filter_1 ${common_args} -ts=none) # should filter out all
# -order-by=name to avoid different output depending on the compiler used. See https://github.com/onqtam/doctest/issues/287
doctest_add_test(NAME filter_2 COMMAND $<TARGET_FILE:mpi_features> -tse=* -nv -order-by=name) # should filter out all + print skipped
doctest_add_test(NAME filter_3 ${common_args} -sc=from*,sc* -sce=sc2 -sf=*subcases*) # enter a specific subcase - sc1
doctest_add_test(NAME order_1 ${common_args} -ob=suite -ns -sf=*test_cases_and_suites*)
doctest_add_test(NAME order_2 ${common_args} -ob=name -sf=*test_cases_and_suites*)
doctest_add_test(NAME order_3 ${common_args} -ob=rand -sfe=*) # exclude everything for no output
doctest_add_test(NO_OUTPUT NAME test_mpi COMMAND mpirun -np 3 $<TARGET_FILE:test_mpi>)
endif()

0 comments on commit 46e3bb3

Please sign in to comment.