Merge pull request #940 from akva2/parallel_tests_in_check_target

Execute tests in parallel for the 'check' target
This commit is contained in:
Arne Morten Kvarving 2019-08-19 13:51:23 +02:00 committed by GitHub
commit d6cbf47e38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 21 deletions

View File

@ -261,9 +261,13 @@ macro (cond_disable_test name)
endif ((NOT DEFINED HAVE_${name}) OR (NOT HAVE_${name}))
endmacro (cond_disable_test name)
# use this target to run all tests
# use this target to run all tests, with parallel execution
cmake_host_system_information(RESULT TESTJOBS QUERY NUMBER_OF_PHYSICAL_CORES)
if(TESTJOBS EQUAL 0)
set(TESTJOBS 1)
endif()
add_custom_target (check
COMMAND ${CMAKE_CTEST_COMMAND}
COMMAND ${CMAKE_CTEST_COMMAND} -j${TESTJOBS}
DEPENDS test-suite
COMMENT "Checking if library is functional"
VERBATIM

View File

@ -31,30 +31,15 @@ if(NOT check_target)
endif()
# Build threads
include(ProcessorCount)
set(build_threads $ENV{CHECK_THREADS})
if(NOT build_threads)
if(UNIX)
if(APPLE)
execute_process(COMMAND sysctl hw.ncpu
OUTPUT_VARIABLE build_threads)
string(REPLACE " " ";" build_threads_list ${build_threads)
list(GET build_threads_list 1 build_threads)
else()
find_program(NPROC_COMMAND nproc)
if(NPROC_COMMAND)
execute_process(COMMAND ${NPROC_COMMAND}
OUTPUT_VARIABLE build_threads)
string(REGEX REPLACE "(\r?\n)+$" "" build_threads "${build_threads}")
endif()
endif()
ProcessorCount(build_threads)
if(build_threads EQUAL 0)
set(build_threads 1)
endif()
endif()
# If for some reason we could not find the info - e.g. centos5 where nproc is missing
if(NOT build_threads)
set(build_threads 1)
endif()
# Record current HEAD
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
OUTPUT_VARIABLE current_branch