From: Sergey Bronnikov via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: tarantool-patches@dev.tarantool.org Subject: [Tarantool-patches] [PATCH] build: configure parallel jobs Date: Fri, 1 Jul 2022 17:36:50 +0300 [thread overview] Message-ID: <62acf609d9e1ea43d95cb27213e1b8f1331b57a7.1656685987.git.sergeyb@tarantool.org> (raw) lua-Harness and tarantool testsuites uses a prove(1) for running tests. prove(1) allows to run tests in parallel with option "--jobs" [1]. In CMake it is not possible to get a number of parallel jobs in CMake passed by user with option "-j", but it allows to pass a number of parallel jobs with environment variable CMAKE_BUILD_PARALLEL_LEVEL [2] on configuration phase. We use a value set by that environment variable and set it to a number of CPU threads when it was not specified by user. Number of CPU threads detected using builtin CMake function [3]. NOTE: CMAKE_BUILD_PARALLEL_LEVEL has been added in a version 3.12. 1. https://perldoc.perl.org/prove 2. https://cmake.org/cmake/help/latest/envvar/CMAKE_BUILD_PARALLEL_LEVEL.html 3. https://cmake.org/cmake/help/latest/module/ProcessorCount.html --- Branch: https://github.com/tarantool/luajit/tree/ligurio/prove-in-parallel CI: https://github.com/tarantool/luajit/commit/62acf609d9e1ea43d95cb27213e1b8f1331b57a7 test/CMakeLists.txt | 13 +++++++++++++ test/lua-Harness-tests/CMakeLists.txt | 1 + test/tarantool-tests/CMakeLists.txt | 1 + 3 files changed, 15 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ba25af54..fc4ffc51 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -43,6 +43,19 @@ endif() set(LUAJIT_TEST_COMMAND "${LUAJIT_TEST_BINARY} -e dofile[[${LUAJIT_TEST_INIT}]]") separate_arguments(LUAJIT_TEST_COMMAND) +set(CMAKE_BUILD_PARALLEL_LEVEL $ENV{CMAKE_BUILD_PARALLEL_LEVEL}) +if(NOT CMAKE_BUILD_PARALLEL_LEVEL) + include(ProcessorCount) + ProcessorCount(N) + # Function ProcessorCount() is guaranteed to return a positive integer (>=1) + # if it succeeds. It returns 0 if there's a problem determining the processor + # count. + if(NOT N EQUAL 0) + set(CMAKE_BUILD_PARALLEL_LEVEL ${N}) + endif() +endif() +message(STATUS "Using CMAKE_BUILD_PARALLEL_LEVEL: ${CMAKE_BUILD_PARALLEL_LEVEL}") + add_subdirectory(LuaJIT-tests) add_subdirectory(PUC-Rio-Lua-5.1-tests) add_subdirectory(lua-Harness-tests) diff --git a/test/lua-Harness-tests/CMakeLists.txt b/test/lua-Harness-tests/CMakeLists.txt index ec08a19b..12476171 100644 --- a/test/lua-Harness-tests/CMakeLists.txt +++ b/test/lua-Harness-tests/CMakeLists.txt @@ -28,6 +28,7 @@ add_custom_command(TARGET lua-Harness-tests LUA_PATH="${LUA_PATH}\;" ${PROVE} ${CMAKE_CURRENT_SOURCE_DIR} --exec '${LUAJIT_TEST_COMMAND} -l profile_luajit21' + --jobs ${CMAKE_BUILD_PARALLEL_LEVEL} ${LUA_TEST_FLAGS} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) diff --git a/test/tarantool-tests/CMakeLists.txt b/test/tarantool-tests/CMakeLists.txt index 5708822e..ecda2e63 100644 --- a/test/tarantool-tests/CMakeLists.txt +++ b/test/tarantool-tests/CMakeLists.txt @@ -136,6 +136,7 @@ add_custom_command(TARGET tarantool-tests ${PROVE} ${CMAKE_CURRENT_SOURCE_DIR} --exec 'env ${LUA_TEST_ENV_MORE} ${LUAJIT_TEST_COMMAND}' --ext ${LUA_TEST_SUFFIX} + --jobs ${CMAKE_BUILD_PARALLEL_LEVEL} ${LUA_TEST_FLAGS} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) -- 2.25.1
next reply other threads:[~2022-07-01 14:37 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-07-01 14:36 Sergey Bronnikov via Tarantool-patches [this message] 2022-07-04 9:52 ` Sergey Kaplun via Tarantool-patches 2022-07-04 10:06 ` Sergey Bronnikov via Tarantool-patches 2022-07-04 10:12 ` Igor Munkin via Tarantool-patches 2022-07-04 14:21 ` Sergey Bronnikov via Tarantool-patches 2022-07-05 21:22 ` Igor Munkin via Tarantool-patches 2022-07-06 10:32 ` Sergey Bronnikov via Tarantool-patches 2022-07-13 10:10 ` Igor Munkin via Tarantool-patches
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=62acf609d9e1ea43d95cb27213e1b8f1331b57a7.1656685987.git.sergeyb@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=estetus@gmail.com \ --subject='Re: [Tarantool-patches] [PATCH] build: configure parallel jobs' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox