@@ -150,3 +150,71 @@ function(add_ydb_test)
150
150
151
151
vcs_info (${YDB_TEST_NAME} )
152
152
endfunction ()
153
+
154
+ #[=============================================================================[
155
+ 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.
163
+ #]=============================================================================]
164
+ function (add_ydb_multiple_tests )
165
+ set (opts "" )
166
+ set (oneval_args PREFIX BASE_DIR )
167
+ set (multival_args FILES ADD_YDB_TEST_ARGS )
168
+ cmake_parse_arguments (ARGS
169
+ "${opts} "
170
+ "${oneval_args} "
171
+ "${multival_args} "
172
+ ${ARGN}
173
+ )
174
+
175
+ if (NOT ARGS_PREFIX )
176
+ message (FATAL_ERROR "Missing the PREFIX parameter." )
177
+ endif ()
178
+
179
+ if (NOT ARGS_FILES )
180
+ message (FATAL_ERROR "Missing the FILES list." )
181
+ endif ()
182
+
183
+ set (test_prefix "${ARGS_PREFIX} " )
184
+
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
+ endif ()
190
+
191
+ list (GET ARGS_FILES 0 firts_file_path )
192
+ if (IS_ABSOLUTE "${firts_file_path} " )
193
+ set (file_path_is_absolute TRUE )
194
+ else ()
195
+ set (file_path_is_absolute FALSE )
196
+ endif ()
197
+
198
+ foreach (test_path IN LISTS ARGS_FILES )
199
+ get_filename_component (test_suffix "${test_path} " NAME_WLE )
200
+
201
+ if (NOT IS_ABSOLUTE "${test_path} " )
202
+ if (file_path_is_absolute )
203
+ set (file_path_kind_error TRUE )
204
+ endif ()
205
+ set (test_path "${ARGS_BASE_DIR} /${test_path} " )
206
+ elseif (NOT file_path_is_absolute )
207
+ set (file_path_kind_error TRUE )
208
+ endif ()
209
+
210
+ if (file_path_kind_error )
211
+ message (FATAL_ERROR "All paths of test files must be either relative or absolute." )
212
+ endif ()
213
+
214
+ add_ydb_test (NAME "${test_prefix} -${test_suffix} "
215
+ SOURCES
216
+ "${test_path} "
217
+ ${ARGS_ADD_YDB_TEST_ARGS}
218
+ )
219
+ endforeach ()
220
+ endfunction ()
0 commit comments