Skip to content

Commit 8ac4640

Browse files
committed
Test: Rework icalrecur_test - pass test data via params rather than hard-coding it.
1 parent cfd401b commit 8ac4640

File tree

3 files changed

+155
-638
lines changed

3 files changed

+155
-638
lines changed

cmake/run_test.cmake

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@ if(NOT test_cmd)
88
message(FATAL_ERROR "Variable test_cmd not defined")
99
endif()
1010

11-
# output_blessed contains the name of the "blessed" output file
12-
if(NOT output_blessed)
13-
message(FATAL_ERROR "Variable output_blessed not defined")
14-
endif()
15-
16-
# output_test contains the name of the output file the test_cmd will produce
17-
if(NOT output_test)
18-
message(FATAL_ERROR "Variable output_test not defined")
19-
endif()
20-
2111
# convert the space-separated string to a list
2212
separate_arguments(test_args UNIX_COMMAND ${test_args})
2313

@@ -30,16 +20,3 @@ execute_process(
3020
if(test_not_successful)
3121
message(SEND_ERROR "Unable to run test '${test_cmd}': ${err} : shell output: ${test_not_successful}!")
3222
endif()
33-
34-
execute_process(
35-
COMMAND ${CMAKE_COMMAND} -E compare_files --ignore-eol ${output_blessed} ${output_test}
36-
RESULT_VARIABLE test_not_successful
37-
ERROR_VARIABLE err
38-
)
39-
40-
if(test_not_successful)
41-
message(
42-
SEND_ERROR
43-
"Output does not match for ${output_blessed} and ${output_test}: ${err} : shell output: ${test_not_successful}!"
44-
)
45-
endif()

src/test/CMakeLists.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ set(CMAKE_COMPARE_FILES_IGNORE_EOL TRUE)
183183
#ignore_eol doesn't work on Cygwin. testing years greater than 2037 will fail
184184
if(NOT CYGWIN AND NOT USE_32BIT_TIME_T)
185185
set(icalrecurtest_SRCS icalrecur_test.c)
186+
configure_file(icalrecur_test.out icalrecur_test.out COPYONLY)
187+
configure_file(icalrecur_withicu_test.out icalrecur_withicu_test.out COPYONLY)
188+
configure_file(icalrecur_withouticu_test.out icalrecur_withouticu_test.out COPYONLY)
189+
configure_file(icalrecur_withicu_dangi_test.out icalrecur_withicu_dangi_test.out COPYONLY)
186190
add_executable(icalrecurtest ${icalrecurtest_SRCS})
187191
target_link_libraries(icalrecurtest ical icalss icalvcal)
188192
if(WITH_CXX_BINDINGS)
@@ -192,31 +196,29 @@ if(NOT CYGWIN AND NOT USE_32BIT_TIME_T)
192196
set(test_cmd "${PROJECT_BINARY_DIR}/src/test/icalrecurtest${CMAKE_EXECUTABLE_SUFFIX}")
193197

194198
#test rscale capable rrules
195-
set(test_args "-r")
196199
if(HAVE_ICU_DANGI)
197200
set(reference_data "icalrecur_withicu_dangi_test.out")
198201
elseif(ICU_FOUND)
199202
set(reference_data "icalrecur_withicu_test.out")
200203
else()
201204
set(reference_data "icalrecur_withouticu_test.out")
202205
endif()
206+
set(test_args "-f ${PROJECT_BINARY_DIR}/src/test/${reference_data}")
203207
add_test(
204208
NAME icalrecurtest-r
205209
COMMAND
206-
${CMAKE_COMMAND} -D test_cmd=${test_cmd} -D test_args:string=${test_args} -D
207-
output_blessed=${PROJECT_SOURCE_DIR}/src/test/${reference_data} -D output_test=${PROJECT_BINARY_DIR}/bin/test.out
210+
${CMAKE_COMMAND} -D test_cmd=${test_cmd} -D test_args:string=${test_args}
208211
-P ${PROJECT_SOURCE_DIR}/cmake/run_test.cmake
209212
)
210213
setprops(icalrecurtest-r)
211214

212215
#test non-rscale rrules
213-
set(test_args "")
214216
set(reference_data "icalrecur_test.out")
217+
set(test_args "-f ${PROJECT_BINARY_DIR}/src/test/${reference_data}")
215218
add_test(
216219
NAME icalrecurtest
217220
COMMAND
218-
${CMAKE_COMMAND} -D test_cmd=${test_cmd} -D test_args:string=${test_args} -D
219-
output_blessed=${PROJECT_SOURCE_DIR}/src/test/${reference_data} -D output_test=${PROJECT_BINARY_DIR}/bin/test.out
221+
${CMAKE_COMMAND} -D test_cmd=${test_cmd} -D test_args:string=${test_args}
220222
-P ${PROJECT_SOURCE_DIR}/cmake/run_test.cmake
221223
)
222224
setprops(icalrecurtest)

0 commit comments

Comments
 (0)