Skip to content

Commit 48a7a19

Browse files
committed
tests: Support parallel execution of script and project-mode tests
Isolate script-mode tests using dedicated working directories, and assign unique build directories for each project-mode test. These changes ensure tests can safely execute in parallel when `ctest -jN` is used.
1 parent 003b029 commit 48a7a19

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tests/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ configure_file(
283283
)
284284

285285
# project-mode
286-
set(project_mode_src_dir "${CMAKE_CURRENT_BINARY_DIR}/test-find-vcvars")
286+
set(project_mode_src_dir "${CMAKE_CURRENT_BINARY_DIR}/project-mode-test-find-vcvars")
287287
configure_file(
288288
${CMAKE_CURRENT_BINARY_DIR}/test-find-vcvars.cmake.in
289289
${project_mode_src_dir}/CMakeLists.txt
@@ -313,9 +313,12 @@ function(add_find_vcvars_test)
313313
)
314314

315315
# script-mode
316+
set(wrk_dir "${CMAKE_CURRENT_BINARY_DIR}/script-mode-test-find-vcvars-${test_name_suffix}")
317+
file(MAKE_DIRECTORY ${wrk_dir})
316318
add_test(
317319
NAME "script-mode-${test_name_suffix}"
318320
COMMAND ${CMAKE_COMMAND} ${arg_OPTIONS} -P ${script_mode_script}
321+
WORKING_DIRECTORY ${wrk_dir}
319322
)
320323

321324
# project-mode
@@ -330,7 +333,7 @@ function(add_find_vcvars_test)
330333
NAME "project-mode-${test_name_suffix}-setup"
331334
COMMAND ${CMAKE_COMMAND} -E rm -rf ${bld_dir}
332335
)
333-
set_tests_properties("project-mode${suffix}-${test_name_suffix}-setup" PROPERTIES FIXTURES_SETUP "fixture-${test_name_suffix}")
336+
set_tests_properties("project-mode-${test_name_suffix}-setup" PROPERTIES FIXTURES_SETUP "fixture-${test_name_suffix}")
334337
endfunction()
335338

336339
_add_find_vcvars_test("")

0 commit comments

Comments
 (0)