Skip to content

Commit

Permalink
Test: Rework icalrecur_test - pass test data via params rather than h…
Browse files Browse the repository at this point in the history
…ard-coding it.
  • Loading branch information
minichma committed Oct 22, 2024
1 parent cfd401b commit 6b3c263
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 638 deletions.
23 changes: 0 additions & 23 deletions cmake/run_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@ if(NOT test_cmd)
message(FATAL_ERROR "Variable test_cmd not defined")
endif()

# output_blessed contains the name of the "blessed" output file
if(NOT output_blessed)
message(FATAL_ERROR "Variable output_blessed not defined")
endif()

# output_test contains the name of the output file the test_cmd will produce
if(NOT output_test)
message(FATAL_ERROR "Variable output_test not defined")
endif()

# convert the space-separated string to a list
separate_arguments(test_args UNIX_COMMAND ${test_args})

Expand All @@ -30,16 +20,3 @@ execute_process(
if(test_not_successful)
message(SEND_ERROR "Unable to run test '${test_cmd}': ${err} : shell output: ${test_not_successful}!")
endif()

execute_process(
COMMAND ${CMAKE_COMMAND} -E compare_files --ignore-eol ${output_blessed} ${output_test}
RESULT_VARIABLE test_not_successful
ERROR_VARIABLE err
)

if(test_not_successful)
message(
SEND_ERROR
"Output does not match for ${output_blessed} and ${output_test}: ${err} : shell output: ${test_not_successful}!"
)
endif()
14 changes: 8 additions & 6 deletions src/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ testme(recur "${recur_SRCS}")

if(HAVE_GETOPT) #getopt is required
set(icalrecur_test_SRCS icalrecur_test.c)
configure_file(icalrecur_test.out icalrecur_test.out COPYONLY)
configure_file(icalrecur_withicu_test.out icalrecur_withicu_test.out COPYONLY)
configure_file(icalrecur_withouticu_test.out icalrecur_withouticu_test.out COPYONLY)
configure_file(icalrecur_withicu_dangi_test.out icalrecur_withicu_dangi_test.out COPYONLY)
buildme(icalrecur_test "${icalrecur_test_SRCS}")
endif()

Expand Down Expand Up @@ -192,31 +196,29 @@ if(NOT CYGWIN AND NOT USE_32BIT_TIME_T)
set(test_cmd "${PROJECT_BINARY_DIR}/src/test/icalrecurtest${CMAKE_EXECUTABLE_SUFFIX}")

#test rscale capable rrules
set(test_args "-r")
if(HAVE_ICU_DANGI)
set(reference_data "icalrecur_withicu_dangi_test.out")
elseif(ICU_FOUND)
set(reference_data "icalrecur_withicu_test.out")
else()
set(reference_data "icalrecur_withouticu_test.out")
endif()
set(test_args "-f ${PROJECT_BINARY_DIR}/src/test/${reference_data}")
add_test(
NAME icalrecurtest-r
COMMAND
${CMAKE_COMMAND} -D test_cmd=${test_cmd} -D test_args:string=${test_args} -D
output_blessed=${PROJECT_SOURCE_DIR}/src/test/${reference_data} -D output_test=${PROJECT_BINARY_DIR}/bin/test.out
${CMAKE_COMMAND} -D test_cmd=${test_cmd} -D test_args:string=${test_args}
-P ${PROJECT_SOURCE_DIR}/cmake/run_test.cmake
)
setprops(icalrecurtest-r)

#test non-rscale rrules
set(test_args "")
set(reference_data "icalrecur_test.out")
set(test_args "-f ${PROJECT_BINARY_DIR}/src/test/${reference_data}")
add_test(
NAME icalrecurtest
COMMAND
${CMAKE_COMMAND} -D test_cmd=${test_cmd} -D test_args:string=${test_args} -D
output_blessed=${PROJECT_SOURCE_DIR}/src/test/${reference_data} -D output_test=${PROJECT_BINARY_DIR}/bin/test.out
${CMAKE_COMMAND} -D test_cmd=${test_cmd} -D test_args:string=${test_args}
-P ${PROJECT_SOURCE_DIR}/cmake/run_test.cmake
)
setprops(icalrecurtest)
Expand Down
Loading

0 comments on commit 6b3c263

Please sign in to comment.