Skip to content

Commit 8b41926

Browse files
committed
Simplify 'add_ydb_multiple_tests' command
1 parent de02d8b commit 8b41926

File tree

2 files changed

+195
-226
lines changed

2 files changed

+195
-226
lines changed

cmake/testing.cmake

Lines changed: 11 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -153,17 +153,14 @@ endfunction()
153153

154154
#[=============================================================================[
155155
This wrapper over `add_ydb_test` adds a separate test for each test file in
156-
FILES list. Mandatory PREFIX will prepend the test name. All the test files
157-
must have either an absolute or relative path. If test files have a relative
158-
path, their paths will be prepended by BASE_DIR, and then, if BASE_DIR is not
159-
empty, BASE_DIR will also prepend the test name after PREFIX. If BASE_DIR is
160-
empty then the current source directory is used instead. All other parameters
161-
of `add_ydb_test` except NAME and SOURCES are passed after ADD_YDB_TEST_ARGS
162-
keyword.
156+
FILES list. Mandatory PREFIX will prepend the test name. If test files have
157+
a relative path, their paths will be prepended by CMAKE_CURRENT_SOURCE_DIR.
158+
All other parameters of `add_ydb_test` except NAME and SOURCES are passed
159+
after ADD_YDB_TEST_ARGS keyword.
163160
#]=============================================================================]
164161
function(add_ydb_multiple_tests)
165162
set(opts "")
166-
set(oneval_args PREFIX BASE_DIR)
163+
set(oneval_args PREFIX)
167164
set(multival_args FILES ADD_YDB_TEST_ARGS)
168165
cmake_parse_arguments(ARGS
169166
"${opts}"
@@ -180,44 +177,16 @@ function(add_ydb_multiple_tests)
180177
message(FATAL_ERROR "Missing the FILES list.")
181178
endif()
182179

183-
set(test_prefix "${ARGS_PREFIX}")
180+
foreach (testPath IN LISTS ARGS_FILES)
181+
get_filename_component(testSuffix "${testPath}" NAME_WLE)
184182

185-
if (NOT ARGS_BASE_DIR)
186-
set(ARGS_BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
187-
else()
188-
set(test_prefix "${test_prefix}-${ARGS_BASE_DIR}")
189-
if (NOT IS_ABSOLUTE "${ARGS_BASE_DIR}")
190-
set(ARGS_BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${ARGS_BASE_DIR}")
191-
endif()
192-
endif()
193-
194-
list(GET ARGS_FILES 0 firts_file_path)
195-
if (IS_ABSOLUTE "${firts_file_path}")
196-
set(file_path_is_absolute TRUE)
197-
else()
198-
set(file_path_is_absolute FALSE)
199-
endif()
200-
201-
foreach (test_path IN LISTS ARGS_FILES)
202-
get_filename_component(test_suffix "${test_path}" NAME_WLE)
203-
204-
set(file_path_kind_error FALSE)
205-
if (NOT IS_ABSOLUTE "${test_path}")
206-
if (file_path_is_absolute)
207-
set(file_path_kind_error TRUE)
208-
endif()
209-
set(test_path "${ARGS_BASE_DIR}/${test_path}")
210-
elseif (NOT file_path_is_absolute)
211-
set(file_path_kind_error TRUE)
212-
endif()
213-
214-
if (file_path_kind_error)
215-
message(FATAL_ERROR "All paths of test files must be either relative or absolute.")
183+
if (NOT IS_ABSOLUTE "${testPath}")
184+
set(testPath "${CMAKE_CURRENT_SOURCE_DIR}/${testPath}")
216185
endif()
217186

218-
add_ydb_test(NAME "${test_prefix}-${test_suffix}"
187+
add_ydb_test(NAME "${ARGS_PREFIX}-${testSuffix}"
219188
SOURCES
220-
"${test_path}"
189+
"${testPath}"
221190
${ARGS_ADD_YDB_TEST_ARGS}
222191
)
223192
endforeach()

0 commit comments

Comments
 (0)